Go to main content

man pages section 3: Library Interfaces and Headers

Exit Print View

Updated: Wednesday, July 27, 2022
 
 

Time::Seconds (3)

Name

Time::Seconds - a simple API to convert seconds to other date values

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

Description

Perl Programmers Reference Guide                              Time::Seconds(3)



NAME
       Time::Seconds - a simple API to convert seconds to other date values

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

DESCRIPTION
       This module is part of the Time::Piece distribution. It allows the user
       to find out the number of minutes, hours, days, weeks or years in a
       given number of seconds. It is returned by Time::Piece when you delta
       two Time::Piece objects.

       Time::Seconds also exports the following constants:

           ONE_DAY
           ONE_WEEK
           ONE_HOUR
           ONE_MINUTE
           ONE_MONTH
           ONE_YEAR
           ONE_FINANCIAL_MONTH
           LEAP_YEAR
           NON_LEAP_YEAR

       Since perl does not (yet?) support constant objects, these constants
       are in seconds only, so you cannot, for example, do this: "print
       ONE_WEEK->minutes;"

METHODS
       The following methods are available:

           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.

       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

       Balazs Szabo (dLux), dlux@kapu.hu

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.



ATTRIBUTES
       See attributes(7) for descriptions of the following attributes:


       +---------------+-----------------------+
       |ATTRIBUTE TYPE |   ATTRIBUTE VALUE     |
       +---------------+-----------------------+
       |Availability   | runtime/perl-532      |
       +---------------+-----------------------+
       |Stability      | Pass-through volatile |
       +---------------+-----------------------+

NOTES
       Source code for open source software components in Oracle Solaris can
       be found at https://www.oracle.com/downloads/opensource/solaris-source-
       code-downloads.html.

       This software was built from source available at
       https://github.com/oracle/solaris-userland.  The original community
       source was downloaded from
       http://www.cpan.org/src/5.0/perl-5.32.0.tar.gz.

       Further information about this software can be found on the open source
       community website at https://www.perl.org/.



perl v5.32.0                      2020-06-14                  Time::Seconds(3)