in reply to Re: Re: Subtracting Dates
in thread Subtracting Dates
Because
is, to me, at least as readable as ehdonhon's example of using Add_Delta_YMD and doesn't pollute the namespace either?my $seconds_per_day = 60 * 60 * 24; my $then = time - (14 * seconds_per_day);
Granted, the $seconds_per_day version takes a little extra work (remembering which indexes from (localtime($then)) you want and adding offsets to the extracted month and year if you intend to display them directly), but it's worthwhile to have more easily portable code, IMHO.
For a larger project that's likely to need other modules, sure, Date::Calc is great. But if it's the only non-core module that would be used, I don't think it's worth the hassle of making people install it when you can do the same thing using only the core language with so little extra effort.
|
---|