On 29/01/2008, Danny Burkes <[EMAIL PROTECTED]> wrote: > Sorry, I left out a crucial piece of code :-) > > It throws PeriodNotFound, even if I pass the dst flag to > local_to_utc. Viz- > > My understanding from the docs is that, if I pass the dst flag to > local_to_utc, it should never throw the exception. Am I > misunderstanding?
Hi Danny, The dst flag is only used to resolve the ambiguity when an AmbiguousTime exception is raised. When transitioning from daylight savings time to standard time, there will be an hour in local time for which there are two equivalent UTC times. For example, suppose the transition from dst to standard time occurred at 2am local time. Local time would reach 01:59:59 and then go back to 01:00:00 again, causing the hour from 1am to 2pm would be repeated. The dst parameter allows you to select whether you want the UTC time corresponding with the dst local time (the first occurrence) or the standard local time (the second occurrence). A PeriodNotFound exception is raised in the opposite case, when transitioning from standard time to daylight savings time. In the case you are looking at, local time went from 23:59:59 to 01:00:00. The hour between midnight and 1am does not exist in local time. The dst flag has no affect on PeriodNotFound exceptions. To resolve this, you'll have to handle the error and then decide what is sensible for your application - e.g. manually adding an hour to the local time and then converting again. Regards, Phil -- Phil Ross http://tzinfo.rubyforge.org/ -- DST-aware timezone library for Ruby _______________________________________________ TZInfo-users mailing list [email protected] http://rubyforge.org/mailman/listinfo/tzinfo-users
