Strptime issues

2003-11-03 Thread Rick Measham
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?

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

But maybe that's just me.


My other option with Strptime are:

1. Always return an Incomplete object, but I doubt that's what people
would want/expect.

2. Always return an Incomplete unless we are given a base, in which case
the base fills in the blanks. This would mean if you have a full
datetime specifier in some format you still need to pass a DateTime into
the strptime object in order to receive a DateTime in return:

$strptime = new DateTime::Format::Strptime( base = DateTime-today,
pattern=$pattern );
$strptime-parse_datetime(Nov 3, 2003);
# Returns DateTime: 2003-11-03T00:00:00

$strptime = new DateTime::Format::Strptime( pattern=$pattern );
$strptime-parse_datetime(Nov 3, 2003);
# Returns DateTime::Incomplete: 2003-11-03Txx:xx:xx

3. Keep the current (shonky) behaviour


Cheers!
Rick







Re: Re: Strptime issues

2003-11-03 Thread rickmeasham
 David Hood [EMAIL PROTECTED] wrote: 
 Perhaps you should return only the information that 
is given, in an 
 iso 8601 
 compliant format, so for November 2003 you could 
simply return 
 2003-11. The 
 
Nah, that's not going to happen. The entire point of 
the module is to get a DateTime object. So it's either 
going to be a full DateTime or a 
DateTime::Incomplete. 
 
Also: What's the ISO format for 11pm November? 


Re: Strptime issues

2003-11-03 Thread Flavio S. Glock
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?
 
 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 think automatic conversion is not a good thing. I'm thinking about the
other alternatives...

The patches were applied - thanks.

- Flavio S. Glock


[OT] Anyone attending Comdex/Apachecon 2003?

2003-11-03 Thread Hill, Ronald
Hi All,

I was just wondering if anyone on the list is planning to attend
Comdex/Apachecon 2003?

Ron Hill


Re: DT::Incomplete and Perl 5.00503

2003-11-03 Thread Flavio S. Glock
Dave Rolsky wrote:
 
 On Mon, 3 Nov 2003, Flavio S. Glock wrote:
 
  I'm working on a fix.
 
 I just checked in a fix.

 Flavio S. Glock wrote:
 
 Fixed:

And I made yet another fix to make the CVS fix equal to the CPAN fix :)
I guess we are done with fixes today.

- Flavio S. Glock


Re: Strptime issues

2003-11-03 Thread Flavio S. Glock
Rick Measham wrote:
 
 If so, maybe a method inside Incomplete would be good:
if ($dti-can_be_datetime) {
   $dti-become_datetime
}

I've put this in the TODO.
So this is the current list of proposed DT::Incomplete methods that are
waiting for votes:

  * epoch
$epoch = $dti-epoch  if $dti-can_be_datetime;

  * has_date / has_time

  * keys or defined_fields
returns the list of names of defined fields

  * join( $dti )
join the defined keys of two DT::Incomplete objects

  * is_incomplete / is_complete

  * can_be_datetime / become_datetime

- Flavio S. Glock


Re: DT::Incomplete more methods

2003-11-03 Thread Joshua Hoblitt
   $span = $dti-span;

I really like the idea of being able to measure the uncertainty in an object.  What if 
the year and day are known but not the month?  Would a span set be returned?

-J

--