jpfarmer has asked for the wisdom of the Perl Monks concerning the following question:
I think I've uncoveded a bug in Date::Calc, but before I submit a bug report, I'd like some feedback.
Using the sample script below, I recieve the following output:
Today_and_Now value: 2003-12-1-14-52-15 End time value: 2004-4-1-0-0-0 Function |Yrs |Mons |Hrs |Days |Mins |Secs ------------------------------------------------- Delta_DHMS | N/A| N/A| 121| 9| 7| 45 Delta_YMDHMS | 1| -8| 0| -14| -52| -15
Notice how Delta_DHMS calculates each value, while Delta_YMDHMS shows offset from the years of difference. I can't tell if this is by design or not according to the module docs. The nearest thing I can find to an explination is this passage:
This function is based on the function "Delta_YMD()" above but additionally calculates the time difference. When a carry over from the time difference occurs, the value of "$D_d" is adjusted accordingly, thus giving the correct total date/time difference.
The Date::Calc Readme doesn't make any mention of changes regarding this function, so I don't think it's something that's been changed recently.
I guess the bottom line is, I'm not confident enough in my debugging skills to know if I've discovered a bug, am misreading the documentation, or if something is goofy on the system I'm working with. Any feedback would be greatly appreciated.
#!/usr/bin/perl use warnings; use strict; use Date::Calc qw/Time_to_Date Delta_YMDHMS Delta_DHMS Today_and_Now/; my ( $year, $month, $day, $hour, $min, $sec ) = Today_and_Now(); my ( $end_year, $end_month, $end_day, $end_hour, $end_min, $end_sec ) = ( 2004, 4, 1, 0, 0, 0 ); my @cached_today_and_now = Today_and_Now; print "Today_and_Now value: ", join('-', @cached_today_and_now), "\n"; print "End time value: 2004-4-1-0-0-0\n\n"; print 'Function |', join ( '|', map { sprintf( "%-5s", $_ ) } qw/Yrs Mons Hrs Days Mins Secs/ ), "\n"; print "-" x 49, "\n"; # The two N/As are added in to pad the results of Delta_DHMS, as it # returns two fewer values and I wanted the table to line up neatly print 'Delta_DHMS |', join ('|', (' N/A', ' N/A', map { sprintf( "%5d", $_ ) } Delta_DHMS( @cached_today_and_now, 2004, 4, 1, 0, 0, 0 ))), "\n"; print 'Delta_YMDHMS |', join ( '|', map { sprintf( "%5d", $_ ) } Delta_YMDHMS( @cached_today_and_now, 2004, 4, 1, 0, 0, 0 ) ), "\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Unexplained Behavior in Date::Calc
by mojotoad (Monsignor) on Dec 01, 2003 at 21:37 UTC | |
by Madams (Pilgrim) on Dec 02, 2003 at 01:57 UTC | |
by mojotoad (Monsignor) on Dec 02, 2003 at 06:33 UTC | |
|
Re: Unexplained Behavior in Date::Calc (yuck)
by tye (Sage) on Dec 02, 2003 at 07:55 UTC | |
by dragonchild (Archbishop) on Dec 02, 2003 at 14:03 UTC | |
|
Re: Unexplained Behavior in Date::Calc
by pg (Canon) on Dec 02, 2003 at 03:46 UTC |