0 Replies Latest reply on Jun 26, 2010 8:08 PM by johnrellis

    Feature request: Time-zone offsets correctly reflecting DST

    johnrellis Most Valuable Participant

      LrDate doesn’t provide any way to format a date with a correct indicator of the local time zone (e.g. if in California, “-08:00” or “-07:00” depending on whether daylight savings time is in effect).


      For example, given a time representing 2009-09-27 14:28:03 PDT (Pacific Daylight Time, UTC-7), I’d like to produce an XMP-format date of the form:


      2009:09:27 14:28:03-07:00


      Similarly, given 2009-11-25 08:15:00 PST (Pacific Standard Time, UTC-8), I’d like to produce:


      2009:11:25 08:15:00-08:00


      (The XMP standard encourages the retention of time zones wherever possible.)


      The only conversion function that appears to pay attention to daylight savings time is LrDate.timeToUserFormat, but it doesn’t produce the necessary time zone offset. 


      An approximate workaround is to use LrDate.timeToUserFormat to get the date and time components from the timestamp.  Then use LrDate.timeFromComponents to convert the time 12:00:00 on that date back to a timestamp, first using time zone “local” and then using time zone 0.  The difference is the current time-zone offset in effect on that day.


      But that isn’t correct for times between 00:00 and 02:00 on the days in spring and fall that DST changes.  A completely correct implementation would subtract 24 hours from the time and see if DST is in effect on that day, and if it is, handle times between 00:00 and 2:00 specially.


      Suggestion: Enhance LrDate.timestampToComponents to pay attention to DST and return components that reflect whether DST is in effect, and to also return the time zone offset (also reflecting whether DST is in effect).