in reply to Trouble with Dates
pojuse strict; use warnings; use Date::Calc qw( Delta_Days Today Days_in_Month ); my $cnt = 0; # work out end of current month my ($y,$m,$d) = Today(); my $mth_end = sprintf "%04d,%02d,%02d",$y,$m,Days_in_Month($y,$m); while (<DATA>) { my @dates = split '\s+', $_; $cnt++; # fill empty dates with month end my @ymd1 = split ',',$dates[0] //= $mth_end; my @ymd2 = split ',',$dates[1] //= $mth_end; my $diff = Delta_Days(@ymd1, @ymd2); print "$dates[0] $dates[1] $diff \n"; } print $cnt, "\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Trouble with Dates
by rruser (Acolyte) on Jul 10, 2013 at 18:48 UTC | |
by poj (Abbot) on Jul 10, 2013 at 19:15 UTC |