in reply to calculate date difference

use Data::Simple qw(date); my $start = date('1940-02-12'); my $min = date('2007-05-01'); my $end = date('2010-08-23'); my $max = date('2008-04-30'); $start = $min if $star < $min; $end = $max if $max < $end; print "Duration: ", $end - $start, " date\n";
Perl 6 - links to (nearly) everything that is Perl 6.

Replies are listed 'Best First'.
Re^2: calculate date difference
by ikegami (Patriarch) on Jul 06, 2010 at 19:56 UTC
    Since he's using delta_ms, it sounds to me like the OP wants the duration in minutes and/or seconds.
      I don't see much sense in calculating milliseconds when the date is being parsed with the accuracy of seconds (looking at the regex), and the upper and lower limits are dates only, no time specified.

      Maybe I misunderstood something, but I'll blame it on the unclear question :-)

      Perl 6 - links to (nearly) everything that is Perl 6.

        I don't see much sense in calculating milliseconds

        It's confusingly named, but delta_ms returns minutes+seconds, not milliseconds. It's the sister of delta_md, which returns months+days.

        the upper and and lower limits are dates only, no time specified.

        It really doesn't need to be said what's the first and last second of the day. Times were specified for the timestamps checked against the limits.

        So yeah, it's still ambiguous. OP, what resolution do you want?