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
55 The methods make the assumption that there are 24 hours in a day, 7
56 days in a week, 365.24225 days in a year and 12 months in a year.
57 (from The Calendar FAQ at http://www.tondering.dk/claus/calendar.html)
58
60 Matt Sergeant, matt@sergeant.org
61
62 Tobias Brox, tobiasb@tobiasb.funcom.com
63
64 BalieXXzs SzabieXX (dLux), dlux@kapu.hu
65
67 Please see Time::Piece for the license.
68
70 Currently the methods aren't as efficient as they could be, for reasons
71 of clarity. This is probably a bad idea.
72
73
74
75perl v5.10.1 2009-04-14 Time::Seconds(3pm)