Re: Today in Cairo Apr 25 2008

[email protected] ("Dr.Ruud")
Newsgroups perl.datetime
Organization Chaos rules.
Message-ID <[email protected]>
Max Campos schreef:

> It looks like Cairo changes its daylight savings at 11pm, causing
> truncate(to=> day) to fail on Apr 25, 2008. Is this by chance
> corrected in a newer version of DateTime?  I'm using v.30
>
> If not, then I guess this really opens up a can of worms as to what
> "today" should do on this date.
>
> use DateTime;
> $x = DateTime->new(year => 2008, month => 4, day => 25, hour => 12,
> minute => 12);
> $x->set_time_zone('Africa/Cairo');
> $x->truncate(to => 'day');
> print "$x\n";
> -------------
> Invalid local time for date in time zone: Africa/Cairo

Maybe add a "safe => 1" (with new, add, subtract) such that the
following
don't die() anymore:

perl -MData::Dumper -MDateTime -e'
     $dt = DateTime->new( safe =>1,
         year => 2008, month => 3, day => 25, time_zone =>
"Africa/Cairo",
     )->add(months => 1);
     print Dumper($dt)
' |less

perl -MData::Dumper -MDateTime -e'
     $dt = DateTime->new( safe => 1,
         year => 2008, month => 4, day => 26, time_zone =>
"Africa/Cairo",
     )->subtract(days => 1);
     print Dumper($dt)
' |less

perl -MData::Dumper -MDateTime -e'
     $dt = DateTime->new( safe => 1,
         year => 2008, month => 4, day => 25, time_zone =>
"Africa/Cairo",
     );
     print Dumper($dt)
' |less

They should all return "2008-04-25 01:00:00" I suppose.

Somewhat related: Maybe also add a newdate() that carries no time
information.

-- 
Affijn, Ruud

"Gewoon is een tijger."
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.