[empathy] don't use strptime



commit 323e59fd738a061d741608f26e16d56fec1f4e09
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Thu Jun 17 17:01:23 2010 +0200

    don't use strptime

 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 6315a3e..35b1ef5 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 */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]