summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-06-04 14:28:38 +0200
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-06-04 14:28:38 +0200
commit6470e96a60d8132cd4a03c897e7ff02540e8f6ad (patch)
treebcb0915a8b0c1711e8e03f6d364d7891945c3060
parent13c65417bb3cd8ff3ebcc61d60e0ce7a196b45f0 (diff)
don't use strptime, it's not portable
-rw-r--r--telepathy-logger/log-store-xml.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/telepathy-logger/log-store-xml.c b/telepathy-logger/log-store-xml.c
index f9dc79534..bb748b6fa 100644
--- a/telepathy-logger/log-store-xml.c
+++ b/telepathy-logger/log-store-xml.c
@@ -23,15 +23,12 @@
* Cosimo Alfarano <cosimo.alfarano@collabora.co.uk>
*/
-#define _XOPEN_SOURCE /* glibc2 needs this for strptime */
-
#include "config.h"
#include "log-store-xml-internal.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
-#include <time.h>
#include <glib/gstdio.h>
#include <glib-object.h>
@@ -602,22 +599,20 @@ static GDate *
create_date_from_string (const gchar *str)
{
GDate *date;
- struct tm tm;
- time_t t;
- gchar *tmp;
+ guint u;
+ guint day, month, year;
- memset (&tm, 0, sizeof (struct tm));
-
- tmp = strptime (str, "%Y%m%d", &tm);
- if (tmp == NULL || tmp[0] != '\0')
+ if (sscanf (str, "%u", &u) != 1)
return NULL;
- t = mktime (&tm);
- if (t == -1)
+ day = (u % 100);
+ month = ((u / 100) % 100);
+ year = (u / 10000);
+
+ if (!g_date_valid_dmy (day, month, year))
return NULL;
- date = g_date_new ();
- g_date_set_time_t (date, t);
+ date = g_date_new_dmy (day, month, year);
return date;
}