On Monday, March 10, 2003, at 04:26 PM, Dave Rolsky wrote:
 my $dt = DateTime->new( year => 2003, month => 4, day => 5,
                         hour => 2, time_zone => 'America/Chicago',

$dt->add( days => 1 );

then the code will throw an exception, because there is no local 2:00 AM
on 2003-04-06 in the America/Chicago time zone.


Is that acceptable?  I can't think of any good solutions to this, other
than documenting it.

This is the same situation as: my $dt = DateTime->new( year => 2003, month => 4, day => 6, hour => 1, minute => 59, seconds => 59, time_zone => 'America/Chicago');

$dt->add( seconds => 1 )

Upon catching that exception, I think I would always do a "carryover" operation, so the result in both cases would be 2003-04-06T03:00:00 w/ DST flag set.

So to protect my processes that scan across arbitrary periods at arbitrary levels of resolution (truncation), I will always have to be vigilant for an exception thrown by seemingly innocent math. Kinda like encountering (mathematically) imaginary numbers when balancing my checkbook... ;-)

The rule for the end of DST, as you mentioned,
  >"First" wins, where first is defined as "earliest UTC datetime".
has withstood every test I've thrown at it.

I guess you're assuming that 03:00:00 wouldn't *always* be the expected result (at local start of DST)?

- Bruce

__bruce__van_allen__santa_cruz__ca__



Reply via email to