Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: sgarvey [...] n-c-s.net
Cc:
AdminCc:

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



Subject: Delta_Format bug
Date: Sun, 27 Jan 2013 15:15:43 -0700
To: bug-Date-Manip [...] rt.cpan.org
From: <sgarvey [...] n-c-s.net>
Between 5.56 and 6.38 something changed that's breaking previously working code

Test script:

#!/usr/local/bin/perl
use strict;
use warnings;
use Date::Manip;
$ENV{TZ} = 'PDT';

my $date1 = ParseDate('January 1, 2001 10:06AM');
my $date2 = ParseDate('January 31, 2002 10:00PM');

my $delta = DateCalc($date1, $date2); #, \$err);
print "\$delta = $delta\n";

# Here's the $format
my $format = '%dh days %hd hours';
$delta = Delta_Format($delta, 2, $format);
print "\$delta (formatted) = $delta\n";
 

With 5.56, it correctly prints 

$delta = +0:0:56:3:11:54:0
$delta (formatted) = 395 days 11.90 hours
 

With 6.38 it prints

$delta = 0:0:0:0:9491:54:0
$delta (formatted) = 0.00 days 9491.90 hours


For my own purposes, I was using "%dt" with 5.56,
but that produces a "0" delta and only "%dyh" works correctly with 6.38
This is not a bug... the format of the delta has changed in version 6.30. It now recognizes that you cannot mix 'days' and 'hours' in the delta and maintain an exact relationship (because a day is not ALWAY 24 hours long... it varies during daylight saving time transitions). So, the results you are getting are correct. However, I realize that using the functional interface, there was no way to force a delta to be treated as semi-exact which allows you to mix days and hours (see the Date::Manip::Delta pod for details). Using the OO interface, you can. So, I added a $mode argument to the ParseDateDelta function, and this will be in the next release (6.39 scheduled out Mar 1, 2013). If you need this functionality before then, please email me at sbeck@cpan.org and I'll get you a copy). You'll need to add a line: $delta = ParseDateDelta($delta,'semi'); before the call to Delta_Format, but otherwise, things will be fine, and you'll get the results you were expecting.