When finding a non-UTC timestamp with no time
authorArt Cancro <ajc@citadel.org>
Thu, 13 Jul 2006 03:22:51 +0000 (03:22 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 13 Jul 2006 03:22:51 +0000 (03:22 +0000)
zone specified, convert from the local timezone to UTC.  Currently
it is hardcoded for the America/New_York timezone, but we will fix
that.

citadel/ical_dezonify.c

index 318a2ef631d5c2d7d4356755e823e8c5be51da83..06fdb19a14918c97f94065cccf6371268bd217c5 100644 (file)
 #include <ical.h>
 #include "ical_dezonify.h"
 
+icaltimezone *get_default_icaltimezone(void) {
+
+        char *location = NULL;
+        icaltimezone *zone = NULL;
+
+        location = "America/New_York";
+        if (location) {
+                zone = icaltimezone_get_builtin_timezone (location);
+        }
+        if (!zone)
+                zone = icaltimezone_get_utc_timezone ();
+
+        return zone;
+}
+
 
 /*
  * Back end function for ical_dezonify()
@@ -90,11 +105,15 @@ void ical_dezonify_backend(icalcomponent *cal,
                                                t,
                                                icaltimezone_get_utc_timezone()
                        );
-                       TheTime.is_utc = 1;
                }
                else {
-                       lprintf(CTDL_DEBUG, "                * Not UTC but no tzid found; WTF??\n");
+                       lprintf(CTDL_DEBUG, "                * Converting default timezone to UTC.\n");
+                       icaltimezone_convert_time(&TheTime,
+                                               get_default_icaltimezone(),
+                                               icaltimezone_get_utc_timezone()
+                       );
                }
+               TheTime.is_utc = 1;
        }
        icalproperty_remove_parameter_by_kind(prop, ICAL_TZID_PARAMETER);