From c4bad4185583facbec1957e505a52ee05dd8d09a Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 28 Jan 2008 06:27:28 +0000 Subject: [PATCH] Check for gmtime_r. Use gmtime_r when available. (#511807, Sebastian MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2008-01-28 Matthias Clasen * configure.in: Check for gmtime_r. * glib/gtimer.c: Use gmtime_r when available. (#511807, Sebastian Dröge) svn path=/trunk/; revision=6393 --- ChangeLog | 6 ++++++ glib/gtimer.c | 14 +++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5483e3905..9a88f8f1e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-01-28 Matthias Clasen + + * configure.in: Check for gmtime_r. + * glib/gtimer.c: Use gmtime_r when available. (#511807, + Sebastian Dröge) + 2008-01-27 Matthias Clasen * glib/gnode.[hc]: Move docs inline. (#316260, Philippe Blain) diff --git a/glib/gtimer.c b/glib/gtimer.c index b625ddb54..a29e39dd2 100644 --- a/glib/gtimer.c +++ b/glib/gtimer.c @@ -402,16 +402,24 @@ gchar * g_time_val_to_iso8601 (GTimeVal *time_) { gchar *retval; - +#ifdef HAVE_GMTIME_R + struct tm tm_; +#endif + g_return_val_if_fail (time_->tv_usec >= 0 && time_->tv_usec < G_USEC_PER_SEC, NULL); #define ISO_8601_LEN 21 #define ISO_8601_FORMAT "%Y-%m-%dT%H:%M:%SZ" retval = g_new0 (gchar, ISO_8601_LEN + 1); - + strftime (retval, ISO_8601_LEN, ISO_8601_FORMAT, - gmtime (&(time_->tv_sec))); +#ifdef HAVE_GMTIME_R + gmtime_r (&(time_->tv_sec), &tm_) +#else + gmtime (&(time_->tv_sec)) +#endif + ); return retval; }