[tracker] Fixes GB#579062, mktime() related error



commit 6261172880a12fe2a66117f17bd02687c216af56
Author: Martyn Russell <martyn lanedo com>
Date:   Tue Mar 16 17:26:27 2010 +0000

    Fixes GB#579062, mktime() related error

 src/libtracker-common/tracker-date-time.c         |   15 ++++++++++++---
 tests/libtracker-common/tracker-type-utils-test.c |    4 ++++
 2 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/src/libtracker-common/tracker-date-time.c b/src/libtracker-common/tracker-date-time.c
index 6e1bc6f..4d2b202 100644
--- a/src/libtracker-common/tracker-date-time.c
+++ b/src/libtracker-common/tracker-date-time.c
@@ -111,8 +111,12 @@ tracker_string_to_date (const gchar *date_string,
 		/* mktime() always assumes that "tm" is in locale time but we
 		 * want to keep control on time, so we go to UTC
 		 */
-		t  = mktime (&tm);
-		t -= timezone;
+#if !(defined(__FreeBSD__) || defined(__OpenBSD__))
+                t  = mktime (&tm);
+                t -= timezone;
+#else
+                t = timegm (&tm);
+#endif
 
 		offset = 0;
 
@@ -149,7 +153,12 @@ tracker_string_to_date (const gchar *date_string,
 	} else {
 		/* local time */
 		tm.tm_isdst = -1;
-		t = mktime (&tm);
+
+#if !(defined(__FreeBSD__) || defined(__OpenBSD__))
+                t = mktime (&tm);
+#else
+                t = timegm (&tm);
+#endif
 
 		offset = -timezone + (tm.tm_isdst > 0 ? 3600 : 0);
 	}
diff --git a/tests/libtracker-common/tracker-type-utils-test.c b/tests/libtracker-common/tracker-type-utils-test.c
index ed1cd1b..f143e89 100644
--- a/tests/libtracker-common/tracker-type-utils-test.c
+++ b/tests/libtracker-common/tracker-type-utils-test.c
@@ -102,7 +102,11 @@ test_date_to_string (void)
 	original->tm_year = 108;
 	original->tm_isdst = 0;
 
+#if !(defined(__FreeBSD__) || defined(__OpenBSD__))
 	input = mktime (original) - timezone;
+#else
+	input = timegm (original);
+#endif
 
 	result = tracker_date_to_string (input);
 



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