Subject: | Bug in calculating week for Sundays |
Date: | Thu, 11 Dec 2014 01:53:25 +0000 |
To: | "'bug-Time-Period [...] rt.cpan.org'" <bug-Time-Period [...] rt.cpan.org> |
From: | "Rob Fries" <Rob.Fries [...] ascensus.com> |
Hi,
We have found a bug where Time::Period incorrectly identifies the Week for a Sunday Time period. Time::Period is installed from the standard rehl distro's via Yum.
OS: rehl5 & rehl6
Perl: v5.8.8 & v5.10.1
Time::Period:
perl-Time-Period.noarch 1.20-2.el5.rf installed
perl-Time-Period.noarch 1.21-1.el6.rf @dags
Our example is:
$ cal 6 2014
June 2014
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
$ date +%s -d "6/8/2014 12:00:00"
1402200000
$ perl -e 'use Time::Period;
my $inp = inPeriod(1402200000, "wk {2} wd {su}");
if ($inp == -1 ){ print "bad schedule\n"; }
elsif ($inp == 1 ){ print "In period\n"; }
elsif ($inp == 0 ){ print "Out of period\n"; }'
Out of period
Running through the code with the perl debugger, it seems the following line of code has an incorrect variable:
if ( (0 == $wd[$i]) && (1 != $md) ) {
the comment seems to agree this should be:
# increment $wk unless $i is also 1, which means its still week 0.
if ( (0 == $wd[$i]) && (1 != $i) ) {
assuming this will only be fixed in future version, the issue is at:
v1.24: line 433
v1.20 & 1.21: line 424
this change seems to have fixed the issue, but I have not done any further testing.
Let me know if there is anything further I can provide.
Rob Fries
Ascensus College Savings
System Integration Architect | Technical Operations
CONFIDENTIALITY NOTICE: This message, including attachments, is intended to be viewed only by the addressee. It may contain information that is privileged, confidential and/or exempt from disclosure under applicable law. No confidentiality or privilege is lost by any transmission error. This message may contain nonpublic personal information about consumers subject to the restrictions of the Gramm-Leach-Bliley Act and the Sarbanes-Oxley Act. You may not directly or indirectly reuse or disclose such information for any purpose except as permitted by law. Any dissemination, distribution or copying of this message is strictly prohibited without our prior written permission. If you are not an intended recipient, or if you have received this message in error, please notify us immediately by return e-mail and permanently remove the original message and any copies from your computer and all back-up systems.