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.