DateTime::Set set_time_zone fix

2004-07-01 Thread Flavio S. Glock
Thanks to Tim Mueller-Seydlitz and Matt Sisk, who found 
a couple of bugs in the DateTime::Set time zone handling. 

I'd like to have some feedback from you, before I put 
the fixed version on CPAN.

You can get the new version from CVS, or send me a mail
and I'll send you a tar file.

You'll need to update Set::Infinite to version 0.59,
it is also in CVS.

These are the changes from DateTime::Set version 0.15:

- fixed time zone handling in the methods:
  set_time_zone
  next/previous/closest/current

- removed limitation of duration size in methods:
  add/add_duration
  subtract/subtract_duration

- requires Set::Infinite 0.59 - uses iterate() experimental
  argument "backtrack_callback"

- the following methods are now mutators:
  set_time_zone( $tz )
  set( locale => $locale )
  add( unit => $n )
  add_duration( $dur )
  subtract( unit => $n )
  subtract_duration( $dur )

- fixed max/min of an infinite SpanSet
- added test for infinite duration

- from_recurrence() code cleanup

- parameter checking: The 'dates' argument to from_datetimes()
  must be a list of DateTime objects

That's all for now.

- Flavio S. Glock


Re: DateTime::Set set_time_zone fix

2004-07-01 Thread Flavio S. Glock
I'm doing some tests with the revised version of DateTime::Set:

[EMAIL PROTECTED] wrote:
> 
> use DateTime::Event::Cron;
> 
> $cron = DateTime::Event::Cron->from_cron(cron => ' 15 18 * * 1-5');
> $new_cron = $cron->clone()->set_time_zone('Europe/Berlin');
> 
> $date = DateTime->new( year => 2004, month => 6, day => 30,
>hour => 17,   minute=> 10,
>time_zone => 'Europe/London');
> 
> print $date->strftime("%a %F %T %Z\n");
# Wed 2004-06-30 17:10:00 GMT/BST

ok

> $date = $date->clone()->set_time_zone('Europe/London');
> 
> print $date->strftime("%a %F %T %Z\n");
# Wed 2004-06-30 17:10:00 GMT/BST

ok

> $next = $new_cron->next($date);
> print $next->strftime("%a %F %T %Z\n");
# was: Wed 2004-06-30 19:15:00 CEST

I got Wed 2004-06-30 17:15:00 GMT/BST, it looks correct now.
This is the local London time, when cron ticks 18:15 in Berlin.

> # Let's repeat the same operation as before
> 
> $date = DateTime->new( year => 2004, month => 6, day => 30,
>hour => 17,   minute=> 10,
>time_zone => 'Europe/London');
> 
> print $date->strftime("%a %F %T %Z\n");
# Wed 2004-06-30 17:10:00 GMT/BST

ok

> $date = $date->clone()->set_time_zone('Europe/Berlin');
> print $date->strftime("%a %F %T %Z\n");
# Wed 2004-06-30 18:10:00 CEST

ok

> $next = $new_cron->next($date);
> print $next->strftime("%a %F %T %Z\n");
# Wed 2004-06-30 18:15:00 CEST

ok.
This is the local Berlin time, when cron ticks 18:15 in Berlin.
It is the same time as before, but in a different time zone.

- Flavio S. Glock