Time::Seconds(3pm)
π Time::Seconds β the perl manual page, but make it cute
okay so bestie, this is Time::Seconds, straight out of the Perl Programmers Reference Guide, and it's literally the glow-up your seconds deserved β¨
πΈ NAME πΈ
Time::Seconds β a simple API to convert seconds to other date values π
β¨ SYNOPSIS β¨
like, here's the whole vibe in one go, no cap:
use Time::Piece;
use Time::Seconds;
my $t = localtime;
$t += ONE_DAY;
my $t2 = localtime;
my $s = $t - $t2;
print "Difference is: ", $s->days, "\n";
π DESCRIPTION π
So this module is part of the Time::Piece distribution, and its whole job is giving you the number of minutes, hours, days, weeks or years hiding inside some number of seconds. It's what Time::Piece hands back to you when you delta two Time::Piece objects β like, you subtract one from the other and boom, you get one of these π¦
Time::Seconds also exports these constants:
ONE_DAY
ONE_WEEK
ONE_HOUR
ONE_MINUTE
ONE_MONTH
ONE_YEAR
ONE_FINANCIAL_MONTH
LEAP_YEAR
NON_LEAP_YEAR
β οΈ real talk though: since perl does not (yet?) support constant objects, these constants are in seconds only. So you literally cannot do this: print ONE_WEEK->minutes; β yeah, tragic, i know π
π METHODS π
here's the lineup, bestie:
my $val = Time::Seconds->new(SECONDS)
$val->seconds;
$val->minutes;
$val->hours;
$val->days;
$val->weeks;
$val->months;
$val->financial_months; # 30 days
$val->years;
$val->pretty; # gives English representation of the delta
The usual arithmetic (+,-,+=,-=) is also available on the objects, slay π
The methods make the assumption that there are 24 hours in a day, 7 days in a week, 365.24225 days in a year and 12 months in a year. (from The Calendar FAQ at http://www.tondering.dk/claus/calendar.html) π§
π«Ά AUTHOR π«Ά
- Matt Sergeant,
matt@sergeant.org - Tobias Brox,
tobiasb@tobiasb.funcom.com - BalΓ‘zs SzabΓ³ (dLux),
dlux@kapu.hu
icons, all of them π
π COPYRIGHT AND LICENSE π
Copyright 2001, Larry Wall.
This module is free software, you may distribute it under the same terms as Perl. π
π Bugs π
Currently the methods aren't as efficient as they could be, for reasons of clarity. This is probably a bad idea. π (not me reading that and going "bestie... why" β but it's in the docs, so it stays, periodt)
and that's the whole page! π this tea was served up in perl v5.42.3, dated 2026-11-03, in Time::Seconds(3pm) β k byeee, go convert some seconds π
π¦ where this page comes from
- alpine 3.24: perl-doc 5.42.3-r0 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms