in reply to Re: Converting local time to utc time
in thread Converting local time to utc time
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Converting local time to utc time
by wjw (Priest) on Nov 10, 2014 at 22:58 UTC | |
In my experience, BotFx gave you the best method. I would seriously consider figuring out what the problem is with installing modules and then move forward with his advice. Dates and Times are a non-trivial PITA. The available modules for Perl are well worth the time to figure out how to get them to you machine. ...the majority is always wrong, and always the last to know about it... Insanity: Doing the same thing over and over again and expecting different results... A solution is nothing more than a clearly stated problem...otherwise, the problem is not a problem, it is simply an inconvenient fact | [reply] |
|
Re^3: Converting local time to utc time
by ureco (Acolyte) on Nov 11, 2014 at 20:43 UTC | |
I've added the following code: The following is output: LOCAL | UTC 2014/10/26 00:59 | 2014/10/25 23:59 <- Correct 2014/10/26 01:00 | 2014/10/26 01:00 <- Incorrect, should be 00:00 UTC is also actually repeating 01:00 - 01:59 so after the Daylight Saving Change it is correct again it's just the transition it appears to go wrong. The UTC datetime is still being moved on by 1hr - this should stay the same enabling the Local time to catch-up. Have I coded this correctly? Really appreciate your help on this - Thanks. | [reply] [d/l] |
by poj (Abbot) on Nov 11, 2014 at 21:24 UTC | |
Ambiguous Local Timespoj | [reply] |
by ureco (Acolyte) on Nov 11, 2014 at 21:47 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? | [reply] |
by soonix (Chancellor) on Nov 12, 2014 at 08:23 UTC | |
by ureco (Acolyte) on Nov 12, 2014 at 15:43 UTC | |
| |
by ureco (Acolyte) on Nov 13, 2014 at 23:44 UTC | |
For each local time I could obtain from the DateTime module whether it was DST or not ('0' / '1') indicator. By storing the previous value I could determine whether the dates being processed where changing from DST to GMT/UTC - value of "10" when combining the previous and current values. When this occurred I set up a counter to subtract 1 hour from the UTC time for the next hour. This correctly ensured that the UTC time continue without jumping forward and missing the 00:00 - 00:59 period. When I ran March data (GMT/UTC to DST) I discovered I did not have a problem during this calculation because the local time move forward an hour it never contains data that will cause the Date Time module to return an error due to an invalid date time - i.e. a time in the missing hour. Code below, (part off as a bit long after I added all my weather parameters) as I said probably not the most efficient or well written Perl code (still new to Perl) but it does what I need it to do... Thanks for all your guidance and pointers, much appreciated.
| [reply] [d/l] |