in reply to Converting seconds to DD:HH:MM:SS

This solution is simular to your database solution:
sub seconds_to_dhms { my $t = shift; return int($t / 86400), (gmtime($t))[2, 1, 0]; }
but it should be a bit faster.

UPDATE: renamed function as per sauoq (I had copied it directly from the question.)

-- gam3
A picture is worth a thousand words, but takes 200K.

Replies are listed 'Best First'.
Re^2: Converting seconds to DD:HH:MM:SS
by sauoq (Abbot) on Oct 08, 2005 at 05:55 UTC
    sub sec_to_ddmmss { my $t = shift; return int($t / 86400), (gmtime($t))[2, 1, 0]; }

    This is clever, but I'd like to see it commented because at first glance, it might appear erroneous. It should be better named too. I'd probably call it seconds_to_dhms(). Yours is broken in two respects: 1) you missed 'hh' for hours and 2) the doubled letters imply that your return values are formatted to two digits.

    -sauoq
    "My two cents aren't worth a dime.";