Dear experts,

a few days ago I have got great help from this list, so I hope I may ask
another (probably stupid) question (I am now having the opposite problem
than back then):

Using DateTime, is it possible to tell in advance if a certain date-time
which is given in a certain locale will be ambiguous due to switching
from DST to standard time?

Example (taken from DateTime's documentation):

  my $dt = DateTime->new(
      year      => 2003,
      month     => 10,
      day       => 26,
      hour      => 1,
      minute    => 30,
      second    => 0,
      time_zone => 'America/Chicago',
  );

Now $dt is ambiguous: The clock has been turned back to 01:00:00 h at
02:00:00 that night, so the time 01:30:00 h has occurred twice.

Even after thinking many hours about it, I haven't found a reasonable
general method to determine if an arbitrary date-time is ambiguous in
the sense above.

Possibly, I could subtract different time spans from the date-time in
question and check if the result is the expected one and use that to
find out if it is ambiguous, but this would cost much CPU time.

So I would like to ask if somebody knows a general, reasonable method
for solving that problem, given the following conditions:

1) We don't know the time span the clock is turned back when switching
from DST to standard time. It might be one hour in most time zones /
countries, but after all, some weird person could decide that it is 18
minutes and 13 seconds or 5 hours, 53 minutes and 42 seconds.

2) We don't know whether the point in time when the switch occurs is
exactly at an hour's end / begin. Again, some weird person could decide
that the switch happens at 08:48:27 am.

I know that there are not many persons on the world that are *that*
weird, but on the other hand, I don't want to implement an algorithm
which uses assumptions which are not safe.

As a last resort, there is at least one other module (AFAIK) which I
could use to extract the daylight saving switching times and time spans
from the time zone database, and I could use that information to solve
my problem. But this would probably mean to reinvent the wheel, so I'd
like to avoid it.

Thank you very much in advance,

Binarus

Reply via email to