Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I'm not sure why this isn't working. It was working a little while ago and i don't recall changing it in any way but for some reason it's stopped now and i can't for the life of me figure out why.

Here's that particular section of code...

my $end_time = 1244572189; my ($Dd, $Dh, $Dm, $Ds) = timeDiff(localtime($end_time)); sub timeDiff(@) { my ($sec1, $min1, $hour1, $mday1, $month1, $year1, $dayofweek1, $dayofyear1, $isdst1) = @_; my ($sec2, $min2, $hour2, $mday2, $month2, $year2, $dayofweek2, $dayofyear2, $isdst2) = localtime(); $mday1 ++; $mday2 ++; $year2 = $year2 + 1900; $year1 = $year1 + 1900; return Delta_DHMS($year2, $month2, $mday2, $hour2, $min2, $sec2, $year1, $month1, $mday1, $hour1, $min1, $sec1); }
I've tried without incrementing the months or adding to the year, which i didn't have before when it was working. Anyone see what i might be doing wrong?

Replies are listed 'Best First'.
Re: Date::Calc::Delta_DHMS(): not a valid date
by ikegami (Patriarch) on May 31, 2009 at 04:09 UTC

    You're telling Date::Calc we are the 32nd of April.

    $mday1 ++; $mday2 ++;
    should be
    $month1 ++; $month2 ++;
      T_T doh!

      Cannot believe i didn't see that...

      Thanks alot ikegami. Who knows how long i would've sat here wondering what was going wrong.