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 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