[libgsf] time stamp: fix parsing bug.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgsf] time stamp: fix parsing bug.
- Date: Tue, 20 Mar 2012 13:09:25 +0000 (UTC)
commit b97048b0f8d34fbf105aa712137a9f903716a9f6
Author: Morten Welinder <terra gnome org>
Date: Tue Mar 20 09:07:09 2012 -0400
time stamp: fix parsing bug.
ChangeLog | 5 +++++
NEWS | 3 +++
gsf/gsf-timestamp.c | 30 +++++++++++-------------------
3 files changed, 19 insertions(+), 19 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index daff4b9..e3ac725 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-03-20 Morten Welinder <terra gnome org>
+
+ * gsf/gsf-timestamp.c (gsf_timestamp_from_string): Reimplement
+ based on glib's GDateTime. Fixes time-shift part of #671860.
+
2012-03-10 Jean Brefort <jean brefort normalesup org>
* gsf/Makefile.am: make introspection work when libgsf is not installed.
diff --git a/NEWS b/NEWS
index 0d5ed51..74f2c27 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,9 @@ Antoine Jacoutot:
Jean Brefort:
* Make introspection work when libgsf is not installed. [#671698]
+Morten:
+ * Fix time stamp drift problem. [Part of #671860]
+
--------------------------------------------------------------------------
libgsf 1.14.22
diff --git a/gsf/gsf-timestamp.c b/gsf/gsf-timestamp.c
index 91e9e4e..1850387 100644
--- a/gsf/gsf-timestamp.c
+++ b/gsf/gsf-timestamp.c
@@ -134,30 +134,22 @@ static time_t gmt_to_local_win32(void)
int
gsf_timestamp_from_string (char const *spec, GsfTimestamp *stamp)
{
- struct tm tm;
-
- memset (&tm, 0, sizeof (struct tm));
+ int year, month, day, hour, minute, second;
+ GDateTime *dt;
/* 'YYYY-MM-DDThh:mm:ss' */
- if (6 == sscanf (spec, "%d-%d-%dT%d:%d:%d",
- &tm.tm_year, &tm.tm_mon, &tm.tm_mday,
- &tm.tm_hour, &tm.tm_min, &tm.tm_sec)) {
- time_t t;
-
- tm.tm_mon--; /* 0..11 */
+ if (6 != sscanf (spec, "%d-%d-%dT%d:%d:%d",
+ &year, &month, &day, &hour, &minute, &second))
+ return FALSE;
- /* err on the side of avoiding negatives */
- if (tm.tm_year >= 1900)
- tm.tm_year -= 1900;
+ dt = g_date_time_new_utc (year, month, day, hour, minute, second);
+ if (!dt)
+ return FALSE;
- t = mktime (&tm);
- if (t == -1)
- return FALSE;
+ stamp->timet = g_date_time_to_unix (dt);
- stamp->timet = t + GMTOFF(tm);
- return TRUE;
- }
- return FALSE;
+ g_date_time_unref (dt);
+ return TRUE;
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]