Doesn't convert the time zone

Jan 6, 2010 at 7:23 PM

Hi,

I've tried importing an event, and it did, but the time was left as GMT instead of what's configured in my account (PST)

I'm curious if I'm the only one that was affected?

Thanks

Jan 26, 2010 at 9:03 PM

I had a similar problem importing event from the german railway that used the follwing format for

DTSTART;TZID=Europe/Berlin:20100103T180100
DTEND;TZID=Europe/Berlin:20100103T182300

I haven really patched the TimeZone issue, as I'm not querying google calendar for the timezone
setting, but maybe it's useful for you.

 Axel

-------------------

Index: svn/GCalICSImporter/IcsEvent.cs
===================================================================
--- svn/GCalICSImporter/IcsEvent.cs    (revision 41772)
+++ svn/GCalICSImporter/IcsEvent.cs    (working copy)
@@ -39,13 +39,31 @@
             Alarms.Add(al);
             return al;
         }
+        
+        private DateTime getDateTime(string lineValue, string[] lineHeaderParts){
+            if (lineValue.EndsWith("Z"))
+                // UTC time -> Tailing Z
+                return DateTime.ParseExact(lineValue, "yyyyMMdd'T'HHmmss'Z'", CultureInfo.InvariantCulture);
+            else
+                // local time
+                return DateTime.ParseExact(lineValue, "yyyyMMdd'T'HHmmss", CultureInfo.InvariantCulture);
 
+        }
+
         private void ParseIcsLine(string icsLine)
         {
             var lineParts = icsLine.Split(":".ToCharArray());
             if (lineParts.Length < 2) return;
             string lineHeader = lineParts[0].ToUpper();
-            string lineValue = string.Empty;
+            
+            // START check if additional ";" are present
+            var lineHeaderParts = lineHeader.Split(";".ToCharArray());
+            if (lineHeaderParts.Length > 1) {
+                lineHeader = lineHeaderParts[0].ToUpper();
+            }
+            // END check if additional ";" are present
+
+            string lineValue = string.Empty;
             for (int i = 1; i < lineParts.Length; i++)
             {
                 lineValue += lineParts[i];
@@ -62,17 +80,17 @@
                     }
                 case IcsStrings.IcsEventDtStartHeader:
                     {
-                        DtStart = DateTime.ParseExact(lineValue, "yyyyMMdd'T'HHmmss'Z'", CultureInfo.InvariantCulture);
-                        break;
+                        DtStart = getDateTime(lineValue, lineHeaderParts);
+                           break;
                     }
                 case IcsStrings.IcsEventDtEndHeader:
                     {
-                        DtEnd = DateTime.ParseExact(lineValue, "yyyyMMdd'T'HHmmss'Z'", CultureInfo.InvariantCulture);
+                        DtEnd  = getDateTime(lineValue, lineHeaderParts);
                         break;
                     }
                 case IcsStrings.IcsEventDtStampHeader:
                     {
-                        DtStamp = DateTime.ParseExact(lineValue, "yyyyMMdd'T'HHmmss'Z'", CultureInfo.InvariantCulture);
+                        DtStamp  = getDateTime(lineValue, lineHeaderParts);
                         break;
                     }
                 case IcsStrings.IcsEventSummaryHeader:
@@ -82,7 +100,7 @@
                     }
                 case IcsStrings.IcsEventDescriptionHeader:
                     {
-                        Description = lineValue;
+                        Description = lineValue.Replace("\\n","\n");
                         break;
                     }
                 case IcsStrings.IcsEventPriorityHeader:

------------------

Nov 29, 2010 at 5:51 AM

I am having the same time zone problem, we are in GMT+10, and the ICS file is generated automatically by a diary program and saves fine if saved straight into Outlook, but when saved using this code into Google Calendar, it comes up as the corresponding times in GMT = 10 hours earlier than it should be (I set a diary event for 16:00 it comes up in Google at 06:00). I don't know if this is a fault of the system generating the ICS files or if I need to change something to manipulate the ICS file before it is uploaded. Can anyone give me some guidance please?

May 9, 2012 at 6:10 PM

I just downloaded the app today, May 9 2012, and the timezone bug still exists.

im -4, halifax canada. but its puts the appointments 4 hrs late in my calender.

Also, no title appears.