Re: Cron with TimeZone

2004-06-18 Thread Matt Sisk
Tim,
As I said in response to your other email, the various 
next/previous/iterator methods should respect the time zone of the 
datetime object that you pass to them, so this should work:

 my $cron = DateTime::Event::Cron-from_cron(cron = '* * * * *');
 my $now = DateTime::Event-now(time_zone = 'Europe/Berlin');
 my $next = $cron-next($now);
 # $next will be in time zone Europe/Berlin
Recurrence sets can also be set to a default time zone. For example:
 my $cron = DateTime::Event::Cron-from_cron(cron = '* * * * *');
 my $now = DateTime-now(time_zone = 'local');
 my $lcron = $cron-set_time_zone('Europe/Berlin');
 my $next = $lcron-next($now);
 # $next will be in the Europe/Berlin time zone, even if 'local' was not
I'm reasonably sure that in this last case, the time zone is converted 
*after* all relevant calculations, so you will not inadvertently miss 
any recurrence events due merely to a time zone leap.

Cheers,
Matt


Re: Cron with TimeZone

2004-06-18 Thread Matt Sisk
Hmm,
Disregard the last note regarding the undefined value message -- buggy 
code without using warnings is to blame.

Thanks,
Matt


Re: Cron with TimeZone

2004-06-18 Thread Flavio S. Glock
Matt Sisk wrote:
 
 So I have a couple of questions:
 
   1) why isn't that method a mutator? just curious

There are no mutators in Date::Set, everything is functional.
( Version 0.14 introduced a few mutators, but they were rolled back in
version 0.15 )

   2) are datetimes from other time zones converted to the DT::S default
 time zone before computations are performed?

No, but there are some guidelines on how to compute the resulting
datetime:
  http://datetime.perl.org/developer/event.html

- Flavio S. Glock


Re: Cron with TimeZone

2004-06-18 Thread Dave Rolsky
On Fri, 18 Jun 2004, Matt Sisk wrote:

  $events-set_time_zone( 'Europe/Berlin' );
 
 

 I found this a bit confusing -- when I RTFM I discovered that this last
 line should be:

   $new_events = $events-set_time_zone( 'Europe/Berlin' );

 So I have a couple of questions:

   1) why isn't that method a mutator? just curious

Huh, I didn't even notice that it wasn't.

That seems awfully wrong to me.  Any method that starts with set_
screams mutator.

   2) are datetimes from other time zones converted to the DT::S default
 time zone before computations are performed?

I think Flavio uses the DateTime.pm object internals, for which he will be
duly punished when I change them.


-dave

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


Re: Cron with TimeZone

2004-06-18 Thread Dave Rolsky
On Fri, 18 Jun 2004, Flavio S. Glock wrote:

 Matt Sisk wrote:
 
  So I have a couple of questions:
 
1) why isn't that method a mutator? just curious

 There are no mutators in Date::Set, everything is functional.
 ( Version 0.14 introduced a few mutators, but they were rolled back in
 version 0.15 )

Well, I thought this was a more a by-product of the natural UI for sets.
Things like intersection, complement, union, etc. are all operators which
by definition create new sets, and so should not mutate.  OTOH,
set_time_zone() doesn't seem like it should be creating a new set.


-dave

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