On Mon, 5 Sep 2005, Joshua Hoblitt wrote:

On Mon, Sep 05, 2005 at 11:49:33PM -0500, Dave Rolsky wrote:
  my $dt = DateTime->new( year => 2003, month => 9, time_zone =>
  'America/Chicago' );
  $dt->add( months => 3 );

Now what do you expect that to produce?  I suspect 99% of users expect
that to produce "2003-12-01T00:00:00".  In other words, we take month 9,
add 3, and get 12.  The time remains untouched.

But if add_duration did the math on the UTC portions it'd give you
"2003-11-30T23:00:00".

If I understand you correctly, your position is that user's will be
confused by DST transitions screwing up additions but won't notice the
same effect on subtractions?

No, they'll notice, but the workarounds for subtractions are well-documented.

Anyway, your position seemed to be that they won't notice for either, and that both should be weird ;)

The more I think about this the more I'm convinced that the idea of datetime subtraction producing something other than seconds is a convenient fiction. Similarly, date subtraction producing something other than a count of days is full of potential bugs.

I'm thinking of addind a new section to the FAQ about all this after 0.30 is out.


-dave

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

Reply via email to