[tracker] libtracker-common: Fix localtime handling with historic UTC offsets
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] libtracker-common: Fix localtime handling with historic UTC offsets
- Date: Thu, 24 Mar 2011 14:57:37 +0000 (UTC)
commit 0e5ae8fa2636d3e33ef59258a7ff5fd7cdb820ba
Author: Jürg Billeter <j bitron ch>
Date: Thu Mar 24 15:55:07 2011 +0100
libtracker-common: Fix localtime handling with historic UTC offsets
src/libtracker-common/tracker-date-time.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/src/libtracker-common/tracker-date-time.c b/src/libtracker-common/tracker-date-time.c
index 46e05f2..49412c0 100644
--- a/src/libtracker-common/tracker-date-time.c
+++ b/src/libtracker-common/tracker-date-time.c
@@ -158,12 +158,21 @@ tracker_string_to_date (const gchar *date_string,
t -= offset;
}
} else {
+ time_t t2;
+
/* local time */
tm.tm_isdst = -1;
t = mktime (&tm);
+ /* calculate UTC offset, requires timegm for correct result
+ with past times when timezone had different UTC offset */
+#if !(defined(__FreeBSD__) || defined(__OpenBSD__) || defined (__GLIBC__))
offset = -timezone + (tm.tm_isdst > 0 ? 3600 : 0);
+#else
+ t2 = timegm (&tm);
+ offset = t2 - t;
+#endif
}
g_match_info_free (match_info);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]