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

Reply via email to