Posted on 2009-05-30 13:33:33-07 by bblakley
Suggestion to add a Localdate function

Not a bug, just a suggestion. I may be missing an existing method to do what I seek.

A large number of the Date::Calc functions require one or more sets of ($year,$month,$day) arguments. Frequently what I am working with is an epoch time value (such as is returned by the system 'time' function), and would like to use that value in my Date::Calc manipulations.

Since the Date::Calc::Localtime function turns an epoch time into $year, $month, $day, $hour, $min, $sec, $doy, $dow, $dst (which is fine) and since I see no function that returns only ($year, $month, $day), if I have an epoch time and simply want to find out what the "day before" that epoch time was, I have to do this:

my @dateOfInterest = Localtime($epochTime); my ($year,$month,$day) = Add_Delta_Days($dateOfInterest[0],$dateOfInterest[1],$dateOfInterest[2],-1 +);

While this does work, what would be nifty would be a Localdate that returns only ($year, $month, $day) thereby allowing this:

my ($year,$month,$day) = Add_Delta_Days(Localdate($epochTime),-1);

Thanks for this great module. It is very useful.

Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.