diff options
author | Andy Dougherty <doughera.lafayette.edu> | 1995-12-21 00:01:16 +0000 |
---|---|---|
committer | Andy Dougherty <doughera.lafayette.edu> | 1995-12-21 00:01:16 +0000 |
commit | cb1a09d0194fed9b905df7b04a4bc031d354609d (patch) | |
tree | f0c890a5a8f5274873421ac573dfc719188e5eec /lib/Time/Local.pm | |
parent | 3712091946b37b5feabcc1f630b32639406ad717 (diff) | |
download | perl-cb1a09d0194fed9b905df7b04a4bc031d354609d.tar.gz |
This is patch.2b1g to perl5.002beta1.
cd to your perl source directory, and type
patch -p1 -N < patch.2b1g
This patch is just my packaging of Tom's documentation patches
he released as patch.2b1g.
Patch and enjoy,
Andy Dougherty doughera@lafcol.lafayette.edu
Dept. of Physics
Lafayette College, Easton PA 18042
Diffstat (limited to 'lib/Time/Local.pm')
-rw-r--r-- | lib/Time/Local.pm | 57 |
1 files changed, 32 insertions, 25 deletions
diff --git a/lib/Time/Local.pm b/lib/Time/Local.pm index 64e62405f7..451c7fa20c 100644 --- a/lib/Time/Local.pm +++ b/lib/Time/Local.pm @@ -6,31 +6,38 @@ use Carp; @ISA = qw(Exporter); @EXPORT = qw(timegm timelocal); -# timelocal.pl -# -# Usage: -# $time = timelocal($sec,$min,$hours,$mday,$mon,$year); -# $time = timegm($sec,$min,$hours,$mday,$mon,$year); - -# These routines are quite efficient and yet are always guaranteed to agree -# with localtime() and gmtime(). We manage this by caching the start times -# of any months we've seen before. If we know the start time of the month, -# we can always calculate any time within the month. The start times -# themselves are guessed by successive approximation starting at the -# current time, since most dates seen in practice are close to the -# current date. Unlike algorithms that do a binary search (calling gmtime -# once for each bit of the time value, resulting in 32 calls), this algorithm -# calls it at most 6 times, and usually only once or twice. If you hit -# the month cache, of course, it doesn't call it at all. - -# timelocal is implemented using the same cache. We just assume that we're -# translating a GMT time, and then fudge it when we're done for the timezone -# and daylight savings arguments. The timezone is determined by examining -# the result of localtime(0) when the package is initialized. The daylight -# savings offset is currently assumed to be one hour. - -# Both routines return -1 if the integer limit is hit. I.e. for dates -# after the 1st of January, 2038 on most machines. +=head1 NAME + +Time::Local - efficiently compute tome from local and GMT time + +=head1 SYNOPSIS + + $time = timelocal($sec,$min,$hours,$mday,$mon,$year); + $time = timegm($sec,$min,$hours,$mday,$mon,$year); + +=head1 DESCRIPTION + +These routines are quite efficient and yet are always guaranteed to agree +with localtime() and gmtime(). We manage this by caching the start times +of any months we've seen before. If we know the start time of the month, +we can always calculate any time within the month. The start times +themselves are guessed by successive approximation starting at the +current time, since most dates seen in practice are close to the +current date. Unlike algorithms that do a binary search (calling gmtime +once for each bit of the time value, resulting in 32 calls), this algorithm +calls it at most 6 times, and usually only once or twice. If you hit +the month cache, of course, it doesn't call it at all. + +timelocal is implemented using the same cache. We just assume that we're +translating a GMT time, and then fudge it when we're done for the timezone +and daylight savings arguments. The timezone is determined by examining +the result of localtime(0) when the package is initialized. The daylight +savings offset is currently assumed to be one hour. + +Both routines return -1 if the integer limit is hit. I.e. for dates +after the 1st of January, 2038 on most machines. + +=cut @epoch = localtime(0); $tzmin = $epoch[2] * 60 + $epoch[1]; # minutes east of GMT |