Hi all, What better way to celebrate an arbitrary calendar event than with a new API for date calculations?
Coming soon to http://search.cpan.org/dist/Date-Piece/ Date::Piece is currently just a Date::Simple object with more operator overloading, a link to Time::Piece, and convenient support for adding (or subtracting) in units of years, months, or days. use Date::Piece qw(date today years months days); my $date = today + 3*years + 3*months + 3*days; my $deadline = $date->at("16:00"); # a Time::Piece object Note that the *days unit is optional, but it adds run-time stricture that the quantity must be an integer. Careful, that may not be the same as 'today + 3*days + 3*months + 3*years'. The caveat may apply if today is any day >= 28 -- if we run out of days in the destination month, we stop at the end. Yes, there are caveats when adding nominal months (or even years if you start on Feb 29th), but the concept of "day math" works better for dates than e.g. attempting to traverse a year in steps of 24*60**2 seconds. Currently, I'm still playing with the API design. I think the overload interface is done, but as far as the method names go, I think I may have to break-away from Date::Simple compatibility in order to make it fit the Time::Piece metaphor (that is, it's a lot like a Time::Piece which is stuck at midnight.) Anyway, it's a date object which supports nominal calendar math with a compact API. I plan to add a few other things (like "the monday on or preceding said day") for week-wise iteration and etc. Maybe some things that would be found in Date::Manip and etc. Questions and suggestions welcome. Particularly, have I overlooked an already-existing module with all of said features and a shorter API? Also, any thoughts on a favorite backend for business days and/or what that API should look like? --Eric -- The opinions expressed in this e-mail were randomly generated by the computer and do not necessarily reflect the views of its owner. --Management --------------------------------------------------- http://scratchcomputing.com ---------------------------------------------------
