4 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
11 @ISA = qw(Exporter DynaLoader);
23 ':override' => 'internal',
28 bootstrap Time::Piece $VERSION;
32 my @MON_NAMES = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
33 my @WDAY_NAMES = qw(Sun Mon Tue Wed Thu Fri Sat);
34 my @MONTH_NAMES = qw(January February March April May June
35 July August September October Novemeber December);
36 my @WEEKDAY_NAMES = qw(Sunday Monday Tuesday Wednesday
37 Thursday Friday Saturday);
39 use constant 'c_sec' => 0;
40 use constant 'c_min' => 1;
41 use constant 'c_hour' => 2;
42 use constant 'c_mday' => 3;
43 use constant 'c_mon' => 4;
44 use constant 'c_year' => 5;
45 use constant 'c_wday' => 6;
46 use constant 'c_yday' => 7;
47 use constant 'c_isdst' => 8;
48 use constant 'c_epoch' => 9;
49 use constant 'c_islocal' => 10;
53 $time = time if (!defined $time);
59 $time = time if (!defined $time);
65 my $class = ref($proto) || $proto;
71 $self = &localtime($time);
73 elsif (ref($proto) && $proto->isa('Time::Piece')) {
74 $self = _mktime($proto->[c_epoch], $proto->[c_islocal]);
80 return bless $self, $class;
84 my ($time, $islocal) = @_;
86 CORE::localtime($time)
89 wantarray ? @time : bless [@time, $time, $islocal], 'Time::Piece';
93 # replace CORE::GLOBAL localtime and gmtime if required
96 map($params{$_}++,@_,@EXPORT);
97 if (delete $params{':override'}) {
98 $class->export('CORE::GLOBAL', keys %params);
101 $class->export((caller)[0], keys %params);
155 return $_[$time->[c_mon]];
157 elsif ($time->has_mon_names) {
158 return $time->mon_name($time->[c_mon]);
160 return $MON_NAMES[$time->[c_mon]];
163 sub has_month_names {
171 return $_[$time->[c_mon]];
173 elsif ($time->has_month_names) {
174 return $time->month_name($time->[c_mon]);
176 return $MONTH_NAMES[$time->[c_mon]];
179 *month = \&monthname;
183 $time->[c_year] + 1900;
203 *day_of_week = \&_wday;
213 return $_[$time->[c_wday]];
215 elsif ($time->has_wday_names) {
216 return $time->wday_name($time->[c_mon]);
218 return $WDAY_NAMES[$time->[c_wday]];
221 sub has_weekday_names {
229 return $_[$time->[c_wday]];
231 elsif ($time->has_weekday_names) {
232 return $time->weekday_name($time->[c_mon]);
234 return $WEEKDAY_NAMES[$time->[c_wday]];
237 *weekdayname = \&weekdayname;
238 *weekday = \&weekdayname;
245 *day_of_year = \&yday;
252 *daylight_savings = \&isdst;
254 # Thanks to Tony Olekshy <olekshy@cs.ualberta.ca> for this algorithm
258 my $epoch = $time->[c_epoch];
260 my $j = sub { # Tweaked Julian day number algorithm.
262 my ($s,$n,$h,$d,$m,$y) = @_; $m += 1; $y += 1900;
264 # Standard Julian day number algorithm without constant.
266 my $y1 = $m > 2 ? $y : $y - 1;
268 my $m1 = $m > 2 ? $m + 1 : $m + 13;
270 my $day = int(365.25 * $y1) + int(30.6001 * $m1) + $d;
272 # Modify to include hours/mins/secs in floating portion.
274 return $day + ($h + ($n + $s / 60) / 60) / 24;
277 # Compute floating offset in hours.
279 my $delta = 24 * (&$j(CORE::localtime $epoch) - &$j(CORE::gmtime $epoch));
281 # Return value in seconds rounded to nearest minute.
282 return Time::Seconds->new( int($delta * 60 + ($delta >= 0 ? 0.5 : -0.5)) * 60);
292 my $sep = @_ ? shift(@_) : $TIME_SEP;
293 sprintf("%02d$sep%02d$sep%02d", $time->[c_hour], $time->[c_min], $time->[c_sec]);
300 my $sep = @_ ? shift(@_) : $DATE_SEP;
301 sprintf("%d$sep%02d$sep%02d", $time->year, $time->mon, $time->[c_mday]);
308 my $sep = @_ ? shift(@_) : $DATE_SEP;
309 sprintf("%02d$sep%02d$sep%d", $time->mon, $time->[c_mday], $time->year);
314 my $sep = @_ ? shift(@_) : $DATE_SEP;
315 sprintf("%02d$sep%02d$sep%d", $time->[c_mday], $time->mon, $time->year);
320 my %seps = (date => $DATE_SEP, T => 'T', time => $TIME_SEP, @_);
321 return join($seps{T}, $time->date($seps{date}), $time->time($seps{time}));
324 # taken from Time::JulianDay
327 my ($year, $month, $day) = ($time->year, $time->mon, $time->mday);
331 + 1461 * ( $year + 4800 - ( 14 - $month ) / 12 )/4
332 + 367 * ( $month - 2 + ( ( 14 - $month ) / 12 ) * 12 ) / 12
333 - 3 * ( ( $year + 4900 - ( 14 - $month ) / 12 ) / 100 ) / 4
341 return shift->julian_day - 2_400_000.5;
345 # taken from the Calendar FAQ
347 my $J = shift->julian_day;
348 my $d4 = ((($J + 31741 - ($J % 7)) % 146097) % 36524) % 1461;
350 my $d1 = (($d4 - $L) % 365) + $L;
356 return (($year %4 == 0) && !($year % 100 == 0)) || ($year % 400 == 0)
362 my $year = $time->year;
363 return _is_leap_year($year);
366 my @MON_LAST = qw(31 28 31 30 31 30 31 31 30 31 30 31);
370 my $year = $time->year;
371 my $_mon = $time->_mon;
372 return $MON_LAST[$_mon] + ($_mon == 1 ? _is_leap_year($year) : 0);
375 use vars qw($_ftime);
383 my ($format, $time) = @_;
387 my ($format, $time) = @_;
388 $time->weekdayname();
391 my ($format, $time) = @_;
395 my ($format, $time) = @_;
399 my ($format, $time) = @_;
403 my ($format, $time) = @_;
404 sprintf("%02d", int($time->y() / 100));
407 my ($format, $time) = @_;
408 sprintf("%02d", $time->d());
411 my ($format, $time) = @_;
413 $_ftime->{'m'}->('m', $time),
414 $_ftime->{'d'}->('d', $time),
415 $_ftime->{'y'}->('y', $time));
418 my ($format, $time) = @_;
419 sprintf("%2d", $time->d());
422 my ($format, $time, @rest) = @_;
423 $time->monname(@rest);
426 my ($format, $time) = @_;
427 sprintf("%02d", $time->h());
430 my ($format, $time) = @_;
432 sprintf("%02d", $h == 0 ? 12 : ($h < 13 ? $h : $h % 12));
435 my ($format, $time) = @_;
436 sprintf("%03d", $time->yday());
439 my ($format, $time) = @_;
440 sprintf("%02d", $time->mon());
443 my ($format, $time) = @_;
444 sprintf("%02d", $time->min());
450 my ($format, $time) = @_;
452 $h == 0 ? 'pm' : ($h < 13 ? 'am' : 'pm');
455 my ($format, $time) = @_;
457 $_ftime->{'I'}->('I', $time),
458 $_ftime->{'M'}->('M', $time),
459 $_ftime->{'S'}->('S', $time)) .
460 " " . $_ftime->{'p'}->('p', $time);
463 my ($format, $time) = @_;
465 $_ftime->{'H'}->('H', $time),
466 $_ftime->{'M'}->('M', $time));
469 my ($format, $time) = @_;
470 sprintf("%02d", $time->s());
476 my ($format, $time) = @_;
478 $_ftime->{'H'}->('H', $time),
479 $_ftime->{'M'}->('M', $time),
480 $_ftime->{'S'}->('S', $time));
483 my ($format, $time) = @_;
484 ($time->wday() + 5) % 7 + 1;
486 # U taken care by libc
488 my ($format, $time) = @_;
489 sprintf("%02d", $time->week());
492 my ($format, $time) = @_;
495 # W taken care by libc
497 my ($format, $time) = @_;
499 $_ftime->{'m'}->('m', $time),
500 $_ftime->{'d'}->('d', $time),
501 $_ftime->{'y'}->('y', $time));
504 my ($format, $time) = @_;
505 sprintf("%02d", $time->y() % 100);
508 my ($format, $time) = @_;
509 sprintf("%4d", $time->y());
511 # Z taken care by libc
516 exists $_ftime->{$format};
524 delete $_ftime->{@_};
528 my ($format) = $_[0];
530 return $_ftime->{$format};
532 if (ref $_[0] eq 'CODE') {
533 $_ftime->{$format} = $_[1];
536 Carp::croak "ftime: second argument not a code ref";
540 Carp::croak "ftime: want one or two arguments";
545 my ($format, $time, @rest) = @_;
546 if (has_ftime($format)) {
547 # We are passing format to the anonsubs so that
548 # one can share the same sub among several formats.
549 return $_ftime->{$format}->($format, $time, @rest);
551 # If we don't know it, pass it down to the libc layer.
552 # (In other words, cheat.)
553 # This pays for for '%Z', though, and for all the
554 # locale-specific %Ex and %Oy formats.
555 return $time->_strftime("%$format");
560 my $format = @_ ? shift(@_) : "%a, %d %b %Y %H:%M:%S %Z";
561 $format =~ s/%(.)/_ftime($1, $time, @_)/ge;
567 my $format = @_ ? shift(@_) : "%a, %d %b %Y %H:%M:%S %Z";
568 return __strftime($format, (@$time)[c_sec..c_isdst]);
571 use vars qw($_ptime);
576 $_[1] =~ s/^%// && $1;
584 $_[1] =~ s/^(0[0-9])// && $1;
587 $_[1] =~ s/^(0[1-9]|2[0-9]|3[01])// && $1;
592 if (defined ($D = $_ptime->{'m'}->($_[0], $_[1]))) {
597 $_[1] =~ s:^/:: || return;
598 if (defined ($D = $_ptime->{'d'}->($_[0], $_[1]))) {
603 $_[1] =~ s:^/:: || return;
604 if (defined ($D = $_ptime->{'y'}->($_[0], $_[1]))) {
612 $_[1] =~ s/^( [1-9]|2[0-9]|3[01])// && $1;
616 $_[1] =~ s/^([0-1][0-9]|2[0-3])// && $1;
619 $_[1] =~ s/^(0[1-9]|1[012])// && $1;
622 $_[1] =~ s/^([0-9][0-9][0-9])// && $1 >= 1 && $1 <= 366 && $1;
625 $_[1] =~ s/^(0[1-9]|1[012])// && $1;
628 $_[1] =~ s/^([0-5][0-9])// && $1;
631 $_[1] =~ s/^\n// && $1;
634 $_[1] =~ s/^(am|pm)// && $1;
639 if (defined ($r = $_ptime->{'I'}->($_[0], $_[1]))) {
644 $_[1] =~ s/^:// || return;
645 if (defined ($r = $_ptime->{'M'}->($_[0], $_[1]))) {
650 $_[1] =~ s/^:// || return;
651 if (defined ($r = $_ptime->{'S'}->($_[0], $_[1]))) {
656 $_[1] =~ s/^ // || return;
657 if (defined ($r = $_ptime->{'p'}->($_[0], $_[1]))) {
667 if (defined ($R = $_ptime->{'H'}->($_[0], $_[1]))) {
672 $_[1] =~ s/^:// || return;
673 if (defined ($R = $_ptime->{'M'}->($_[0], $_[1]))) {
681 $_[1] =~ s/^([0-5][0-9])// && $1;
684 $_[1] =~ s/^\t// && $1;
689 if (defined ($T = $_ptime->{'H'}->($_[0], $_[1]))) {
694 $_[1] =~ s/^:// || return;
695 if (defined ($T = $_ptime->{'M'}->($_[0], $_[1]))) {
700 $_[1] =~ s/^:// || return;
701 if (defined ($T = $_ptime->{'S'}->($_[0], $_[1]))) {
715 if (defined ($x = $_ptime->{'m'}->($_[0], $_[1]))) {
720 $_[1] =~ s:^/:: || return;
721 if (defined ($x = $_ptime->{'d'}->($_[0], $_[1]))) {
726 $_[1] =~ s:^/:: || return;
727 if (defined ($x = $_ptime->{'y'}->($_[0], $_[1]))) {
735 $_[1] =~ s/^([0-9][0-9])// && $1;
738 $_[1] =~ s/^([1-9][0-9][0-9][0-9])// && $1;
745 exists $_ptime->{$format};
753 delete $_ptime->{@_};
757 my ($format) = $_[0];
759 return $_ptime->{$format};
761 if (ref $_[0] eq 'CODE') {
762 $_ptime->{$format} = $_[1];
765 Carp::croak "ptime: second argument not a code ref";
769 Carp::croak "ptime: want one or two arguments";
774 my ($format, $stime) = @_;
775 if (has_ptime($format)) {
776 # We are passing format to the anonsubs so that
777 # one can share the same sub among several formats.
778 return $_ptime->{$format}->($format, $_[1]);
780 die "strptime: unknown format %$format (time '$stime')\n";
788 while ($format ne '') {
789 if ($format =~ s/^([^%]+)//) {
791 last unless $stime =~ s/^\Q$skip//;
793 while ($format =~ s/^%(.)//) {
795 my $t = _ptime($f, $stime);
797 if (ref $t eq 'HASH') {
798 @ptime{keys %$t} = values %$t;
810 shift if ref($_[0]) && $_[0]->isa(__PACKAGE__); # strip first if called as a method
811 my @old = @WDAY_NAMES;
819 shift if ref($_[0]) && $_[0]->isa(__PACKAGE__); # strip first if called as a method
820 my @old = @WEEKDAY_NAMES;
828 shift if ref($_[0]) && $_[0]->isa(__PACKAGE__); # strip first if called as a method
829 my @old = @MON_NAMES;
837 shift if ref($_[0]) && $_[0]->isa(__PACKAGE__); # strip first if called as a method
838 my @old = @MONTH_NAMES;
846 shift if ref($_[0]) && $_[0]->isa(__PACKAGE__);
855 shift if ref($_[0]) && $_[0]->isa(__PACKAGE__);
863 use overload '""' => \&cdate;
867 if ($time->[c_islocal]) {
868 return scalar(CORE::localtime($time->[c_epoch]));
871 return scalar(CORE::gmtime($time->[c_epoch]));
882 die "Can't subtract a date from something!" if shift;
884 if (ref($rhs) && $rhs->isa('Time::Piece')) {
885 return Time::Seconds->new($time->[c_epoch] - $rhs->epoch);
889 return _mktime(($time->[c_epoch] - $rhs), $time->[c_islocal]);
897 croak "Invalid rhs of addition: $rhs" if ref($rhs);
899 return _mktime(($time->[c_epoch] + $rhs), $time->[c_islocal]);
906 my ($time, $rhs, $reverse) = @_;
907 $time = $time->epoch;
908 if (UNIVERSAL::isa($rhs, 'Time::Piece')) {
918 my ($lhs, $rhs) = get_epochs(@_);
919 return $lhs <=> $rhs;
927 Time::Piece - Object Oriented time objects
934 print "Time is $t\n";
935 print "Year is ", $t->year, "\n";
939 This module replaces the standard localtime and gmtime functions with
940 implementations that return objects. It does so in a backwards
941 compatible manner, so that using localtime/gmtime in the way documented
942 in perlfunc will still return what you expect.
944 The module actually implements most of an interface described by
945 Larry Wall on the perl5-porters mailing list here:
946 http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2000-01/msg00241.html
950 After importing this module, when you use localtime(0 or gmtime() in
951 scalar context, rather than getting an ordinary scalar string
952 representing the date and time, you get a Time::Piece object, whose
953 stringification happens to produce the same effect as the localtime()
954 and gmtime(0 functions.
956 There is also a new() constructor provided, which is the same as
957 localtime(), except when passed a Time::Piece object, in which case
958 it's a copy constructor.
960 The following methods are available on the object:
963 # 60 and 61: leap second and double leap second
964 $t->sec # same as $t->s
965 $t->second # same as $t->s
968 $t->hour # same as $t->h
970 $t->mday # same as $t->d
971 $t->mon # 1 = January
972 $t->_mon # 0 = January
974 $t->monthname # February
975 $t->month # same as $t->monthname
976 $t->y # based at 0 (year 0 AD is, of course 1 BC)
977 $t->year # same as $t->y
978 $t->_year # year minus 1900
979 $t->wday # 1 = Sunday
980 $t->day_of_week # 0 = Sunday
981 $t->_wday # 0 = Sunday
983 $t->weekdayname # Tuesday
984 $t->weekday # same as weekdayname
985 $t->yday # also available as $t->day_of_year, 0 = Jan 01
986 $t->isdst # also available as $t->daylight_savings
987 $t->daylight_savings # same as $t->isdst
990 $t->hms(".") # 12.34.56
991 $t->time # same as $t->hms
994 $t->date # same as $t->ymd
996 $t->mdy("/") # 02/29/2000
998 $t->dmy(".") # 29.02.2000
999 $t->datetime # 2000-02-29T12:34:56 (ISO 8601)
1000 $t->cdate # Tue Feb 29 12:34:56 2000
1001 "$t" # same as $t->cdate
1003 $t->epoch # seconds since the epoch
1004 $t->tzoffset # timezone offset in a Time::Seconds object
1006 $t->julian_day # number of days since Julian period began
1007 $t->mjd # modified Julian day
1009 $t->week # week number (ISO 8601)
1011 $t->is_leap_year # true if it its
1012 Time::Piece::_is_leap_year($year) # true if it its
1013 $t->month_last_day # 28..31
1015 $t->time_separator($s) # set the default separator (default ":")
1016 $t->date_separator($s) # set the default separator (default "-")
1017 $t->wday_names(@days) # set the default weekday names, abbreviated
1018 $t->weekday_names(@days) # set the default weekday names
1019 $t->mon_names(@days) # set the default month names, abbreviated
1020 $t->month_names(@days) # set the default month names
1022 $t->strftime($format) # date and time formatting
1023 $t->strftime() # "Tue, 29 Feb 2000 12:34:56 GMT"
1025 $t->_strftime($format) # same as POSIX::strftime (without the
1026 # overhead of the full POSIX extension),
1027 # calls the operating system libraries,
1028 # as opposed to $t->strftime()
1030 use Time::Piece 'strptime'; # date parsing
1031 my %p = strptime("%H:%M", "12:34"); # $p{H} and ${M} will be set
1033 =head2 Local Locales
1035 Both wdayname (day) and monname (month) allow passing in a list to use
1036 to index the name of the days against. This can be useful if you need
1037 to implement some form of localisation without actually installing or
1038 using the locales provided by the operating system.
1040 my @weekdays = qw( Dimanche Lundi Merdi Mercredi Jeudi Vendredi Samedi );
1042 my $french_day = localtime->day(@weekdays);
1044 These settings can be overriden globally too:
1046 Time::Piece::weekday_names(@weekdays);
1047 Time::Piece::wday_names(@wdays);
1051 Time::Piece::month_names(@months);
1052 Time::Piece::mon_names(@mon);
1054 And locally for months:
1056 print localtime->month(@months);
1058 =head2 Date Calculations
1060 It's possible to use simple addition and subtraction of objects:
1064 my $seconds = $t1 - $t2;
1065 $t1 += ONE_DAY; # add 1 day (constant from Time::Seconds)
1067 The following are valid ($t1 and $t2 are Time::Piece objects):
1069 $t1 - $t2; # returns Time::Seconds object
1070 $t1 - 42; # returns Time::Piece object
1071 $t1 + 533; # returns Time::Piece object
1073 However adding a Time::Piece object to another Time::Piece object
1074 will cause a runtime error.
1076 Note that the first of the above returns a Time::Seconds object, so
1077 while examining the object will print the number of seconds (because
1078 of the overloading), you can also get the number of minutes, hours,
1079 days, weeks and years in that delta, using the Time::Seconds API.
1081 =head2 Date Comparisons
1083 Date comparisons are also possible, using the full suite of "<", ">",
1084 "<=", ">=", "<=>", "==" and "!=".
1086 =head2 YYYY-MM-DDThh:mm:ss
1088 The ISO 8601 standard defines the date format to be YYYY-MM-DD, and
1089 the time format to be hh:mm:ss (24 hour clock), and if combined, they
1090 should be concatenated with the date first and with a capital 'T' in
1095 The I<week number> may be an unknown concept to some readers. The ISO
1096 8601 standard defines that weeks begin on a Monday and week 1 of the
1097 year is the week that includes both January the 4th and the first
1098 Thursday of the year. In other words, if the first Monday of January
1099 is the 2nd, 3rd, or 4th, the preceding days of the January are part of
1100 the last week of the preceding year. Week numbers range from 1 to 53.
1102 =head2 strftime method
1104 The strftime() method can be used to format Time::Piece objects for output.
1105 The argument to strftime() is the format string to be used, for example:
1107 $t->strftime("%H:%M");
1109 will output the hours and minutes concatenated with a colon. The
1110 available format characters are as in the standard strftime() function
1111 (unless otherwise indicated the implementation is in pure Perl,
1112 no operating system strftime() is invoked):
1118 The percentage character "%".
1122 The abbreviated weekday name, e.g. 'Tue'. Note that the abbreviations
1123 are not necessarily three characters wide in all languages.
1127 The weekday name, e.g. 'Tuesday'.
1131 The abbreviated month name, e.g. 'Feb'. Note that the abbreviations
1132 are not necessarily three characters wide in all languages.
1136 The month name, e.g. 'February'.
1140 The ctime format, or the localtime()/gmtime() format: C<%a %b %m %H:%M:%S %Y>.
1142 (Should be avoided: use $t->timedate instead.)
1146 The 'centuries' number, e.g. 19 for the year 1999 and 20 for the year 2000.
1150 The zero-filled right-aligned day of the month, e.g. '09' or '10'.
1156 (Should be avoided: use $t->date instead.)
1160 The space-filled right-aligned day of the month, e.g. ' 9' or '10'.
1164 Same as C<%b>, the abbreviated monthname.
1168 The zero-filled right-aligned hours in 24 hour clock, e.g. '09' or '10'.
1172 The zero-filled right-aligned hours in 12 hour clock, e.g. '09' or '10'.
1176 The zero-filled right-aligned day of the year, e.g. '001' or '365'.
1180 The zero-filled right-aligned month number, e.g. '09' or '10'.
1184 The zero-filled right-aligned minutes, e.g. '09' or '10'.
1188 The newline character "\n".
1192 Notice that this is somewhat meaningless in 24 hour clocks.
1198 (Should be avoided: use $t->time instead.)
1206 The zero-filled right-aligned seconds, e.g. '09' or '10'.
1210 The tabulator character "\t".
1216 (Should be avoided: use $t->time instead.)
1220 The day of the week with Monday as 1 (one) and Sunday as 7.
1224 The zero-filled right-aligned week number of the year, Sunday as the
1225 first day of the week, from '00' to '53'.
1227 (Currently taken care by the operating system strftime().)
1231 The zero-filled right-aligned week of the year, e.g. '01' or '53'.
1236 The day of the week with Sunday as 0 (zero) and Monday as 1 (one).
1240 The zero-filled right-aligned week number of the year, Monday as the
1241 first day of the week, from '00' to '53'.
1243 (Currently taken care by the operating system strftime().)
1249 (Should be avoided: use $t->date instead.)
1253 The zero-filled right-aligned last two numbers of the year, e.g. 99
1254 for 1999 and 01 for 2001.
1256 (Should be avoided: this is the Y2K bug alive and well.)
1260 The year, e.g. 1999 or 2001.
1264 The timezone name, for example "GMT" or "EET".
1266 (Taken care by the operating system strftime().)
1270 The format C<Z> and any of the C<O*> and C<E*> formats are handled by
1271 the operating system, not by Time::Piece, because those formats are
1272 usually rather unportable and non-standard. (For example 'MST' can
1273 mean almost anything: 'Mountain Standard Time' or 'Moscow Standard Time'.)
1275 =head2 strptime function
1277 You can export the strptime() function and use it to parse date and
1278 time strings back to numbers. For example the following will return
1279 the hours, minutes, and seconds as $parse{H}, $parse{M}, and $parse{S}.
1281 use Time::Piece 'strptime';
1282 my %parse = strptime('%H:%M:S', '12:34:56');
1284 For 'compound' formats like for example 'T' strptime() will return
1287 strptime() does not perform overly strict checks on the dates and
1288 times, it will be perfectly happy with the 31st day of February,
1289 for example. Stricter validation should be performed by other means.
1291 =head2 Global Overriding
1293 Finally, it's possible to override localtime and gmtime everywhere, by
1294 including the ':override' tag in the import list:
1296 use Time::Piece ':override';
1300 The excellent Calendar FAQ at L<http://www.tondering.dk/claus/calendar.html>
1302 If you just want an object-oriented interface to the usual time
1303 functions see L<Time::localtime> and L<Time::gmtime> which are part
1304 of the standard distribution. Beware, though, that their fields are as
1305 in the C library: the I<year> is I<year-1900> (like $t->_year in Time::Piece)
1306 and I<months> begin from zero (like $t->_mon).
1308 L<strftime(3)>, L<strftime(3)>
1312 Matt Sergeant, matt@sergeant.org
1314 This module is based on Time::Object, with changes suggested by Jarkko
1315 Hietaniemi before including in core perl.
1319 This module is free software, you may distribute it under the same terms
1324 The test harness leaves much to be desired. Patches welcome.