On Tue, 31 Aug 2004, Rick Measham wrote:

> At 9:33 am -0700 2004-08-30, Jonathan Leffler wrote:
> >Dear Rick,
> >
> >I just tried to install DateTime::Format::Strptime 1.06 (with Perl 5.8.5
> >on Sun Solaris 8 - not that I think that is relevant).  I get a test
> >failure on test 85 of t/006_locales.t...
> --snip--
> >It looks like the test is trying to use February 30th.  My impression is
> >that the problem is in the test, not the module being tested.
> --snip--
> >-       my $dt = DateTime->now( locale => $locale )->set( month => $month );
> >+       my $dt = DateTime->now( locale => $locale )->set( month =>
> >$month, day => 23 );
>
> Dave, this looks more like an error in DateTime ... shouldn't setting
> the month work like adding a month and have it roll over ... or
> better shouldn't it truncate it to the month length?
>
> It's easy for me to get rid of the error in the test, but my thought
> is that the error shouldn't occur.

I think throwing an error is the best thing here.  It's really hard for me
to do something "reasonable" (as in obvious to most people) when you try
to convert the date to Feb 30.  You came up with two reasonable
suggestions all by yourself ;)

And really, I think that this code is indicative of a logical error in
the caller's code, or bad user input being passed through, and throwing an
error makes it obvious this happened.  Truncating or rolling-over will
simply mask the error, which will translate into corrupt data somewhere
down the line.


-dave

/*=======================
House Absolute Consulting
www.houseabsolute.com
=======================*/

Reply via email to