Having spent some time yesterday creating a simple web application which has some date/time stuffs in it, I realized how horrible the Unix API (and thus, PHP's API) and MySQL's date/time handling are. Conversion between month that starts from 0 and 1, year that needs to be substracted/added with 1900, these certainly have bitten (and will continue to bite) people's behind on a regular basis.
Luckily Perl 5.10 will include Time::Piece which will make localtime/gmtime become saner and more straightforward. It even includes many bonuses like leap year- and DST checking, strftime(), simple date calculation, etc.
Unfortunately we can't modify date/time elements in a Time::Piece object, e.g. $t->mon(1) (setting the month to January).
Now on to the quiz question: what would be the simplest and most straightforward way in Perl to, given a Unix timestamp t, returns two Unix timestamps t1 and t2 that are the start and end of day (or week, or month, or year) where t1 <= t <= t2.
In reply to Date calculation: start and end of period by dgaramond2
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |