From: Gabor Szabo Date: Thu, 27 Jul 2006 09:25:02 +0000 (+0300) Subject: perlfunc.pod - unite gmtime and localtime X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=435fbc73c32c7bd8a6a0cdb8a1ea0ca077918585;p=p5sagit%2Fp5-mst-13.2.git perlfunc.pod - unite gmtime and localtime From: "Gabor Szabo" Message-ID: p4raw-id: //depot/perl@28661 --- diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index adc832c..ebf107f 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -2317,49 +2317,12 @@ X X X =item gmtime -Converts a time as returned by the time function to an 9-element list -with the time localized for the standard Greenwich time zone. -Typically used as follows: +Works just like L but the returned values are +localized for the standard Greenwich time zone. - # 0 1 2 3 4 5 6 7 8 - ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = - gmtime(time); - -All list elements are numeric, and come straight out of the C `struct -tm'. $sec, $min, and $hour are the seconds, minutes, and hours of the -specified time. $mday is the day of the month, and $mon is the month -itself, in the range C<0..11> with 0 indicating January and 11 -indicating December. $year is the number of years since 1900. That -is, $year is C<123> in year 2023. $wday is the day of the week, with -0 indicating Sunday and 3 indicating Wednesday. $yday is the day of -the year, in the range C<0..364> (or C<0..365> in leap years). $isdst -is always C<0>. - -Note that the $year element is I simply the last two digits of -the year. If you assume it is then you create non-Y2K-compliant -programs--and you wouldn't want to do that, would you? - -The proper way to get a complete 4-digit year is simply: - - $year += 1900; - -And to get the last two digits of the year (e.g., '01' in 2001) do: - - $year = sprintf("%02d", $year % 100); - -If EXPR is omitted, C uses the current time (C). - -In scalar context, C returns the ctime(3) value: - - $now_string = gmtime; # e.g., "Thu Oct 13 04:54:34 1994" - -If you need local time instead of GMT use the L builtin. -See also the C function provided by the C module, -and the strftime(3) and mktime(3) functions available via the L module. - -This scalar value is B locale dependent (see L), but is -instead a Perl builtin. To get somewhat similar but locale dependent date -strings, see the example in L. +Note: when called in list context, $isdst, the last value +returned by gmtime is always C<0>. There is no +Daylight Saving Time in GMT. See L for portability concerns. @@ -2717,7 +2680,7 @@ be placed in parentheses. See L for details, including issues with tied arrays and hashes. =item localtime EXPR -X +X X =item localtime @@ -2747,6 +2710,9 @@ to get a complete 4-digit year is simply: $year += 1900; +Otherwise you create non-Y2K-compliant programs--and you wouldn't want +to do that, would you? + To get the last two digits of the year (e.g., '01' in 2001) do: $year = sprintf("%02d", $year % 100); @@ -2784,6 +2750,13 @@ and the month of the year, may not necessarily be three characters wide. See L for portability concerns. +The L and L modules provides a convenient, +by-name access mechanism to the gmtime() and localtime() functions, +respectively. + +For a comprehensive date and time representation look at the +L module on CPAN. + =item lock THING X @@ -5841,7 +5814,7 @@ for a seed can fall prey to the mathematical property that one-third of the time. So don't do that. =item stat FILEHANDLE -X X +X X X =item stat EXPR @@ -6542,11 +6515,15 @@ a prominent exception being Mac OS Classic which uses 00:00:00, January 1, 1904 in the current local time zone for its epoch. For measuring time in better granularity than one second, -you may use either the Time::HiRes module (from CPAN, and starting from +you may use either the L module (from CPAN, and starting from Perl 5.8 part of the standard distribution), or if you have gettimeofday(2), you may be able to use the C interface of Perl. See L for details. +For date and time processing look at the many related modules on CPAN. +For a comprehensive date and time representation look at the +L module. + =item times X