Re: definition of correctness

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

>> Probably because the start point of your POSIX calculations are at
>> 00:00, and those of your DateTime-calculations are at 02:00?
>
> That still does not make sense, 00:00 + 26 hrs is same as 00:00 + 27
> hours ? because thats what POSIX::mktime tells me.


Your DateTime-calls have "day => 4" where you need "day => 5".


The point in time 2008-10-05T02:00:00 doesn't exist there, so you can
not set up an object with it.

$ perl -MDateTime -le '
  print DateTime->new(
    year => 2008, month => 10, day => 5,
    hour => 2,
    time_zone => "Australia/Melbourne",
  )
'
Invalid local time for date in time zone: Australia/Melbourne



I got used to set up your objects at noon, and subtract 12 hours to get
to midnight, etc.

$ perl -MDateTime -le '
  print DateTime->new(
    year => 2008, month => 10, day => 5,
    hour => 12,
    time_zone => "Australia/Melbourne",
  )->add( hours => -12+2+24, )
'
2008-10-06T02:00:00


$ perl -MDateTime -le '
  print DateTime->new(
    year => 2008, month => 10, day => 5,
    hour => 12,
    time_zone => "Australia/Melbourne",
  )->add( hours => -12+2+25, )
'
2008-10-06T03:00:00


$ perl -MDateTime -le '
  print DateTime->new(
    year => 2008, month => 10, day => 5,
    hour => 12,
    time_zone => "Australia/Melbourne",
  )->add( hours => -12+2+48, )
'
2008-10-07T02:00:00


Don't think you can use 00:00 as a safe point in time to set up an
object.
(There are timezones that switch DST at midnight, so some midnights
don't exist.)

-- 
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.