Skip Menu |

This queue is for tickets about the Date-Manip CPAN distribution.

Report information
The Basics
Id: 131751
Status: resolved
Priority: 0/
Queue: Date-Manip

People
Owner: Nobody in particular
Requestors: ShriverSteve [...] prahs.com
Cc:
AdminCc:

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



Subject: Error in DateCalc() between version 6.60 and 6.79 of Date::Manip
Date: Tue, 11 Feb 2020 23:45:05 +0000
To: "bug-Date-Manip [...] rt.cpan.org" <bug-Date-Manip [...] rt.cpan.org>
From: "Shriver, Steve" <ShriverSteve [...] prahs.com>
Hi y’all, I have found two potential bugs with Date::Manip. The first one (#1 below) is that I get no output for data given to the DateCalc() method in Date::Manip-6.79, but it works under v6.60. The second problem (#2 below) is in Date::Manip-6.60, which looks like a Y2K-type problem. I have Date::Manip-6.60 on my old rhel6 server. A recent upgrade on the host required building all the cpan modules, we picked up latest versions including Date::Manip-6.79. My application broke in one place related to your module. I’ve reduced the errors to the following script, running on my Mac OS X 10.15.3; using perlbrew to install perl-5.30.1 and perl-5.18.4. [shriversteve@MAC] [2]:679: --# uname -a Darwin Mac 19.3.0 Darwin Kernel Version 19.3.0: Thu Jan 9 20:58:23 PST 2020; root:xnu-6153.81.5~1/RELEASE_X86_64 x86_64 Show quoted text
--- test code --- [shriversteve@MAC] [2]:676: --# cat ./date_manip_test.pl #!/usr/bin/env perl # use v5.18; use Date::Manip; printf("running %s v(%vd)\n", $^X, $^V); say "\$Date::Manip::VERSION ", "$Date::Manip::VERSION \n"; my ($now, $dc, $ud, $err, ); $now = UnixDate("today", q[%c]); say "unixdate: $now"; for ( qw(exact semi approx) ) { my $delta = ParseDateDelta( "- 28 days", $_ ); say "delta ($_): $delta"; $dc = DateCalc("today", $delta, \$err, 2); say "datecalc: $dc"; say " error: $err" if $err; $ud = UnixDate($dc, q[%Y-%m-%d]); say "unixdate: $ud"; say ""; } __END__ --- test 1: working --- [shriversteve@MAC] [2]:658: --# perlbrew exec cpanm ~/.cpanm/dists/Date-Manip-6.60.tar.gz [shriversteve@MAC] [2]:677: --# perlbrew exec ./date_manip_test.pl perl-5.30.1 ========== running /Users/shriversteve/perl5/perlbrew/perls/perl-5.30.1/bin/perl v(5.30.1) $Date::Manip::VERSION 6.60 unixdate: Tue Feb 11 00:00:00 2020 delta (exact): 0:0:0:0:-672:0:0 datecalc: 2019102911:00:00 #<== Y2K? (#2) unixdate: 2019-10-29 delta (semi): 0:0:-4:0:0:0:0 datecalc: 2020011408:00:00 unixdate: 2020-01-14 delta (approx): 0:0:-4:0:0:0:0 #<== my use case (#1) datecalc: 2020011408:00:00 unixdate: 2020-01-14 perl-5.18.4 ========== running /Users/shriversteve/perl5/perlbrew/perls/perl-5.18.4/bin/perl v(5.18.4) $Date::Manip::VERSION 6.60 unixdate: Tue Feb 11 00:00:00 2020 delta (exact): 0:0:0:0:-672:0:0 datecalc: 2019102911:00:00 unixdate: 2019-10-29 delta (semi): 0:0:-4:0:0:0:0 datecalc: 2020011408:00:00 unixdate: 2020-01-14 delta (approx): 0:0:-4:0:0:0:0 datecalc: 2020011408:00:00 unixdate: 2020-01-14 --- test 2: broken --- [shriversteve@MAC] [2]:661: --# perlbrew exec cpanm ~/.cpanm/dists/Date-Manip-6.79.tar.gz [shriversteve@MAC] [2]:678: --# perlbrew exec ./date_manip_test.pl perl-5.30.1 ========== running /Users/shriversteve/perl5/perlbrew/perls/perl-5.30.1/bin/perl v(5.30.1) $Date::Manip::VERSION 6.79 unixdate: Tue Feb 11 00:00:00 2020 delta (exact): 0:0:0:0:-672:0:0 datecalc: error: 3 unixdate: delta (semi): 0:0:-4:0:0:0:0 datecalc: error: 3 unixdate: delta (approx): 0:0:-4:0:0:0:0 #<== my use case (#1) datecalc: error: 3 unixdate: perl-5.18.4 ========== running /Users/shriversteve/perl5/perlbrew/perls/perl-5.18.4/bin/perl v(5.18.4) $Date::Manip::VERSION 6.79 unixdate: Tue Feb 11 00:00:00 2020 delta (exact): 0:0:0:0:-672:0:0 datecalc: error: 3 unixdate: delta (semi): 0:0:-4:0:0:0:0 datecalc: error: 3 unixdate: delta (approx): 0:0:-4:0:0:0:0 datecalc: error: 3 unixdate: My original code (and problem report) was an observed issue with DateCalc(“today”, “- 28 days”, \$err, 2) that worked under Date-Manip-6.60 and fails under Date-Manip-6.79. That problem is demo’d above in the “approx.” test. But in digging into the various mode’s for ParseDateDelta(), I see that there is also a potential Y2K-looking error in the 6.60 version when using ‘exact’ mode. (Not my original problem, but an interesting bug potentially.) Is this a DateCalc() bug in the Date-Manip-6.79 or a problem with how I’m using your module? Thanks, Steve PS – Digging into the code, I see where the error is occurring in Date/Manip/DM6.pm, around line 393-396, but I don’t see the correct solution. Yet! Hope this helps. 😊 [signature_1380953652] Steve Shriver Sr Software Engineer 4130 Parklake Ave • Raleigh, NC 27612 • USA • prahs.com [signature_1792515981]

Message body is not shown because it is too large.

Download image001.png
image/png 2.8k
image001.png
Download image002.png
image/png 2.4k
image002.png
What you see as two potential bugs are actually related to 1 bug which was corrected in Date::Manip 6.70 (which is why you see a different behavior going from 6.60 to 6.79). Your script includes the following: my $delta = ParseDateDelta( "- 28 days", $_ ); $dc = DateCalc("today", $delta, \$err, 2); The 2nd statement is actually incorrect, but in a way which was not trapped in old versions (prior to 6.70) but IS trapped now. In the 2nd statement, the 4th argument (2) explicitly tells Date::Manip to do a business mode calculation. Now when you parsed the delta, you told it it was an exact, semi-exact, or business mode delta, but then you ignore that fact in the second line by forcing business mode. So, all three calculations in the loop are doing business mode calculations. The default day is 8-5 (which is 9 hours long) and if you subtract 672 hours from "today", you'll get some time during the work day. So, the result that you got is correct (if you treat the delta as a business mode). When you subtract 4 weeks, you get the start of the business day (08:00) 4 weeks in the past. So, all of those results are correct. However, it was a mistake to use a non-business mode delta in a business mode calculation. This was pointed out to me (and corrected) in 6.70. So, if you change your second line to: $dc = DateCalc("today", $delta, \$err); (i.e. remove the '2' argument), then Date::Manip will determine the type of calculation form the delta itself, and things will work as expected.
Show quoted text
> In the 2nd statement, the 4th argument (2) explicitly tells > Date::Manip to do a business mode calculation. Now when you parsed > the delta, you told it it was an exact, semi-exact, or business mode > delta, but then you ignore that fact in the second line by forcing > business mode.
Correction.... You parsed them as an exact, semi-exact, or approximate delta.