From 323e59fd738a061d741608f26e16d56fec1f4e09 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Thu, 17 Jun 2010 17:01:23 +0200 Subject: don't use strptime --- libempathy-gtk/empathy-log-window.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/libempathy-gtk/empathy-log-window.c b/libempathy-gtk/empathy-log-window.c index 6315a3ea4..35b1ef52c 100644 --- a/libempathy-gtk/empathy-log-window.c +++ b/libempathy-gtk/empathy-log-window.c @@ -22,13 +22,10 @@ * Xavier Claessens */ -#define _XOPEN_SOURCE /* glibc2 needs this for strptime */ - #include "config.h" #include #include -#include #include #include @@ -417,28 +414,20 @@ got_messages_for_date_cb (GObject *manager, static GDate * gdate_from_str (const gchar *str) { - GDate *gdate; - struct tm tm; - time_t t; - gchar *tmp; + guint u; + guint day, month, year; - if (str == NULL) + if (sscanf (str, "%u", &u) != 1) return NULL; - memset (&tm, 0, sizeof (struct tm)); - - tmp = strptime (str, "%Y%m%d", &tm); - if (tmp == NULL || tmp[0] != '\0') - return NULL; + day = (u % 100); + month = ((u / 100) % 100); + year = (u / 10000); - t = mktime (&tm); - if (t == -1) + if (!g_date_valid_dmy (day, month, year)) return NULL; - gdate = g_date_new (); - g_date_set_time_t (gdate, t); - - return gdate; + return g_date_new_dmy (day, month, year); } #endif /* ENABLE_TPL */ -- cgit v1.2.3