You can use
Date::Calc of course (or
Date::Manip).
I'm almost in agreement with
dws, except that time is a concept that is ethreal at best. If you're in a region plagued by "daylight savings time", then this may not work during that small window where a day has only 23 hours, or perhaps 25. It's like changing time-zones even though you're sitting still.