1Time::Seconds(3pm) Perl Programmers Reference Guide Time::Seconds(3pm)
2
3
4
6 Time::Seconds - a simple API to convert seconds to other date values
7
9 use Time::Piece;
10 use Time::Seconds;
11
12 my $t = localtime;
13 $t += ONE_DAY;
14
15 my $t2 = localtime;
16 my $s = $t - $t2;
17
18 print "Difference is: ", $s->days, "\n";
19
21 This module is part of the Time::Piece distribution. It allows the user
22 to find out the number of minutes, hours, days, weeks or years in a
23 given number of seconds. It is returned by Time::Piece when you delta
24 two Time::Piece objects.
25
26 Time::Seconds also exports the following constants:
27
28 ONE_DAY
29 ONE_WEEK
30 ONE_HOUR
31 ONE_MINUTE
32 ONE_MONTH
33 ONE_YEAR
34 ONE_FINANCIAL_MONTH
35 LEAP_YEAR
36 NON_LEAP_YEAR
37
38 Since perl does not (yet?) support constant objects, these constants
39 are in seconds only, so you cannot, for example, do this: "print
40 ONE_WEEK->minutes;"
41
43 The following methods are available:
44
45 my $val = Time::Seconds->new(SECONDS)
46 $val->seconds;
47 $val->minutes;
48 $val->hours;
49 $val->days;
50 $val->weeks;
51 $val->months;
52 $val->financial_months; # 30 days
53 $val->years;
54 $val->pretty; # gives English representation of the delta
55
56 The usual arithmetic (+,-,+=,-=) is also available on the objects.
57
58 The methods make the assumption that there are 24 hours in a day, 7
59 days in a week, 365.24225 days in a year and 12 months in a year.
60 (from The Calendar FAQ at http://www.tondering.dk/claus/calendar.html)
61
63 Matt Sergeant, matt@sergeant.org
64
65 Tobias Brox, tobiasb@tobiasb.funcom.com
66
67 BalieXXzs SzabieXX (dLux), dlux@kapu.hu
68
70 Please see Time::Piece for the license.
71
73 Currently the methods aren't as efficient as they could be, for reasons
74 of clarity. This is probably a bad idea.
75
76
77
78perl v5.16.3 2013-03-04 Time::Seconds(3pm)