Re: DT::Incomplete more methods

2003-11-04 Thread Flavio S. Glock
Joshua Hoblitt wrote:
 
$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?

spanset would be a separate method. Here is an example:

With 'year' -

  $dti = DateTime::Incomplete-new( year=2003, day=7 );

  start:  DateTime =  2003-01-07T00:00:00 

  end:DateTime =  2003-12-08T00:00:00 

  span:  DateTime::Span =
  [ 2003-01-07T00:00:00 , 2003-12-08T00:00:00 )

  spanset:  DateTime::SpanSet =
  [ 2003-01-07T00:00:00 , 2003-01-08T00:00:00 )
  [ 2003-02-07T00:00:00 , 2003-02-08T00:00:00 )
  [ 2003-03-07T00:00:00 , 2003-03-08T00:00:00 )
  ...
  [ 2003-12-07T00:00:00 , 2003-12-08T00:00:00 )

  recurrence:  DateTime::Set =
  2003-01-07T00:00:00 ,
  2003-01-07T00:00:01 ,
  2003-01-07T00:00:02 ,
  ...
  2003-01-07T23:59:59 ,
  2003-02-07T00:00:00 ,
  ...
  2003-12-07T23:59:59

Without 'year' -

  $dti = DateTime::Incomplete-new( day=7 );

  start:  undef 

  end:undef 

  span:   undef

  spanset:  DateTime::SpanSet =
  ...
  [ 2003-01-07T00:00:00 , 2003-01-08T00:00:00 )
  [ 2003-02-07T00:00:00 , 2003-02-08T00:00:00 )
  [ 2003-03-07T00:00:00 , 2003-03-08T00:00:00 )
  ...

  recurrence:  DateTime::Set =
  ...
  2003-01-07T00:00:00 ,
  2003-01-07T00:00:01 ,
  2003-01-07T00:00:02 ,
  ...
  2003-01-07T23:59:59 ,
  2003-02-07T00:00:00 ,
  ...


- Flavio S. Glock


Re: Re: Re: Strptime issues

2003-11-04 Thread rickmeasham
 [EMAIL PROTECTED] 
[EMAIL PROTECTED] wrote: 
 sub has_time { $_[0]-has{'hour', 'minute'} }   
 
Maybe should be: 
sub has_time {  
   return 1 if ($_[0]-has('hour', 'minute') and not 
$_[0]-has('nanosecond')); 
   return 1 if ($_[0]-has('hour', 'minute', 'second'))  
   return 0 
}   
Which only returns true if we have HH:MM or 
HH:MM:SS or HH:MM:SS.N+. The older version 
allowed us to get true for HH:MM:xx.N+ which is not 
really a time. 
 
Same caveat: 
Above code passes all tests on the perl installed in
my head. Havn't tried any of it with the much fussier  
software version.   
   
perl -v   
This is perl, v5.8.0 built for ricks-brain-1.0   
   
   
 


Re: Strptime issues

2003-11-04 Thread Flavio S. Glock
[EMAIL PROTECTED] wrote:
 
  Flavio S. Glock [EMAIL PROTECTED] wrote:
 
* keys or defined_fields
  returns the list of names of defined fields
 
 sub has {
# called with parameters you get true or false
# called with no params and you get a list of fields

I implemented this in CVS with tests, but I believe it 
should be 2 separate methods instead. What do you think?

* can_be_datetime / become_datetime
 
 sub can_be_datetime {
# -MM-DD
# -MM-DD HH:MM
# -MM-DD HH:MM:SS
# -MM-DD HH:MM:SS.N

I think any dti that has_year can become a datetime.
For example, DT::I-new( year=2003 )-become_datetime-datetime
  2003-01-01T00:00:00
Or perhaps, allow any dti without 'holes':
 
 -MM
 -MM-DD
 -MM-DD HH
 -MM-DD HH:MM
 -MM-DD HH:MM:SS
 -MM-DD HH:MM:SS.N
this excludes, for example:
 --DD

- Flavio S. Glock


Re: DT::Incomplete more methods

2003-11-04 Thread Joshua Hoblitt
On Tue, 4 Nov 2003, Flavio S. Glock wrote:

 Joshua Hoblitt wrote:
 
 $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?

 spanset would be a separate method. Here is an example:

Looks good.

-J

--