• timezone issues analyzed

    By Jon A Christopher 1 decade ago

    I've found the source of the problems dealing with timezones and DST.



    In GooCalUtil.convXSToNotesDateTime, a string is parsed into components, one of which is the numeric timezone offset. In my case, this offset is GMT-5.00, corresponding to the Eastern time zone in the United states.



    The code



    String tzStr = org.substring(19, 22);

            if (tzStr.charAt(0)=='+') {<br/>
                tzStr = tzStr.substring(1, 3);<br/>
            }<br/>
    



    correctly identifies the tz offset as -05.



    However, the following code:


            int tzOffset = Integer.parseInt(tzStr) * 60 * 60 * 1000;<br/>
            TimeZone tz = TimeZone.getTimeZone(java.util.TimeZone.getAvailableIDs(tzOffset)[0]);<br/>
    





    does the wrong thing. java.util.TimeZone.getAvailableIDs returns a list of all timezone ids at -05. The first element of this list corresponds to the timezone "America/Atikokan", which is not currently using DST, while the correct Timezone id would correspond to "US/Eastern" or "America/New York" which is using DST.



    Depending on the order of timezone id entries in the list, this could produce calendar times for meetings scheduled in a different timezone which are off by 0, 1, or 2 hours.



    Therefore, one cannot simply use the first returned element of ava.util.TimeZone.getAvailableIDs to get a timezone id.

    Since lotus stores/returns a string which must be parsed as a string, and not a timezone id, I believe the only solution

    is to have a configuration file which GooCalSync will

    use to map from a numeric timezone offset to a timezone id.



    This file could be pre-configured for the timezone ids for the largest population centers, and users who are in an "unusual" timezone could edit it to match.



    For instance:



    -05 America/New York

    -06 America/Chicago

    -07 America/Denver

    -08 America/Los Angeles



    I suppose other solutions are possible, but the using the first returned id is just wrong.



    On the other hand, I suppose it's possible that lotus notes itself has a better idea of the exact timezone id, perhaps a better solution would be to modify



    GooCalUtil.convNotesDateTimeToXS to take care of dst, since the passed-in lotus.domino.DateTime function does have an isDST function which is probably more accurate than converting to a string and back to a date object.

    • By Dave Haughs 1 decade ago

      I went ahead and just hardcoded my timezone in there for the lookup. I replaced:



      TimeZone tz = TimeZone.getTimeZone(java.util.TimeZone.getAvailableIDs(tzOffset)[0]);



      with:



      TimeZone tz = TimeZone.getTimeZone("America/Indiana/Indianapolis");



      and it works fine.



      I like your idea of a configuration file, then the user has complete control over what time zone is used, or just pass it as a parameter in the batch file when starting the app.

    • By Karl Freburger 1 decade ago

      My company uses some custom templates, so I'm not sure is this information is true in all cases: on my meetings I see some properties that look very useful:



      Field Name: StartTimeZone

      Data Type: Text List

      Data Length: 54 bytes

      Seq Num: 2

      Dup Item ID: 0

      Field Flags: SUMMARY



      "Z=6$DO=1$DL=3 2 1 11 1 1$ZX=146$ZN=America/Chicago"



      Note that this meeting was scheduled from US Central Daylight Time. The StartTime property has the local start time in the TZ where the meeting was scheduled:



      Field Name: StartTime

      Data Type: Time/Date List or Range

      Data Length: 12 bytes

      Seq Num: 2

      Dup Item ID: 0

      Field Flags: SUMMARY



      10:00:00 AM



      I think that's enough information to figure out when the start time really is. I also see this property:



      Field Name: LocalTimeZone

      Data Type: Text List

      Data Length: 55 bytes

      Seq Num: 2

      Dup Item ID: 0

      Field Flags: SUMMARY NOUPDATE



      "Z=5$DO=1$DL=3 2 1 11 1 1$ZX=149$ZN=America/New_York"



      That corresponds to MY timezone (US Eastern Daylight Time). From those 3 properties you should be able to reliably and unambiguously determine what time should appear on my Calendar (in this example, 11 AM EDT)



      No time zone abbreviations are used, so there won't be any confusion. Maybe. Hope this helps…