DateTime::Event::Recurrence says:
The "start" parameter should have no time zone.
I'm not sure what was the reason for that, but you'd better not use a
timezone in $start.
This probably needs to be better documented.
This seems to work:
---
$start = DateTime::Format::ICal->parse_datetime($rfc_time);
# Create a datetime set with a recurrence of "daily", starting at the
# datetime we created above.
$set = DateTime::Format::ICal->parse_recurrence(
dtstart => $start,
recurrence => 'FREQ=DAILY;INTERVAL=1');
$set->set_time_zone('America/Chicago');
---
- Flavio S. Glock
2007/3/14, Tim Klein <[EMAIL PROTECTED]>:
Hello, all!
We're seeing what appears to be a Daylight Saving Time related bug.
But maybe instead we're asking DateTime to do something unreasonable?
(I've been following the discussion between Matthew and Zefram, but I
think this is a different issue.)
Below is a small Perl program that demonstrates the problem. The
program constructs a "daily at 23:00" recurrence, and then prints the
first four occurrences in it. (In case it matters, we're running
this on a Linux machine whose kernel has been updated for the new
Daylight Saving Time change dates in the USA.)
Question #1: Run the program. This is the output:
Occurrence #1: 2007-03-10T23:00:00 America/Chicago CST (1173589200)
Occurrence #2: 2007-03-12T23:00:00 America/Chicago CDT (1173758400)
Occurrence #3: 2007-03-13T23:00:00 America/Chicago CDT (1173844800)
Occurrence #4: 2007-03-14T23:00:00 America/Chicago CDT (1173931200)
Why did it skip 2007-03-11? That was the day when CST became CDT,
but why would that cause it to skip that day altogether?
===
Question #2: In the line near the top that assigns $rfc_time, change
the 23 to some lower number, such as 14. In other words, change the
start time of the recurrence from 23:00 to 14:00. Run the program.
This is the output:
Occurrence #1: 2007-03-10T14:00:00 America/Chicago CST (1173556800)
Occurrence #2: 2007-03-11T15:00:00 America/Chicago CDT (1173643200)
Occurrence #3: 2007-03-12T14:00:00 America/Chicago CDT (1173726000)
Occurrence #4: 2007-03-13T14:00:00 America/Chicago CDT (1173812400)
Why does it show a different time on 2007-03-11 than on the other
days? I think it should say 14:00 CDT, right? But even if 15:00 is
correct for some reason, then why isn't 15:00 also correct for all of
the days after that?
Thank you for any help!
Tim
Dallas, Texas, USA
==============
#!/usr/bin/perl
use DateTime;
use DateTime::Format::ICal;
$rfc_time = '20070310T230000';
# Create a start datetime.
$start = DateTime::Format::ICal->parse_datetime($rfc_time);
$start->set_time_zone('America/Chicago');
# Create a datetime set with a recurrence of "daily", starting at the
# datetime we created above.
$set = DateTime::Format::ICal->parse_recurrence(
dtstart => $start,
recurrence => 'FREQ=DAILY;INTERVAL=1');
# Show the first few occurrences in that datetime set.
for ($i=1; $i <= 4; ++$i) {
$occurrence = $set->next;
print "Occurrence #$i: ", $occurrence,
" ", $occurrence->time_zone->name,
" ", $occurrence->time_zone_short_name,
" (", $occurrence->epoch, ")\n";
}