Time::Seconds(3perl)
โจ Time::Seconds โจ
okay bestie, gather round ๐ซถ this is the manual page for Time::Seconds(3perl) โ a super simple API that turns seconds into other date values. like, seconds in, days out. it's giving math but make it cute ๐
๐ธ SYNOPSIS ๐ธ
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";
look at that. ONE_DAY. adding it like it's nothing. iconic behavior honestly โจ
๐ DESCRIPTION ๐
so this module is part of the Time::Piece distribution, right? it lets you figure out how many minutes, hours, days, weeks or years are hiding inside a given number of seconds. and here's the slay part: Time::Piece hands you one of these objects automatically when you subtract two Time::Piece objects from each other. delta them, get seconds, boom ๐ฅ
Time::Seconds also exports these constants, no cap:
ONE_DAY
ONE_WEEK
ONE_HOUR
ONE_MINUTE
ONE_MONTH
ONE_YEAR
ONE_FINANCIAL_MONTH
LEAP_YEAR
NON_LEAP_YEAR
โ ๏ธ okay important, don't get got: since perl does not (yet?) support constant objects, these constants are in seconds only. so you literally cannot do this: print ONE_WEEK->minutes; likeโฆ the object isn't there, bestie ๐ญ the number is. that's it.
๐ METHODS ๐
here's the whole lineup, every single one:
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. go off, do math ๐งฎโจ
and now the fine print, because the vibes need โจaccuracyโจ: these methods make the assumption that there are:
- 24 hours in a day
- 7 days in a week
- 365.24225 days in a year
- 12 months in a year
(that's straight from The Calendar FAQ at http://www.tondering.dk/claus/calendar.html โ sourcing, we love to see it ๐)
๐ฆ AUTHOR ๐ฆ
the legends who made this happen:
- Matt Sergeant, matt@sergeant.org
- Tobias Brox, tobiasb@tobiasb.funcom.com
- Balรกzs Szabรณ (dLux), dlux@kapu.hu
๐ COPYRIGHT AND LICENSE ๐
Copyright 2001, Larry Wall.
this module is free software, and you may distribute it under the same terms as Perl. periodt ๐
๐ Bugs ๐
ngl, currently the methods aren't as efficient as they could be โ and the reason is clarity. which, per the original, is probably a bad idea. ๐ญ we respect the honesty tho ๐โจ
and that's the whole page, bestie!! this was Time::Seconds(3perl), from perl v5.44.0, dated 2026-10-17 ๐ go convert some seconds, you absolute main character ๐๐
๐ฆ where this page comes from
- arch rolling: perl 5.44.0-1 ยท Artistic-1.0-Perl AND GPL-1.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms