aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk/empathy-log-window.c
diff options
context:
space:
mode:
Diffstat (limited to 'libempathy-gtk/empathy-log-window.c')
-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 */