Skip Menu |

This queue is for tickets about the Schedule-Cron-Events CPAN distribution.

Report information
The Basics
Id: 68393
Status: rejected
Priority: 0/
Queue: Schedule-Cron-Events

People
Owner: KOHTS [...] cpan.org
Requestors: alessio.palma [...] dada.net
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.8
Fixed in: (no value)



Subject: Bad date computing.
I ran this script on 23 May 2011, I think there is a problem on month crossing. use Schedule::Cron::Events; use strict; use warnings; use DateTime; use HTTP::Date; use Time::HiRes; # ($year,$month,$day,$hour,$minute,$second,$tz) = HTTP::Date::parse_date($str); # my $datetime_event = DadaMobile::Time::parse( (sprintf "%4d-%02d-%02d %02d:%02d:%02d", $year, $month, $day, $hour, $min, $sec), 'UTC' ); my $crontime = "00 14 * * 1,4"; my $now = DateTime->from_epoch( epoch => Time::HiRes::time(), time_zone => 'UTC' ); my $date = [ split /,/, $now->strftime('%S,%M,%H,%d,%m,%Y') ]; $date->[5] -= 1900; # 1900 + date->[5] => current year my $obj_crontab = Schedule::Cron::Events->new( $crontime, Date => $date ); for (my $i = 0 ; $i<5 ; $i++ ) { my ( $sec, $min, $hour, $day, $month, $year ) = $obj_crontab->nextEvent(); my $obj_dt = DateTime->new( year => $year + 1900 , month => $month , day => $day , hour => $hour , minute => $min, second => $sec, nanosecond => 0, time_zone => 'UTC' ); print "next event => $obj_dt\n"; } next event => 2011-05-23T14:00:00 MONDAY, next event => 2011-05-27T14:00:00 THUESDAY, next event => 2011-05-30T14:00:00 MONDAY, next event => 2011-06-04T14:00:00 SATURDAY ??? next event => 2011-06-07T14:00:00 THURSDAY ??? The correct results are next event => 2011-06-02T14:00:00 THUESDAY next event => 2011-06-06T14:00:00 MONDAY ------------ This is perl, v5.10.1 (*) built for x86_64-linux-gnu-thread-multi Linux ubuntu 2.6.32-30-generic #59-Ubuntu SMP Tue Mar 1 21:30:46 UTC 2011 x86_64 GNU/Linux Schedule-Cron-Events-1.8-shl9hp
Sorry, didn't notice the ticket till June of 2013. So there're two errors in the example: 1) you have to pass month - 1 to Schedule::Cron::Events->new() 2) my $obj_dt builder seems to contain the same error So if you replace 2011-06 with 2011-07 and 2011-05 with 2011-06 in the example output, you will have: next event => 2011-06-23T14:00:00 MONDAY next event => 2011-06-27T14:00:00 THURSDAY next event => 2011-06-30T14:00:00 MONDAY next event => 2011-07-04T14:00:00 THURSDAY next event => 2011-07-07T14:00:00 MONDAY which is exactly what's specified by the cron line "00 14 * * 1,4". Nevertheless I've added some tests and input parameter checks which will catch some of the errors of this kind. Will be released soon in 1.10. Rejecting the bug.