gdatetime: Deprecate GDateTime API which uses GTimeVal

GTimeVal is not year-2038-safe.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #1438
This commit is contained in:
Philip Withnall 2019-06-18 12:34:30 +01:00
parent 44d1fa3070
commit e971b25c6a
2 changed files with 21 additions and 3 deletions

View File

@ -854,6 +854,7 @@ g_date_time_replace_days (GDateTime *datetime,
/* now/unix/timeval Constructors {{{1 */ /* now/unix/timeval Constructors {{{1 */
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
/*< internal > /*< internal >
* g_date_time_new_from_timeval: * g_date_time_new_from_timeval:
* @tz: a #GTimeZone * @tz: a #GTimeZone
@ -887,6 +888,7 @@ g_date_time_new_from_timeval (GTimeZone *tz,
return g_date_time_from_instant (tz, tv->tv_usec + return g_date_time_from_instant (tz, tv->tv_usec +
UNIX_TO_INSTANT (tv->tv_sec)); UNIX_TO_INSTANT (tv->tv_sec));
} }
G_GNUC_END_IGNORE_DEPRECATIONS
/*< internal > /*< internal >
* g_date_time_new_from_unix: * g_date_time_new_from_unix:
@ -1084,7 +1086,10 @@ g_date_time_new_from_unix_utc (gint64 t)
* Returns: a new #GDateTime, or %NULL * Returns: a new #GDateTime, or %NULL
* *
* Since: 2.26 * Since: 2.26
* Deprecated: 2.62: #GTimeVal is not year-2038-safe. Use
* g_date_time_new_from_unix_local() instead.
**/ **/
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
GDateTime * GDateTime *
g_date_time_new_from_timeval_local (const GTimeVal *tv) g_date_time_new_from_timeval_local (const GTimeVal *tv)
{ {
@ -1097,6 +1102,7 @@ g_date_time_new_from_timeval_local (const GTimeVal *tv)
return datetime; return datetime;
} }
G_GNUC_END_IGNORE_DEPRECATIONS
/** /**
* g_date_time_new_from_timeval_utc: * g_date_time_new_from_timeval_utc:
@ -1116,7 +1122,10 @@ g_date_time_new_from_timeval_local (const GTimeVal *tv)
* Returns: a new #GDateTime, or %NULL * Returns: a new #GDateTime, or %NULL
* *
* Since: 2.26 * Since: 2.26
* Deprecated: 2.62: #GTimeVal is not year-2038-safe. Use
* g_date_time_new_from_unix_utc() instead.
**/ **/
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
GDateTime * GDateTime *
g_date_time_new_from_timeval_utc (const GTimeVal *tv) g_date_time_new_from_timeval_utc (const GTimeVal *tv)
{ {
@ -1129,6 +1138,7 @@ g_date_time_new_from_timeval_utc (const GTimeVal *tv)
return datetime; return datetime;
} }
G_GNUC_END_IGNORE_DEPRECATIONS
/* Parse integers in the form d (week days), dd (hours etc), ddd (ordinal days) or dddd (years) */ /* Parse integers in the form d (week days), dd (hours etc), ddd (ordinal days) or dddd (years) */
static gboolean static gboolean
@ -2533,7 +2543,10 @@ g_date_time_to_unix (GDateTime *datetime)
* Returns: %TRUE if successful, else %FALSE * Returns: %TRUE if successful, else %FALSE
* *
* Since: 2.26 * Since: 2.26
* Deprecated: 2.62: #GTimeVal is not year-2038-safe. Use
* g_date_time_to_unix() instead.
**/ **/
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gboolean gboolean
g_date_time_to_timeval (GDateTime *datetime, g_date_time_to_timeval (GDateTime *datetime,
GTimeVal *tv) GTimeVal *tv)
@ -2543,6 +2556,7 @@ g_date_time_to_timeval (GDateTime *datetime,
return TRUE; return TRUE;
} }
G_GNUC_END_IGNORE_DEPRECATIONS
/* Timezone queries {{{1 */ /* Timezone queries {{{1 */
/** /**

View File

@ -113,10 +113,12 @@ GDateTime * g_date_time_new_from_unix_local (gint64
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
GDateTime * g_date_time_new_from_unix_utc (gint64 t); GDateTime * g_date_time_new_from_unix_utc (gint64 t);
GLIB_AVAILABLE_IN_ALL G_GNUC_BEGIN_IGNORE_DEPRECATIONS
GLIB_DEPRECATED_IN_2_62_FOR(g_date_time_new_from_unix_local)
GDateTime * g_date_time_new_from_timeval_local (const GTimeVal *tv); GDateTime * g_date_time_new_from_timeval_local (const GTimeVal *tv);
GLIB_AVAILABLE_IN_ALL GLIB_DEPRECATED_IN_2_62_FOR(g_date_time_new_from_unix_utc)
GDateTime * g_date_time_new_from_timeval_utc (const GTimeVal *tv); GDateTime * g_date_time_new_from_timeval_utc (const GTimeVal *tv);
G_GNUC_END_IGNORE_DEPRECATIONS
GLIB_AVAILABLE_IN_2_56 GLIB_AVAILABLE_IN_2_56
GDateTime * g_date_time_new_from_iso8601 (const gchar *text, GDateTime * g_date_time_new_from_iso8601 (const gchar *text,
@ -238,9 +240,11 @@ gdouble g_date_time_get_seconds (GDateTi
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
gint64 g_date_time_to_unix (GDateTime *datetime); gint64 g_date_time_to_unix (GDateTime *datetime);
GLIB_AVAILABLE_IN_ALL G_GNUC_BEGIN_IGNORE_DEPRECATIONS
GLIB_DEPRECATED_IN_2_62_FOR(g_date_time_to_unix)
gboolean g_date_time_to_timeval (GDateTime *datetime, gboolean g_date_time_to_timeval (GDateTime *datetime,
GTimeVal *tv); GTimeVal *tv);
G_GNUC_END_IGNORE_DEPRECATIONS
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
GTimeSpan g_date_time_get_utc_offset (GDateTime *datetime); GTimeSpan g_date_time_get_utc_offset (GDateTime *datetime);