[Denver-pm] Simplifying Time?

Jay Hannah jay at jays.net
Thu Mar 20 08:37:39 PDT 2014


On Mar 20, 2014, at 10:19 AM, Robert L. Harris <robert.l.harris at gmail.com> wrote:
> I'm running a script that is adding up the duration of events.  By the end of it I have something like this:
> 
> $Days=5
> $Hours=131
> $Mins=618
> $Secs=151
> 
> Anyone know a simple modules to simplify this to standard ranges?  Even if I have to do a multi-step?  I've looked into a few options but none are 'clean.'

The defacto thing everyone and their mom uses is DateTime:

   https://metacpan.org/pod/DateTime

I find it pretty meh for some things, so I used to use Class::Date a ton at a previous job:

   https://metacpan.org/pod/distribution/Class-Date/Date.pod

   # creating relative date object
   # (normally you don't need to create this object explicitly)
   my $reldate = new Class::Date::Rel "3Y 1M 3D 6h 2m 4s";

It's been a while since I hacked on this stuff hard.  :)

j
Omaha.pm









More information about the Denver-pm mailing list