On Tue, 16 Aug 2005, Eugene van der Pijll wrote:

Dave Rolsky schreef:
But in fact, one hour less than 6 months has passed because of the DST
change

I think this is a very strange thing to say, as the duration "6 months"
is never a fixed amount of hours, not even in UTC.

The difference is compared to adding 6 months to the local time, which would end up adding 6 months and 1 hour to the UTC time.

In this case, we added 6 months to the _UTC_ time and the displayed clock
time changes, due to DST.  This is also a reasonable result, since it
reflects the actual amount of time that has passed.

I don't think it is reasonable, and I can't remember anyone complaining
about this. Can you give a reference? [*]

There have been several reports, they're in the list archives. One was from Mike Schilli. Then another more recent one complained about the change I made based on Mike's bug report. Can't win ;)

I think we need to have dual sets of methods, one for local and one for
UTC:

I don't like it. The proper solution IMHO would be to do the calculation
in utc, if that is what you want:

   $localzone = $dt1->time_zone;
   $dt1 = $dt1->set_timezone('utc')
              ->add_duration(months => 6)
              ->set_timezone($localzone);

It's not a common problem, as far as I can see, at least not for people
who work with "local" times. They (almost?) never want to account for
leap hours when subtracting datetimes in July and December, for
instance.

That's true, but it's a bit cumbersome. At the very least, offering some sort of convenience method for the above would be nice.

1 day is just not always the same as 24 hours, in timezones with DST.
That's how DateTime has always worked; that is how it should work.

Actually, DateTime was doing some really weird stuff for a long time, mixing local and UTC times in the date math. Then I "fixed" it to just use UTC everywhere, which while accurate tends to lead to confusion. Using local everywhere would probably be better for most folks.


-dave

/*===================================================
VegGuide.Org                        www.BookIRead.com
Your guide to all that's veg.       My book blog
===================================================*/

Reply via email to