[tracker] libtracker-common: Fix handling of UTC offsets with minutes



commit f3b929e4580912e010deb4a88affeaf22f34eebc
Author: Jürg Billeter <j bitron ch>
Date:   Wed Feb 24 10:33:55 2010 +0100

    libtracker-common: Fix handling of UTC offsets with minutes
    
    Fixes NB#157899.

 src/libtracker-common/tracker-date-time.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/src/libtracker-common/tracker-date-time.c b/src/libtracker-common/tracker-date-time.c
index cdd5494..6e1bc6f 100644
--- a/src/libtracker-common/tracker-date-time.c
+++ b/src/libtracker-common/tracker-date-time.c
@@ -58,7 +58,7 @@ tracker_string_to_date (const gchar *date_string,
 
 	if (!regex) {
 		GError *e = NULL;
-		regex = g_regex_new ("^(-?[0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])T([0-9][0-9]):([0-9][0-9]):([0-9][0-9])(\\.[0-9]+)?(Z|((\\+|-)[0-9][0-9]):?([0-9][0-9]))?$", 0, 0, &e);
+		regex = g_regex_new ("^(-?[0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])T([0-9][0-9]):([0-9][0-9]):([0-9][0-9])(\\.[0-9]+)?(Z|(\\+|-)([0-9][0-9]):?([0-9][0-9]))?$", 0, 0, &e);
 		if (e) {
 			g_error ("%s", e->message);
 		}
@@ -119,13 +119,24 @@ tracker_string_to_date (const gchar *date_string,
 		match = g_match_info_fetch (match_info, 9);
 		if (match) {
 			/* non-UTC timezone */
-			offset = atoi (match) * 3600;
+
+			gboolean positive_offset;
+
+			positive_offset = (match[0] == '+');
 			g_free (match);
 
 			match = g_match_info_fetch (match_info, 10);
+			offset = atoi (match) * 3600;
+			g_free (match);
+
+			match = g_match_info_fetch (match_info, 11);
 			offset += atoi (match) * 60;
 			g_free (match);
 
+			if (!positive_offset) {
+				offset = -offset;
+			}
+
 			if (offset < -14 * 3600 || offset > 14 * 3600) {
 				g_set_error (error, TRACKER_DATE_ERROR, TRACKER_DATE_ERROR_OFFSET,
 				             "UTC offset too large: %d seconds", offset);



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