in reply to Re^3: Converting local time to utc time
in thread Converting local time to utc time

From the DateTime docs
Ambiguous Local Times

Because of Daylight Saving Time, it is possible to specify a local time that is ambiguous. For example, in the US in 2003, the transition from to saving to standard time occurred on October 26, at 02:00:00 local time. The local clock changed from 01:59:59 (saving time) to 01:00:00 (standard time). This means that the hour from 01:00:00 through 01:59:59 actually occurs twice, though the UTC time continues to move forward. If you specify an ambiguous time, then the latest UTC time is always used, in effect always choosing standard time.
poj
  • Comment on Re^4: Converting local time to utc time

Replies are listed 'Best First'.
Re^5: Converting local time to utc time
by ureco (Acolyte) on Nov 11, 2014 at 21:47 UTC
    Didn't fully understand that paragraph when I first read it! Given that I cannot change the source local datetime - is there anyway I can convert these ambiguous date times into UTC?

    Kind of feel I'm back to my original question... given a local date time for the entire year incrementing by 1 minute each time how can I convert this local time into UTC time and get correct results, even during the ambiguous date time period when the local date time changes from Daylight Saving Time and back again?

      The problem is: if you have a timestamp of "2003-10-26 01:17:47 Local Time", you actually have incomplete information. Only if you can distinguish(*) between "Local Time (Summer)" and "Local Time (Winter)", you have a chance to getting the right results here.

      Does your CSV source contain that info?

      Otherwise it will become guesswork, e.g. you could assume that the transition between summer and "normal" time (as I like to call it) is marked by a record with a time stamp earlier than its predecessor.

      (*) ... and can give this bit to the converting (sub)routine
        I might need to code round this with the information I have. I only have a date/time (per minute) and a series of associated weather parameters, temp, wind etc.

        These records come in sequence, as the local time changes, going from BST to GMT(UTC) or back the local time either repeats an hour or misses an hour. If I can detect this change (i.e. work out the day the clocks change) then I can probably build in the correct (duplicate/missing) times. The clock change always occurs during a given hour on variable days - it's always GMT/BST times in the source data.

        I was hoping that this module would do this for me, but if not then I'll need to go away and think about how to build a solution. But, will need to think how I'm going to do it!