Rick Measham wrote:
> 
> I'm adapting Strptime to return DateTime::Incomplete objects when it
> gets an incomplete datetime. The old behaviour was to return the lowest
> possible value.
> 
> eg. 'November 2003' used to return 2003-11-01T00:00:00, but will now
> return 2003-11-xxTxx:xx:xx
> 
> I'm currently checking to see if a datetime is possible and only
> returning incomplete if not. Is that a good idea?

How about it to be an option in the Strptime constructor?

  my $Strp = new DateTime::Format::Strptime(
                 pattern     => '%T',
                 locale      => 'en_AU',
                 time_zone   => 'Melbourne/Australia',
                 incomplete  => 'never' | 'always' | 'maybe'
             );

> If so, maybe a method inside Incomplete would be good:
>    if ($dti->can_be_datetime) {
>       $dti->become_datetime
>    }
> or else an incomplete could automatically convert itself to a DateTime
> once it had enough information?!?!?
> 
> I figure an Incomplete can become a DateTime if:
> 
> We have a Year, Month and Day, but no time (becomes 00:00:00) -or-
> We have a Year, Month, Day, Hour and Minute -or-
> We have a Year, Month, Day, Hour, Minute and Second -or-
> We have a Year, Month, Day, Hour, Minute, Second and Nanosecond

That's ok to me. Do you already have code to do this?

> 3. Keep the current (shonky) behaviour

That's not too bad, except that DT::Incomplete is a bit slower than
DateTime.

- Flavio S. Glock

Reply via email to