[Brisbane-pm] Times and Dates
Jacinta Richardson
jarich at perltraining.com.au
Thu Sep 6 19:02:13 PDT 2007
Martin Jacobs wrote:
> Hi Perlmongers,
>
> Here's a tricky one to do with times and dates.
>
> I'm trying to generate a timeseries. The start and end time are
> user-defined, as is the timestep interval. So, if I start at 06/01/1990
> 00:00:00, and end at 06/01/1990 00:12:00, and specify a timestep of 6
> minutes, I will get a timeseries like this...
>
> 06/01/1990 00:00:00
> 06/01/1990 00:06:00
> 06/01/1990 00:12:00
In some ways it's overkill, but you may find it useful to use the DataTime
module from CPAN to handle your dates. This then allows you to create a date
object, add your increments easily (correctly handling leap years etc) and
compare that to see if you've over-stepped your final date.
You can find it here:
http://search.cpan.org/perldoc?DateTime
It is a large module that takes up a fair amount of memory. But it gets it
right, including leap seconds, missing days centuries ago etc.
All the best,
Jacinta
More information about the Brisbane-pm
mailing list