TimeDate-2.32/000755 000767 000024 00000000000 13630020510 013717 5ustar00nicolasstaff000000 000000 TimeDate-2.32/ChangeLog000644 000767 000024 00000026020 13630020314 015473 0ustar00nicolasstaff000000 000000 2.32 -- Wed Mar 04 14:41:00 MT 2020 * Fix t/date.t to run on leap years [arc] 2.31 -- Thu Jan 16 14:00:00 MT 2020 * Fix year 2020 bug from t/getdate.t [Prajith] * Fix warnings from t/date.t * Fix pod issue in lib/Date/Parse.pm * Fix for French language using English day suffixes in %o [mitchjacksontech] * RT#84075: Fix Date::Parse::str2time century issue. [perlpilot] * Adds Occitan language. [Quenty31] * Migrate GitHub repo and bugtracker to atoomic/perl-TimeDate 2.30 -- Mon Feb 18 13:31:03 CST 2013 * Syncing distribution version number with Date::Parse, not functional changes 1.20 -- Sat Dec 12 06:38:14 CST 2009 * Typo => s/timezome/timezone/ [yanick] * RT#52387 Fix %s formating to use timelocal when no timezone is given * RT#51664 fix str2time('16 Oct 09') to not give a negative result 1.19 -- Fri Sep 25 13:59:41 CDT 2009 * Replace Date::Language::Hungarian with version from CPAN by Lee Goddard 1.18 -- Thu Sep 24 17:43:28 CDT 2009 * RT#49963 Skip pre 1970 date tests on Win32 * Added Date::Language::Hungarian (Konrad Lorinczi) 1.17 -- Sat Sep 19 10:56:12 CDT 2009 Bugfixes * RT#45067: Date::Format with %z gives wrong results for half-hour timezones (Ernesto Hernndez-Novich) * RT#48164: Date::Parse unable to set seconds correctly * RT#17396: Parse error for french date with 'mars' (march) as month Documentation * Fixed documentation for %e in Date::Format * Update documentation to remove Date::Format->language Enhancements * Add support for dates like Jul-13-1999 (Brett Warden) * Added Icelandic language (Tomas Edwardsson) * Added Romanian language (Doru Petrescu) * Added Russian language (Denis Poznyakov & Danil Pismenny) * Added Turkish language (Burak Gursoy) * Added Spanish language (Adrian Mugnolo) * Added Chinese language (Kang-min Liu) * Support parsing dates like 2002-02-26-10:37:21.141 as used by lpd * Support Z timezone when only the time is specified * Added METDST to Time::Zone * Added AKST/AKDT to Time::Zone Changes prior to 1.17 Change 814 on 2003/06/03 by (Graham Barr) Date::Parse - Time::Local in 5.8 does not support fractional seconds Change 813 on 2003/06/02 by (Graham Barr) Release 1.15 Change 812 on 2003/06/02 by (Graham Barr) Fix comments about Language implementation in Date::Parse (patch from Christian Hammers) Change 811 on 2003/06/02 by (Graham Barr) Fix short name for 'maart' to be 'mrt' as suggested by Frank Maas Change 810 on 2003/06/02 by (Graham Barr) Add %G format for GPS week (patch from Eric Richardson) Change 809 on 2003/06/02 by (Graham Barr) Language updates from Daniel Yacob Change 808 on 2003/06/02 by (Graham Barr) str2time("") should return undef Change 807 on 2003/06/02 by (Graham Barr) Added Swedish and Finnish languages from Matthew Musgrove Change 778 on 2003/03/03 by (Graham Barr) Added Chinese_GB language. Supplied by forehead (I don't even pretend tounderstand it) Change 777 on 2003/03/03 by (Graham Barr) Return fractional seconds when specified in an ISO date Change 776 on 2003/03/03 by (Graham Barr) New languages from Daniel Yacob Change 775 on 2003/03/03 by (Graham Barr) Fix UTC support on ISO dates Change 774 on 2003/03/03 by (Graham Barr) Allow a : in a timezone so the dates specified in RSS can be parsed (eg 2002-11-07T23:31:49-05:00) Patch from Kellan Change 773 on 2003/03/03 by (Graham Barr) Support parsing more formats Change 754 on 2002/11/03 by (Graham Barr) Release 1.14 Change 753 on 2002/11/03 by (Graham Barr) Fix bug parsing 2002-11-02 11pm Change 752 on 2002/11/03 by (Graham Barr) Add Greek language module from Matthew Musgrove Change 744 on 2002/09/16 by (Graham Barr) Add Date::Language::Brazilian and Date::Language::Danish to MANIFEST Change 743 on 2002/09/16 by (Graham Barr) Add Date::Language::Brazilian from Christian Tosta Add Date::Language::Danish from Lars Skjrlund Change 742 on 2002/09/16 by (Graham Barr) Time::Zone - Add some zones for Brazil Change 741 on 2002/09/16 by (Graham Barr) Time::Zone [cpan #1299] - Allow $ENV{TZ} to have zomes like EST5 Change 733 on 2002/06/13 by (Graham Barr) Date::Language::French - Fix missing ; Change 732 on 2002/06/06 by (Graham Barr) Release 1.13 Change 731 on 2002/06/06 by (Graham Barr) Fix pattern to allow single digits for month and day (eg '2002-6-1') Change 730 on 2002/06/03 by (Graham Barr) Release 1.12 Change 729 on 2002/06/03 by (Graham Barr) Fix month name abbreviations Change 720 on 2002/04/25 by (Graham Barr) Date::Parse - Make it work with 5.004 again Change 719 on 2002/04/25 by (Graham Barr) Prevent the ISO date pattern matching where it should not. ie there must not be a non-space character directly before the date string Change 718 on 2002/04/17 by (Graham Barr) Change French @Dsuf, from Peter Samuelson Change 712 on 2002/03/07 by (Graham Barr) Added %L format for month number as 1..12 from Adam Monsen Change 708 on 2002/02/28 by (Graham Barr) Release 1.11 Change 707 on 2002/02/28 by (Graham Barr) Fix format error in t/date.t Change 692 on 2002/01/09 by (Graham Barr) Be a bit more lenient on the ISO format Change 691 on 2002/01/02 by (Graham Barr) Fix typo in ISO-8601 formats in docs Change 690 on 2001/12/28 by (Graham Barr) Date::Format - Fix array dereference syntax typo Change 689 on 2001/12/28 by (Graham Barr) Date::Format - Fix doc typos Change 682 on 2001/11/20 by (Graham Barr) Date::Parse - Make the minutes and seconds parts of an ISO-8601 optional (patch from Christian Hammers) Change 681 on 2001/11/20 by (Graham Barr) Date::Parse - Allow AM/PM to be just A/P (eg Jul 13 1999 1:23P) as used by MySQL (patch from Drew Degentesh) Change 680 on 2001/11/20 by (Graham Barr) Time::Zone - Add CEST Central European Daylight Change 679 on 2001/11/20 by (Graham Barr) Date::Parse - Extract (but ignore) fractions of a second in an ISO8601 date string (patch from rayg at yahoo-inc.com) Change 678 on 2001/11/20 by (Graham Barr) Add %P to be am or pm Change 677 on 2001/11/20 by (Graham Barr) Date::Language::French - Um, the french have 7 days in the week just like everyone else Change 676 on 2001/11/20 by (Graham Barr) Date::Language::German - Fix abbrev for October (patch from Stefan Niederhauser) Change 634 on 2001/09/03 by (Graham Barr) Add a check for invalid years in format 1995-01-24 Change 580 on 2000/09/04 by (Graham Barr) Release 1.10 Change 579 on 2000/09/04 by (Graham Barr) Date::Parse - Support for more date formats Time::Zone - Added more zones Change 539 on 2000/06/14 by (Graham Barr) Documentation updates Change 536 on 2000/06/06 by (Graham Barr) Fix VERSION numbers Change 535 on 2000/06/06 by (Graham Barr) Date::Format - Added support for %O* to support output of roman numerals Change 443 on 2000/03/29 by (Graham Barr) Release 1.09 Change 442 on 2000/03/29 by (Graham Barr) Added PPD stuff to Makefile.PL Change 441 on 2000/03/29 by (Graham Barr) Date::Parse - Allow "s after the timezone Change 440 on 2000/03/29 by (Graham Barr) Date::Format - Fix doc for %c and %C Change 409 on 2000/03/28 by (Graham Barr) Moved .pm files into lib directory Change 408 on 2000/03/28 by (Graham Barr) str2time returns undef on error bit Time::Local returns -1. Check if the -1 is real or an error Change 407 on 2000/03/28 by (Graham Barr) Added Eastern European Summer Time EEST Change 268 on 1999/03/18 by (Graham Barr) Date::Format, Time::Zone - Fix problem with %z and %Z as suggested by Jason A Smith Change 267 on 1999/03/18 by (Graham Barr) - Make t/getdate.t more portable as suggested by Paul Schinder Change 250 on 1999/02/06 by (Graham Barr) Date::Format - Correct docs for %d and %e Change 249 on 1999/02/06 by (Graham Barr) Added Date::Language::Czech Change 180 on 1998/08/05 by (Graham Barr) Date::Language - Added Date::Language::French contributed by Emmanuel Bataille (bem@residents.frmug.org) - Split out the languages into .pm's Date::Parse - Added patch from Alan Burlison to Date::Parse to allow zone offests +7, +10 and +700 - Parse now supports GMT+0100 *** Release 1.08 Fri Jan 2 1998 (Graham Barr) Date::Format, Time::Zone - Fix for formatting %z and %Z all - Update Email address and year Tue Feb 17 1998 (Graham Barr) Date::Language - Added format_o to German Fri Sep 12 1997 (Graham Barr) Date::Parse - Added 'DST' to parser, it adjusts $zone by 3600 (but that may not be right in all cases) - Added a check to str2time to ensure valid values are passed to Time::Local, to avoid croak-ing - Fixed to treat AM and PM correctly when the hour is 12. (I hope :-) Time::Zone - Modified for Western Australia Tue 07 Jan 1996 o Release 1.07 o Fixed a problem in Time::Zone (had @l[8] instead of $l[8], doh! ) Thu 02 Jan 1996 o Release 1.06 o Fixed t/getdate.t o Date::Parse can now parse the date-format 960913, which apparently is fairly common in sweden. Wed 31 Jul 1996 o Release 1.05 o Modified Date::Format not to use single letter sub names, all format sub names are nore prefixed with format_ o Cleaned up Date/Format.pm so that AUTOLOAD is not required o Patched Date/Language.pm to add Norwegian. Thanks to Gisle Aas for the patch Thu 27 Jun 1996 o Added %z to Date::Format to output timezone in +/-0000 format o Added multi-language support via Date::Language,. Tue 25 Jun 1996 o Some code tidying up o added a new test, copied from Date::GetDate o improved performance Wed 22 May 1996 o Fixed a bug in the parser for dates in a default (local) timezone but a different dst Wed 15 May 1996 o Added support for mainframe type dates Fri 3 May 1996 o Added %s to date formatting at request of Josh Osborne . TimeDate-2.32/MANIFEST000644 000767 000024 00000002552 13630020510 015054 0ustar00nicolasstaff000000 000000 ChangeLog lib/Date/Format.pm lib/Date/Language.pm lib/Date/Language/Afar.pm lib/Date/Language/Amharic.pm lib/Date/Language/Austrian.pm lib/Date/Language/Brazilian.pm lib/Date/Language/Bulgarian.pm lib/Date/Language/Chinese.pm lib/Date/Language/Chinese_GB.pm lib/Date/Language/Czech.pm lib/Date/Language/Danish.pm lib/Date/Language/Dutch.pm lib/Date/Language/English.pm lib/Date/Language/Finnish.pm lib/Date/Language/French.pm lib/Date/Language/Gedeo.pm lib/Date/Language/German.pm lib/Date/Language/Greek.pm lib/Date/Language/Hungarian.pm lib/Date/Language/Icelandic.pm lib/Date/Language/Italian.pm lib/Date/Language/Norwegian.pm lib/Date/Language/Occitan.pm lib/Date/Language/Oromo.pm lib/Date/Language/Romanian.pm lib/Date/Language/Russian.pm lib/Date/Language/Russian_cp1251.pm lib/Date/Language/Russian_koi8r.pm lib/Date/Language/Sidama.pm lib/Date/Language/Somali.pm lib/Date/Language/Spanish.pm lib/Date/Language/Swedish.pm lib/Date/Language/Tigrinya.pm lib/Date/Language/TigrinyaEritrean.pm lib/Date/Language/TigrinyaEthiopian.pm lib/Date/Language/Turkish.pm lib/Date/Parse.pm lib/Time/Zone.pm lib/TimeDate.pm Makefile.PL MANIFEST This list of files README t/cpanrt.t t/date.t t/format.t t/getdate.t t/lang.t META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) TimeDate-2.32/t/000755 000767 000024 00000000000 13630020510 014162 5ustar00nicolasstaff000000 000000 TimeDate-2.32/README000644 000767 000024 00000001453 13610162551 014614 0ustar00nicolasstaff000000 000000 This is the perl5 TimeDate distribution. It requires perl version 5.003 or later This distribution replaces my earlier GetDate distribution, which was only a date parser. The date parser contained in this distribution is far superior to the yacc based parser, and a *lot* fatser. The parser contained here will only parse absolute dates, if you want a date parser that can parse relative dates then take a look at the Time modules by David Muir on CPAN. You install the library by running these commands: perl Makefile.PL make make test make install Please report any bugs/suggestions to Copyright 1995-2009 Graham Barr. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Share and Enjoy! Graham TimeDate-2.32/META.yml000644 000767 000024 00000001162 13630020510 015170 0ustar00nicolasstaff000000 000000 --- abstract: unknown author: - 'Graham Barr ' build_requires: ExtUtils::MakeMaker: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.44, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: TimeDate no_index: directory: - t - inc resources: bugtracker: https://github.com/atoomic/perl-TimeDate/issues repository: https://github.com/atoomic/perl-TimeDate version: '2.32' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' TimeDate-2.32/lib/000755 000767 000024 00000000000 13630020510 014465 5ustar00nicolasstaff000000 000000 TimeDate-2.32/PaxHeader/Makefile.PL000644 000767 000024 00000000036 13611417640 017656 xustar00nicolasstaff000000 000000 30 mtime=1579556768.563418891 TimeDate-2.32/Makefile.PL000644 000767 000024 00000001046 13611417640 015707 0ustar00nicolasstaff000000 000000 # This -*- perl -*- script makes the Makefile BEGIN { require 5.004 } use strict; use warnings; use ExtUtils::MakeMaker; WriteMakefile( NAME => 'Date::Parse', DISTNAME => 'TimeDate', AUTHOR => 'Graham Barr ', VERSION_FROM => 'lib/Date/Parse.pm', META_MERGE => { resources => { bugtracker => 'https://github.com/atoomic/perl-TimeDate/issues', repository => 'https://github.com/atoomic/perl-TimeDate', } }, (eval { ExtUtils::MakeMaker->VERSION(6.21) } ? (LICENSE => 'perl') : ()), ); TimeDate-2.32/META.json000644 000767 000024 00000001776 13630020510 015353 0ustar00nicolasstaff000000 000000 { "abstract" : "unknown", "author" : [ "Graham Barr " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.44, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "TimeDate", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/atoomic/perl-TimeDate/issues" }, "repository" : { "url" : "https://github.com/atoomic/perl-TimeDate" } }, "version" : "2.32", "x_serialization_backend" : "JSON::PP version 4.04" } TimeDate-2.32/lib/Date/000755 000767 000024 00000000000 13630020510 015342 5ustar00nicolasstaff000000 000000 TimeDate-2.32/lib/Time/000755 000767 000024 00000000000 13630020510 015363 5ustar00nicolasstaff000000 000000 TimeDate-2.32/lib/TimeDate.pm000644 000767 000024 00000000413 13610163333 016526 0ustar00nicolasstaff000000 000000 package TimeDate; use vars qw($VERSION); $VERSION = "1.21"; =pod This is an empty module which is just there to get ownership on TimeDate using first-come permissions from PAUSE. This was required during the release of 1.21 for transferring ownership. =cut 1; TimeDate-2.32/lib/Time/Zone.pm000644 000767 000024 00000020232 13610162551 016645 0ustar00nicolasstaff000000 000000 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 parses the TZ environment variable and returns a timezone string suitable for inclusion in L-like output. It opionally takes a timezone string, a time, and a is-dst flag. C determins the offset from GMT time in seconds. It only does the calculation once. C determines the offset from GMT in seconds of a specified timezone. C determines the name of the timezone based on its offset =head1 AUTHORS Graham Barr David Muir Sharnoff Paul Foley =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 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; TimeDate-2.32/lib/Date/Language/000755 000767 000024 00000000000 13630020510 017065 5ustar00nicolasstaff000000 000000 TimeDate-2.32/lib/Date/Format.pm000644 000767 000024 00000022660 13611433207 017150 0ustar00nicolasstaff000000 000000 # Copyright (c) 1995-2009 Graham Barr. This program is free # software; you can redistribute it and/or modify it under the same terms # as Perl itself. package Date::Format; use strict; use vars qw(@EXPORT @ISA $VERSION); require Exporter; $VERSION = "2.24"; @ISA = qw(Exporter); @EXPORT = qw(time2str strftime ctime asctime); sub time2str ($;$$) { Date::Format::Generic->time2str(@_); } sub strftime ($\@;$) { Date::Format::Generic->strftime(@_); } sub ctime ($;$) { my($t,$tz) = @_; Date::Format::Generic->time2str("%a %b %e %T %Y\n", $t, $tz); } sub asctime (\@;$) { my($t,$tz) = @_; Date::Format::Generic->strftime("%a %b %e %T %Y\n", $t, $tz); } ## ## ## package Date::Format::Generic; use vars qw($epoch $tzname); use Time::Zone; use Time::Local; sub ctime { my($me,$t,$tz) = @_; $me->time2str("%a %b %e %T %Y\n", $t, $tz); } sub asctime { my($me,$t,$tz) = @_; $me->strftime("%a %b %e %T %Y\n", $t, $tz); } sub _subs { my $fn; $_[1] =~ s/ %(O?[%a-zA-Z]) / ($_[0]->can("format_$1") || sub { $1 })->($_[0]); /sgeox; $_[1]; } sub strftime { my($pkg,$fmt,$time); ($pkg,$fmt,$time,$tzname) = @_; my $me = ref($pkg) ? $pkg : bless []; if(defined $tzname) { $tzname = uc $tzname; $tzname = sprintf("%+05d",$tzname) unless($tzname =~ /\D/); $epoch = timegm(@{$time}[0..5]); @$me = gmtime($epoch + tz_offset($tzname) - tz_offset()); } else { @$me = @$time; undef $epoch; } _subs($me,$fmt); } sub time2str { my($pkg,$fmt,$time); ($pkg,$fmt,$time,$tzname) = @_; my $me = ref($pkg) ? $pkg : bless [], $pkg; $epoch = $time; if(defined $tzname) { $tzname = uc $tzname; $tzname = sprintf("%+05d",$tzname) unless($tzname =~ /\D/); $time += tz_offset($tzname); @$me = gmtime($time); } else { @$me = localtime($time); } $me->[9] = $time; _subs($me,$fmt); } my(@DoW,@MoY,@DoWs,@MoYs,@AMPM,%format,@Dsuf); @DoW = qw(Sunday Monday Tuesday Wednesday Thursday Friday Saturday); @MoY = qw(January February March April May June July August September October November December); @DoWs = map { substr($_,0,3) } @DoW; @MoYs = map { substr($_,0,3) } @MoY; @AMPM = qw(AM PM); @Dsuf = (qw(th st nd rd th th th th th th)) x 3; @Dsuf[11,12,13] = qw(th th th); @Dsuf[30,31] = qw(th st); %format = ('x' => "%m/%d/%y", 'C' => "%a %b %e %T %Z %Y", 'X' => "%H:%M:%S", ); my @locale; my $locale = "/usr/share/lib/locale/LC_TIME/default"; local *LOCALE; if(open(LOCALE,"$locale")) { chop(@locale = ); close(LOCALE); @MoYs = @locale[0 .. 11]; @MoY = @locale[12 .. 23]; @DoWs = @locale[24 .. 30]; @DoW = @locale[31 .. 37]; @format{"X","x","C"} = @locale[38 .. 40]; @AMPM = @locale[41 .. 42]; } sub wkyr { my($wstart, $wday, $yday) = @_; $wday = ($wday + 7 - $wstart) % 7; return int(($yday - $wday + 13) / 7 - 1); } ## ## these 6 formatting routins need to be *copied* into the language ## specific packages ## my @roman = ('',qw(I II III IV V VI VII VIII IX)); sub roman { my $n = shift; $n =~ s/(\d)$//; my $r = $roman[ $1 ]; if($n =~ s/(\d)$//) { (my $t = $roman[$1]) =~ tr/IVX/XLC/; $r = $t . $r; } if($n =~ s/(\d)$//) { (my $t = $roman[$1]) =~ tr/IVX/CDM/; $r = $t . $r; } if($n =~ s/(\d)$//) { (my $t = $roman[$1]) =~ tr/IVX/M../; $r = $t . $r; } $r; } sub format_a { $DoWs[$_[0]->[6]] } sub format_A { $DoW[$_[0]->[6]] } sub format_b { $MoYs[$_[0]->[4]] } sub format_B { $MoY[$_[0]->[4]] } sub format_h { $MoYs[$_[0]->[4]] } sub format_p { $_[0]->[2] >= 12 ? $AMPM[1] : $AMPM[0] } sub format_P { lc($_[0]->[2] >= 12 ? $AMPM[1] : $AMPM[0]) } sub format_d { sprintf("%02d",$_[0]->[3]) } sub format_e { sprintf("%2d",$_[0]->[3]) } sub format_H { sprintf("%02d",$_[0]->[2]) } sub format_I { sprintf("%02d",$_[0]->[2] % 12 || 12)} sub format_j { sprintf("%03d",$_[0]->[7] + 1) } sub format_k { sprintf("%2d",$_[0]->[2]) } sub format_l { sprintf("%2d",$_[0]->[2] % 12 || 12)} sub format_L { $_[0]->[4] + 1 } sub format_m { sprintf("%02d",$_[0]->[4] + 1) } sub format_M { sprintf("%02d",$_[0]->[1]) } sub format_q { sprintf("%01d",int($_[0]->[4] / 3) + 1) } sub format_s { $epoch = timelocal(@{$_[0]}[0..5]) unless defined $epoch; sprintf("%d",$epoch) } sub format_S { sprintf("%02d",$_[0]->[0]) } sub format_U { wkyr(0, $_[0]->[6], $_[0]->[7]) } sub format_w { $_[0]->[6] } sub format_W { wkyr(1, $_[0]->[6], $_[0]->[7]) } sub format_y { sprintf("%02d",$_[0]->[5] % 100) } sub format_Y { sprintf("%04d",$_[0]->[5] + 1900) } sub format_Z { my $o = tz_local_offset(timelocal(@{$_[0]}[0..5])); defined $tzname ? $tzname : uc tz_name($o, $_[0]->[8]); } sub format_z { my $t = timelocal(@{$_[0]}[0..5]); my $o = defined $tzname ? tz_offset($tzname, $t) : tz_offset(undef,$t); sprintf("%+03d%02d", int($o / 3600), int(abs($o) % 3600) / 60); } sub format_c { &format_x . " " . &format_X } sub format_D { &format_m . "/" . &format_d . "/" . &format_y } sub format_r { &format_I . ":" . &format_M . ":" . &format_S . " " . &format_p } sub format_R { &format_H . ":" . &format_M } sub format_T { &format_H . ":" . &format_M . ":" . &format_S } sub format_t { "\t" } sub format_n { "\n" } sub format_o { sprintf("%2d%s",$_[0]->[3],$Dsuf[$_[0]->[3]]) } sub format_x { my $f = $format{'x'}; _subs($_[0],$f); } sub format_X { my $f = $format{'X'}; _subs($_[0],$f); } sub format_C { my $f = $format{'C'}; _subs($_[0],$f); } sub format_Od { roman(format_d(@_)) } sub format_Oe { roman(format_e(@_)) } sub format_OH { roman(format_H(@_)) } sub format_OI { roman(format_I(@_)) } sub format_Oj { roman(format_j(@_)) } sub format_Ok { roman(format_k(@_)) } sub format_Ol { roman(format_l(@_)) } sub format_Om { roman(format_m(@_)) } sub format_OM { roman(format_M(@_)) } sub format_Oq { roman(format_q(@_)) } sub format_Oy { roman(format_y(@_)) } sub format_OY { roman(format_Y(@_)) } sub format_G { int(($_[0]->[9] - 315993600) / 604800) } 1; __END__ =head1 NAME Date::Format - Date formating subroutines =head1 SYNOPSIS use Date::Format; @lt = localtime(time); print time2str($template, time); print strftime($template, @lt); print time2str($template, time, $zone); print strftime($template, @lt, $zone); print ctime(time); print asctime(@lt); print ctime(time, $zone); print asctime(@lt, $zone); =head1 DESCRIPTION This module provides routines to format dates into ASCII strings. They correspond to the C library routines C and C. =over 4 =item time2str(TEMPLATE, TIME [, ZONE]) C converts C