in reply to DateCalc using Date::Manip
As others have noted, there are several ways to do calculations (exact, approximate, semi-approximate). Unfortunately, Date::Manip::DM6 (which is basically just an interface that is backward compatible with the older versions of Date::Manip) didn't currently support all of them (since they didn't even exist in older versions of Date::Manip).
The was no reason NOT to support them... I just had never thought to add them (and nobody had requested that). So I just did, and in the next version of Date::Manip, you'll be able to do:
my $dtopt= DateCalc($dt1,$dt2,'semi');
and get what you want. However, that won't work in the current version.
Getting what you want with the current version of Date::Manip::DM6 is harder because in the older module, there were only exact and approximate, and in newer versions there are exact, semi-approximate, and approximate, and it's challenging to get what you want. Really, the best way would be to do that calculation using the OO interface:
use Date::Manip::Date; my $date1 = new Date::Manip::Date; my $date2 = $date1->new_date(); $date1->parse($dt1); $date2->parse($dt2); my $delt = $date1->calc($date2,'semi'); my $delv = $delt->value(); print "$delv\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: DateCalc using Date::Manip
by huck (Prior) on Jan 10, 2017 at 18:03 UTC | |
by SBECK (Chaplain) on Jan 11, 2017 at 16:50 UTC | |
by tsdesai (Acolyte) on Jan 11, 2017 at 10:25 UTC |