diff options
author | Karl Berry <karl@freefriends.org> | 2015-04-26 22:16:26 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2015-04-26 22:16:26 +0000 |
commit | 342e672574c4e67d510e46ab6acd0e21a7d0cf54 (patch) | |
tree | 79e04202d08c0404bbd780bd26c1e34710e539b6 /Master/tlpkg/tlperl/lib/Time | |
parent | be2706af7c57a0ef0f4d4e9f684ca4ef74922a82 (diff) |
(tl)perl 5.20.2 for windows, from siep
git-svn-id: svn://tug.org/texlive/trunk@37064 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/tlperl/lib/Time')
-rw-r--r-- | Master/tlpkg/tlperl/lib/Time/HiRes.pm | 29 | ||||
-rw-r--r-- | Master/tlpkg/tlperl/lib/Time/Piece.pm | 17 | ||||
-rw-r--r-- | Master/tlpkg/tlperl/lib/Time/Seconds.pm | 17 | ||||
-rw-r--r-- | Master/tlpkg/tlperl/lib/Time/Zone.pm | 291 |
4 files changed, 334 insertions, 20 deletions
diff --git a/Master/tlpkg/tlperl/lib/Time/HiRes.pm b/Master/tlpkg/tlperl/lib/Time/HiRes.pm index 5223ba99e96..cf64bc1fbba 100644 --- a/Master/tlpkg/tlperl/lib/Time/HiRes.pm +++ b/Master/tlpkg/tlperl/lib/Time/HiRes.pm @@ -20,10 +20,10 @@ our @EXPORT_OK = qw (usleep sleep ualarm alarm gettimeofday time tv_interval d_usleep d_ualarm d_gettimeofday d_getitimer d_setitimer d_nanosleep d_clock_gettime d_clock_getres d_clock d_clock_nanosleep - stat + stat lstat ); -our $VERSION = '1.9725'; +our $VERSION = '1.9726'; our $XS_VERSION = $VERSION; $VERSION = eval $VERSION; @@ -87,7 +87,7 @@ Time::HiRes - High resolution alarm, sleep, gettimeofday, interval timers use Time::HiRes qw( usleep ualarm gettimeofday tv_interval nanosleep clock_gettime clock_getres clock_nanosleep clock - stat ); + stat lstat ); usleep ($microseconds); nanosleep ($nanoseconds); @@ -125,10 +125,11 @@ Time::HiRes - High resolution alarm, sleep, gettimeofday, interval timers my $ticktock = clock(); - use Time::HiRes qw( stat ); + use Time::HiRes qw( stat lstat ); my @stat = stat("file"); my @stat = stat(FH); + my @stat = lstat("file"); =head1 DESCRIPTION @@ -168,7 +169,7 @@ any clocks and timers will be imprecise, especially so if you are working in a pre-emptive multiuser system. Understand the difference between I<wallclock time> and process time (in UNIX-like systems the sum of I<user> and I<system> times). Any attempt to sleep for X seconds will -most probably end up sleeping B<more> than that, but don't be surpised +most probably end up sleeping B<more> than that, but don't be surprised if you end up sleeping slightly B<less>. The following functions can be imported from this module. @@ -302,7 +303,7 @@ C<$which> can be C<ITIMER_REAL>, C<ITIMER_VIRTUAL>, C<ITIMER_PROF>, or C<ITIMER_REALPROF>. Note that which ones are available depends: true UNIX platforms usually have the first three, but only Solaris seems to have C<ITIMER_REALPROF> (which is used to profile multithreaded programs). -Win32 unfortunately does not haveinterval timers. +Win32 unfortunately does not have interval timers. C<ITIMER_REAL> results in C<alarm()>-like behaviour. Time is counted in I<real time>; that is, wallclock time. C<SIGALRM> is delivered when @@ -392,7 +393,14 @@ compatibility limitations the returned value may wrap around at about =item stat EXPR -As L<perlfunc/stat> but with the access/modify/change file timestamps +=item lstat + +=item lstat FH + +=item lstat EXPR + +As L<perlfunc/stat> or L<perlfunc/lstat> +but with the access/modify/change file timestamps in subsecond resolution, if the operating system and the filesystem both support such timestamps. To override the standard stat(): @@ -406,7 +414,8 @@ UNIX filesystems often do; NTFS does; FAT doesn't (FAT timestamp granularity is B<two> seconds). A zero return value of &Time::HiRes::d_hires_stat means that -Time::HiRes::stat is a no-op passthrough for CORE::stat(), +Time::HiRes::stat is a no-op passthrough for CORE::stat() +(and likewise for lstat), and therefore the timestamps will stay integers. The same thing will happen if the filesystem does not do subsecond timestamps, even if the &Time::HiRes::d_hires_stat is non-zero. @@ -476,7 +485,7 @@ time stamp from t1: it may be equal or I<less>. use Time::HiRes qw( clock_gettime clock_getres CLOCK_REALTIME ); # Read the POSIX high resolution timer. - my $high = clock_getres(CLOCK_REALTIME); + my $high = clock_gettime(CLOCK_REALTIME); # But how accurate we can be, really? my $reso = clock_getres(CLOCK_REALTIME); @@ -586,7 +595,7 @@ Copyright (c) 1996-2002 Douglas E. Wegscheid. All rights reserved. Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Jarkko Hietaniemi. All rights reserved. -Copyright (C) 2011, 2012 Andrew Main (Zefram) <zefram@fysh.org> +Copyright (C) 2011, 2012, 2013 Andrew Main (Zefram) <zefram@fysh.org> This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. diff --git a/Master/tlpkg/tlperl/lib/Time/Piece.pm b/Master/tlpkg/tlperl/lib/Time/Piece.pm index a3f7fb660b0..f913db99be9 100644 --- a/Master/tlpkg/tlperl/lib/Time/Piece.pm +++ b/Master/tlpkg/tlperl/lib/Time/Piece.pm @@ -19,7 +19,7 @@ our %EXPORT_TAGS = ( ':override' => 'internal', ); -our $VERSION = '1.20_01'; +our $VERSION = '1.27'; bootstrap Time::Piece $VERSION; @@ -415,7 +415,7 @@ sub week { # Now that we have the Julian day including fractions # convert it to an integer Julian Day Number using nearest - # int (since the day changes at midday we oconvert all Julian + # int (since the day changes at midday we convert all Julian # dates to following midnight). $J = int($J+0.5); @@ -639,7 +639,7 @@ Time::Piece - Object Oriented time objects =head1 DESCRIPTION -This module replaces the standard localtime and gmtime functions with +This module replaces the standard C<localtime> and C<gmtime> functions with implementations that return objects. It does so in a backwards compatible manner, so that using localtime/gmtime in the way documented in perlfunc will still return what you expect. @@ -717,6 +717,11 @@ following methods are available on the object: # see strptime man page. Creates a new # Time::Piece object +Note that C<localtime> and C<gmtime> are not listed above. If called as +methods on a Time::Piece object, they act as constructors, returning a new +Time::Piece object for the current time. In other words: they're not useful as +methods. + =head2 Local Locales Both wdayname (day) and monname (month) allow passing in a list to use @@ -728,7 +733,7 @@ using locales. my $french_day = localtime->day(@days); -These settings can be overriden globally too: +These settings can be overridden globally too: Time::Piece::day_list(@days); @@ -860,7 +865,9 @@ well into the future and past. Matt Sergeant, matt@sergeant.org Jarkko Hietaniemi, jhi@iki.fi (while creating Time::Piece for core perl) -=head1 License +=head1 COPYRIGHT AND LICENSE + +Copyright 2001, Larry Wall. This module is free software, you may distribute it under the same terms as Perl. diff --git a/Master/tlpkg/tlperl/lib/Time/Seconds.pm b/Master/tlpkg/tlperl/lib/Time/Seconds.pm index 1ecefa16abb..b001f20402e 100644 --- a/Master/tlpkg/tlperl/lib/Time/Seconds.pm +++ b/Master/tlpkg/tlperl/lib/Time/Seconds.pm @@ -1,8 +1,10 @@ package Time::Seconds; use strict; -use vars qw/@EXPORT @EXPORT_OK @ISA/; +use vars qw/@EXPORT @EXPORT_OK/; -@ISA = 'Exporter'; +our $VERSION = '1.27'; + +use Exporter 5.57 'import'; @EXPORT = qw( ONE_MINUTE @@ -176,6 +178,8 @@ sub pretty { 1; __END__ +=encoding utf8 + =head1 NAME Time::Seconds - a simple API to convert seconds to other date values @@ -242,11 +246,14 @@ Matt Sergeant, matt@sergeant.org Tobias Brox, tobiasb@tobiasb.funcom.com -Bal�zs Szab� (dLux), dlux@kapu.hu +Balázs Szabó (dLux), dlux@kapu.hu + +=head1 COPYRIGHT AND LICENSE -=head1 LICENSE +Copyright 2001, Larry Wall. -Please see Time::Piece for the license. +This module is free software, you may distribute it under the same terms +as Perl. =head1 Bugs diff --git a/Master/tlpkg/tlperl/lib/Time/Zone.pm b/Master/tlpkg/tlperl/lib/Time/Zone.pm new file mode 100644 index 00000000000..8a40f9158c8 --- /dev/null +++ b/Master/tlpkg/tlperl/lib/Time/Zone.pm @@ -0,0 +1,291 @@ + +package Time::Zone; + +=head1 NAME + +Time::Zone -- miscellaneous timezone manipulations routines + +=head1 SYNOPSIS + + use Time::Zone; + print tz2zone(); + print tz2zone($ENV{'TZ'}); + print tz2zone($ENV{'TZ'}, time()); + print tz2zone($ENV{'TZ'}, undef, $isdst); + $offset = tz_local_offset(); + $offset = tz_offset($TZ); + +=head1 DESCRIPTION + +This is a collection of miscellaneous timezone manipulation routines. + +C<tz2zone()> parses the TZ environment variable and returns a timezone +string suitable for inclusion in L<date(1)>-like output. It opionally takes +a timezone string, a time, and a is-dst flag. + +C<tz_local_offset()> determins the offset from GMT time in seconds. It +only does the calculation once. + +C<tz_offset()> determines the offset from GMT in seconds of a specified +timezone. + +C<tz_name()> determines the name of the timezone based on its offset + +=head1 AUTHORS + +Graham Barr <gbarr@pobox.com> +David Muir Sharnoff <muir@idiom.com> +Paul Foley <paul@ascent.com> + +=cut + +require 5.002; + +require Exporter; +use Carp; +use strict; +use vars qw(@ISA @EXPORT $VERSION @tz_local); + +@ISA = qw(Exporter); +@EXPORT = qw(tz2zone tz_local_offset tz_offset tz_name); +$VERSION = "2.24"; + +# Parts stolen from code by Paul Foley <paul@ascent.com> + +sub tz2zone (;$$$) +{ + my($TZ, $time, $isdst) = @_; + + use vars qw(%tzn_cache); + + $TZ = defined($ENV{'TZ'}) ? ( $ENV{'TZ'} ? $ENV{'TZ'} : 'GMT' ) : '' + unless $TZ; + + # Hack to deal with 'PST8PDT' format of TZ + # Note that this can't deal with all the esoteric forms, but it + # does recognize the most common: [:]STDoff[DST[off][,rule]] + + if (! defined $isdst) { + my $j; + $time = time() unless $time; + ($j, $j, $j, $j, $j, $j, $j, $j, $isdst) = localtime($time); + } + + if (defined $tzn_cache{$TZ}->[$isdst]) { + return $tzn_cache{$TZ}->[$isdst]; + } + + if ($TZ =~ /^ + ( [^:\d+\-,] {3,} ) + ( [+-] ? + \d {1,2} + ( : \d {1,2} ) {0,2} + ) + ( [^\d+\-,] {3,} )? + /x + ) { + my $dsttz = defined($4) ? $4 : $1; + $TZ = $isdst ? $dsttz : $1; + $tzn_cache{$TZ} = [ $1, $dsttz ]; + } else { + $tzn_cache{$TZ} = [ $TZ, $TZ ]; + } + return $TZ; +} + +sub tz_local_offset (;$) +{ + my ($time) = @_; + + $time = time() unless $time; + my (@l) = localtime($time); + my $isdst = $l[8]; + + if (defined($tz_local[$isdst])) { + return $tz_local[$isdst]; + } + + $tz_local[$isdst] = &calc_off($time); + + return $tz_local[$isdst]; +} + +sub calc_off +{ + my ($time) = @_; + + my (@l) = localtime($time); + my (@g) = gmtime($time); + + my $off; + + $off = $l[0] - $g[0] + + ($l[1] - $g[1]) * 60 + + ($l[2] - $g[2]) * 3600; + + # subscript 7 is yday. + + if ($l[7] == $g[7]) { + # done + } elsif ($l[7] == $g[7] + 1) { + $off += 86400; + } elsif ($l[7] == $g[7] - 1) { + $off -= 86400; + } elsif ($l[7] < $g[7]) { + # crossed over a year boundry! + # localtime is beginning of year, gmt is end + # therefore local is ahead + $off += 86400; + } else { + $off -= 86400; + } + + return $off; +} + +# constants + +CONFIG: { + use vars qw(%dstZone %zoneOff %dstZoneOff %Zone); + + my @dstZone = ( + # "ndt" => -2*3600-1800, # Newfoundland Daylight + "brst" => -2*3600, # Brazil Summer Time (East Daylight) + "adt" => -3*3600, # Atlantic Daylight + "edt" => -4*3600, # Eastern Daylight + "cdt" => -5*3600, # Central Daylight + "mdt" => -6*3600, # Mountain Daylight + "pdt" => -7*3600, # Pacific Daylight + "akdt" => -8*3600, # Alaska Daylight + "ydt" => -8*3600, # Yukon Daylight + "hdt" => -9*3600, # Hawaii Daylight + "bst" => +1*3600, # British Summer + "mest" => +2*3600, # Middle European Summer + "metdst" => +2*3600, # Middle European DST + "sst" => +2*3600, # Swedish Summer + "fst" => +2*3600, # French Summer + "cest" => +2*3600, # Central European Daylight + "eest" => +3*3600, # Eastern European Summer + "msd" => +4*3600, # Moscow Daylight + "wadt" => +8*3600, # West Australian Daylight + "kdt" => +10*3600, # Korean Daylight + # "cadt" => +10*3600+1800, # Central Australian Daylight + "aedt" => +11*3600, # Eastern Australian Daylight + "eadt" => +11*3600, # Eastern Australian Daylight + "nzd" => +13*3600, # New Zealand Daylight + "nzdt" => +13*3600, # New Zealand Daylight + ); + + my @Zone = ( + "gmt" => 0, # Greenwich Mean + "ut" => 0, # Universal (Coordinated) + "utc" => 0, + "wet" => 0, # Western European + "wat" => -1*3600, # West Africa + "at" => -2*3600, # Azores + "fnt" => -2*3600, # Brazil Time (Extreme East - Fernando Noronha) + "brt" => -3*3600, # Brazil Time (East Standard - Brasilia) + # For completeness. BST is also British Summer, and GST is also Guam Standard. + # "bst" => -3*3600, # Brazil Standard + # "gst" => -3*3600, # Greenland Standard + # "nft" => -3*3600-1800,# Newfoundland + # "nst" => -3*3600-1800,# Newfoundland Standard + "mnt" => -4*3600, # Brazil Time (West Standard - Manaus) + "ewt" => -4*3600, # U.S. Eastern War Time + "ast" => -4*3600, # Atlantic Standard + "est" => -5*3600, # Eastern Standard + "act" => -5*3600, # Brazil Time (Extreme West - Acre) + "cst" => -6*3600, # Central Standard + "mst" => -7*3600, # Mountain Standard + "pst" => -8*3600, # Pacific Standard + "akst" => -9*3600, # Alaska Standard + "yst" => -9*3600, # Yukon Standard + "hst" => -10*3600, # Hawaii Standard + "cat" => -10*3600, # Central Alaska + "ahst" => -10*3600, # Alaska-Hawaii Standard + "nt" => -11*3600, # Nome + "idlw" => -12*3600, # International Date Line West + "cet" => +1*3600, # Central European + "mez" => +1*3600, # Central European (German) + "ect" => +1*3600, # Central European (French) + "met" => +1*3600, # Middle European + "mewt" => +1*3600, # Middle European Winter + "swt" => +1*3600, # Swedish Winter + "set" => +1*3600, # Seychelles + "fwt" => +1*3600, # French Winter + "eet" => +2*3600, # Eastern Europe, USSR Zone 1 + "ukr" => +2*3600, # Ukraine + "bt" => +3*3600, # Baghdad, USSR Zone 2 + "msk" => +3*3600, # Moscow + # "it" => +3*3600+1800,# Iran + "zp4" => +4*3600, # USSR Zone 3 + "zp5" => +5*3600, # USSR Zone 4 + # "ist" => +5*3600+1800,# Indian Standard + "zp6" => +6*3600, # USSR Zone 5 + # For completeness. NST is also Newfoundland Stanard, and SST is also Swedish Summer. + # "nst" => +6*3600+1800,# North Sumatra + # "sst" => +7*3600, # South Sumatra, USSR Zone 6 + # "jt" => +7*3600+1800,# Java (3pm in Cronusland!) + "wst" => +8*3600, # West Australian Standard + "hkt" => +8*3600, # Hong Kong + "cct" => +8*3600, # China Coast, USSR Zone 7 + "jst" => +9*3600, # Japan Standard, USSR Zone 8 + "kst" => +9*3600, # Korean Standard + # "cast" => +9*3600+1800,# Central Australian Standard + "aest" => +10*3600, # Eastern Australian Standard + "east" => +10*3600, # Eastern Australian Standard + "gst" => +10*3600, # Guam Standard, USSR Zone 9 + "nzt" => +12*3600, # New Zealand + "nzst" => +12*3600, # New Zealand Standard + "idle" => +12*3600, # International Date Line East + ); + + %Zone = @Zone; + %dstZone = @dstZone; + %zoneOff = reverse(@Zone); + %dstZoneOff = reverse(@dstZone); + +} + +sub tz_offset (;$$) +{ + my ($zone, $time) = @_; + + return &tz_local_offset($time) unless($zone); + + $time = time() unless $time; + my(@l) = localtime($time); + my $dst = $l[8]; + + $zone = lc $zone; + + if($zone =~ /^(([\-\+])\d\d?)(\d\d)$/) { + my $v = $2 . $3; + return $1 * 3600 + $v * 60; + } elsif (exists $dstZone{$zone} && ($dst || !exists $Zone{$zone})) { + return $dstZone{$zone}; + } elsif(exists $Zone{$zone}) { + return $Zone{$zone}; + } + undef; +} + +sub tz_name (;$$) +{ + my ($off, $dst) = @_; + + $off = tz_offset() + unless(defined $off); + + $dst = (localtime(time))[8] + unless(defined $dst); + + if (exists $dstZoneOff{$off} && ($dst || !exists $zoneOff{$off})) { + return $dstZoneOff{$off}; + } elsif (exists $zoneOff{$off}) { + return $zoneOff{$off}; + } + sprintf("%+05d", int($off / 60) * 100 + $off % 60); +} + +1; |