diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2010-06-17 23:01:23 +0800 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2010-06-18 23:18:03 +0800 |
commit | 323e59fd738a061d741608f26e16d56fec1f4e09 (patch) | |
tree | 11ea180a9ae0ccd411d123be4a01ce7c311d1e2d /libempathy-gtk/empathy-log-window.c | |
parent | 824264d894e91c80cc03cd2ef837eb767d4e5242 (diff) | |
download | gsoc2013-empathy-323e59fd738a061d741608f26e16d56fec1f4e09.tar gsoc2013-empathy-323e59fd738a061d741608f26e16d56fec1f4e09.tar.gz gsoc2013-empathy-323e59fd738a061d741608f26e16d56fec1f4e09.tar.bz2 gsoc2013-empathy-323e59fd738a061d741608f26e16d56fec1f4e09.tar.lz gsoc2013-empathy-323e59fd738a061d741608f26e16d56fec1f4e09.tar.xz gsoc2013-empathy-323e59fd738a061d741608f26e16d56fec1f4e09.tar.zst gsoc2013-empathy-323e59fd738a061d741608f26e16d56fec1f4e09.zip |
don't use strptime
Diffstat (limited to 'libempathy-gtk/empathy-log-window.c')
-rw-r--r-- | libempathy-gtk/empathy-log-window.c | 27 |
1 files 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 <xclaesse@gmail.com> */ -#define _XOPEN_SOURCE /* glibc2 needs this for strptime */ - #include "config.h" #include <string.h> #include <stdlib.h> -#include <time.h> #include <glib/gi18n-lib.h> #include <gtk/gtk.h> @@ -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 */ |