[Denver-pm] Simplifying Time?

Jay Hannah jay at jays.net
Thu Mar 20 09:23:47 PDT 2014


On Mar 20, 2014, at 11:06 AM, Robert L. Harris <robert.l.harris at gmail.com> wrote:
> It looks like the reldate is what I want, not figure out how to use it.  No clear examples on "convert 561 seconds to 9 minutes, 21 seconds" :)

Does this help?

https://github.com/jhannah/sandbox/blob/master/robertlharris/go.pl


$ cat go.pl
use Class::Date;
use 5.10.0;

my $reldate = new Class::Date::Rel "561s";
say "In minutes: " . $reldate->min;
say "In seconds: " . $reldate->sec;

my $seconds_only = $reldate - (int($reldate->min) * 60 . 'm');  # subtract minutes away
say "Seconds only: $seconds_only";
printf("%d minutes %d seconds\n", int($reldate / 60), $seconds_only);


$ perl go.pl
In minutes: 9.35
In seconds: 561
Seconds only: 21
9 minutes 21 seconds


j




More information about the Denver-pm mailing list