It's a bug.
You can workaround it by setting the time zone first to 'floating',
and then to 'Asia/Jerusalem':
------
sub show_day_start_and_end {
   my ($day_index, $day_name, $day_of_month) = @_;

   my $span_set =
       DateTime::SpanSet
           ->from_sets(
               start_set   =>
                   DateTime::Event::Recurrence->weekly(
                       days => $day_index, hours => 8, minutes => 30,
                   ),
               end_set     =>
                   DateTime::Event::Recurrence->weekly(
                       days => $day_index, hours => 15, minutes => 30,
                   ),
           )
           ->set_time_zone('floating')
           ->set_time_zone('Asia/Jerusalem');

   my $date =
       DateTime->new(
           year        => 2008,
           month       => 3,
           day         => $day_of_month,
           hour        => 12,
           time_zone => 'Asia/Jerusalem'
       );

   my $span = $span_set->current($date)->span();
   say "$day_name start: ", $span->start(), ' end: ', $span->end(), '
', $span->end->time_zone->name;
}
-----

Tests would be much welcome :)

Flávio S. Glock

2008/12/16  <p...@galumph.com>:
> I'm seeing unexpected behavior with recurrences on different sides of a 
> daylight savings change.  I'm expecting that I get the same local time of 
> day, regardless of which side I'm on.
>
> I've been using Jerusalem as a test time zone due to the fact that it goes 
> onto daylight savings on a Friday.  So, in the below sample code, I'm testing 
> last spring's changeover on 2008-3-28.  Since both the Thursday and Friday 
> recurrences start and end at the same times of day, I'm expecting that I 
> should get 8:30am for the start and 3:30pm for the end on both days.  
> However, what I get for output is:
>
>    Thursday start: 2008-03-27T08:30:00 end: 2008-03-27T15:30:00
>    Friday start: 2008-03-28T09:30:00 end: 2008-03-28T16:30:00
>
> How do I get consistent local times of day?
>
> -----
>
> DateTime: 0.4305
> DateTime::Event::Recurrence: 0.16
> DateTime::SpanSet: 0.25
>
> perl 5.10.0
>
> -----
>
> use DateTime;
> use DateTime::Event::Recurrence;
> use DateTime::SpanSet;
>
> show_day_start_and_end(4, 'Thursday', 27);
> show_day_start_and_end(5, 'Friday',   28);
>
> sub show_day_start_and_end {
>    my ($day_index, $day_name, $day_of_month) = @_;
>
>    my $span_set =
>        DateTime::SpanSet
>            ->from_sets(
>                start_set   =>
>                    DateTime::Event::Recurrence->weekly(
>                        days => $day_index, hours => 8, minutes => 30,
>                    ),
>                end_set     =>
>                    DateTime::Event::Recurrence->weekly(
>                        days => $day_index, hours => 15, minutes => 30,
>                    ),
>            )
>            ->set_time_zone('Asia/Jerusalem');
>
>    my $date =
>        DateTime->new(
>            year        => 2008,
>            month       => 3,
>            day         => $day_of_month,
>            hour        => 12,
>            time_zone => 'Asia/Jerusalem'
>        );
>
>    my $span = $span_set->current($date)->span();
>    say "$day_name start: ", $span->start(), ' end: ', $span->end();
> }
>

Reply via email to