Re: Strptime issues

2003-11-06 Thread Flavio S. Glock
Rick Measham wrote:
 
if ($dti-can_be_datetime) {
   $dti-become_datetime
}

implemented as:

   if ($dti-can_be_datetime) {
  $dti = $dti-become_datetime
   }

because changing the class of '$dti' is a bit hard.


How about to extend the 'to_datetime' method, instead of creating a new
one:

   if ($dti-can_be_datetime) {
  $dti = $dti-to_datetime
   }


- Flavio S. Glock


Re: Re: Strptime issues

2003-11-06 Thread rickmeasham
 Flavio S. Glock [EMAIL PROTECTED] wrote: 
  
 How about to extend the 'to_datetime' method, 
instead of creating a 
 new 
 one: 
  
if ($dti-can_be_datetime) { 
   $dti = $dti-to_datetime 
} 
  
 
Sounds good .. and it's as simple as using 
DateTime-today as the base, which may well be a 
good default behaviour for -to_datetime when no 
base is in the object or none is passed in the call. 
 
Cheers! 
Rick 


Re: Strptime issues

2003-11-06 Thread Flavio S. Glock
[EMAIL PROTECTED] wrote:
 
 Sounds good .. and it's as simple as using
 DateTime-today as the base, which may well be a
 good default behaviour for -to_datetime when no
 base is in the object or none is passed in the call.

So this is what we've got so far:

0.0102  2003-11-06
- to_datetime() uses today as a base date, if none was given.
  The following methods are affected by this change:
  epoch, hires_epoch, is_dst, utc_rd_values, utc_rd_as_seconds,
sprintf(%s)
- can_be_datetime()
- has_date(), has_time()
- defined_fields() method, contributed by Rick Measham
- to_datetime() sets fields in a known order,
  instead of hash-order.  Based on a patch by Rick Measham
- Included has() method, contributed by Rick Measham


0.0101  2003-11-03
- runs in Perl 5.00503.
  Dave Rolsky  Flavio S. Glock, creating a cvs conflict :)
- there is no set_locale() in DateTime.
  Modified from a patch by Rick Measham
- fixed an infinite loop in _format_nanoseconds.
  Patch by Rick Measham


This is a sample of the new API:

   $dti = $dti-to_datetime;

   if ( $dti-can_be_datetime ) 
   {
  $dti = $dti-to_datetime
   }
   else
   {
  print only @{[ $dti-defined_fields ]} are set
   }

   if ( $dti-can_be_datetime  $dti-has_date ) ...

   if ( $dti-has_date  $dti-has_time ) ...

   if ( $dti-has_year ) ...

   if ( $dti-has( qw( year month day hour ) ) ) ...


- Flavio S. Glock


Re: DateTime::Format

2003-11-06 Thread Dave Rolsky
On Thu, 6 Nov 2003, Joshua Hoblitt wrote:

 Would this be better as a decorator that adds a format_datetime method?

 (decorator setup)
 DateTime::Format=Pg
 print DateTime-now-format_datetime

 2003-11-01 06:34:35+

Well, people using this might very well want to have DateTime act as a
translator between two data sources which need to exchange info, like two
different DBMSs.


-dave

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


ANNOUNCE: DateTime::Incomplete 0.0103

2003-11-06 Thread fglock
0.0103  2003-11-06
- start, end, to_span
- requires DateTime::Set 0.1401


Now you can do this:

  $dti = DateTime::Incomplete-new( year = 2004 );
  print Starts in ,
$dti-start-datetime,
, ends in ,
$dti-end-datetime;

  # Starts in 2004-01-01T00:00:00, ends in
2005-01-01T00:00:00

  $span = $dti-to_span;
  print Duration is ,
@{[ $span-duration-deltas ]};

  # ... seconds 31622400 nanoseconds 0

  print ICal ,
DateTime::Format::ICal-format_period(
$span );

  # ICal 20040101Z/20050101Z

If you installed the latest 
DateTime::Event::Recurrence, this will also work:

  $dti = DateTime::Incomplete-new( 
   month = 12 );
  $dti-truncate( to = month );

  print ICal ,
DateTime::Format::ICal-format_recurrence(
$dti-to_recurrence );

  # ICal
RRULE:FREQ=YEARLY;BYMONTH=12;BYMONTHDAY=1;BYHOUR=0;BYMINUTE=0;BYSECOND=0

:)

- Flavio S. Glock