aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-06-17 23:01:23 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-06-18 23:18:03 +0800
commit323e59fd738a061d741608f26e16d56fec1f4e09 (patch)
tree11ea180a9ae0ccd411d123be4a01ce7c311d1e2d
parent824264d894e91c80cc03cd2ef837eb767d4e5242 (diff)
downloadgsoc2013-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
-rw-r--r--libempathy-gtk/empathy-log-window.c27
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 */