diff options
author | Anas Nashif <anas.nashif@intel.com> | 2012-12-27 19:01:41 -0800 |
---|---|---|
committer | Anas Nashif <anas.nashif@intel.com> | 2012-12-27 19:01:41 -0800 |
commit | 8511956c25f92ccd6094dca45824697ad21cfdd4 (patch) | |
tree | 339c6be9e55fc02eae92912dcde3aec10bb2dbe5 | |
download | perl-TimeDate-8511956c25f92ccd6094dca45824697ad21cfdd4.tar.gz perl-TimeDate-8511956c25f92ccd6094dca45824697ad21cfdd4.tar.bz2 perl-TimeDate-8511956c25f92ccd6094dca45824697ad21cfdd4.zip |
Imported Upstream version 1.20upstream/1.20
47 files changed, 4056 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..49eca37 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,400 @@ +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 <gbarr@pobox.com> (Graham Barr) + + Date::Parse + - Time::Local in 5.8 does not support fractional seconds + +Change 813 on 2003/06/02 by <gbarr@pobox.com> (Graham Barr) + + Release 1.15 + +Change 812 on 2003/06/02 by <gbarr@pobox.com> (Graham Barr) + + Fix comments about Language implementation in Date::Parse + (patch from Christian Hammers) + +Change 811 on 2003/06/02 by <gbarr@pobox.com> (Graham Barr) + + Fix short name for 'maart' to be 'mrt' as suggested by Frank Maas + +Change 810 on 2003/06/02 by <gbarr@pobox.com> (Graham Barr) + + Add %G format for GPS week (patch from Eric Richardson) + +Change 809 on 2003/06/02 by <gbarr@pobox.com> (Graham Barr) + + Language updates from Daniel Yacob + +Change 808 on 2003/06/02 by <gbarr@pobox.com> (Graham Barr) + + str2time("") should return undef + +Change 807 on 2003/06/02 by <gbarr@pobox.com> (Graham Barr) + + Added Swedish and Finnish languages from Matthew Musgrove + +Change 778 on 2003/03/03 by <gbarr@pobox.com> (Graham Barr) + + Added Chinese_GB language. + Supplied by forehead (I don't even pretend tounderstand it) + +Change 777 on 2003/03/03 by <gbarr@pobox.com> (Graham Barr) + + Return fractional seconds when specified in an ISO date + +Change 776 on 2003/03/03 by <gbarr@pobox.com> (Graham Barr) + + New languages from Daniel Yacob + +Change 775 on 2003/03/03 by <gbarr@pobox.com> (Graham Barr) + + Fix UTC support on ISO dates + +Change 774 on 2003/03/03 by <gbarr@pobox.com> (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 <gbarr@pobox.com> (Graham Barr) + + Support parsing more formats + +Change 754 on 2002/11/03 by <gbarr@pobox.com> (Graham Barr) + + Release 1.14 + +Change 753 on 2002/11/03 by <gbarr@pobox.com> (Graham Barr) + + Fix bug parsing 2002-11-02 11pm + +Change 752 on 2002/11/03 by <gbarr@pobox.com> (Graham Barr) + + Add Greek language module from Matthew Musgrove + +Change 744 on 2002/09/16 by <gbarr@pobox.com> (Graham Barr) + + Add Date::Language::Brazilian and Date::Language::Danish + to MANIFEST + +Change 743 on 2002/09/16 by <gbarr@pobox.com> (Graham Barr) + + Add Date::Language::Brazilian from Christian Tosta + Add Date::Language::Danish from Lars Skjrlund + +Change 742 on 2002/09/16 by <gbarr@pobox.com> (Graham Barr) + + Time::Zone + - Add some zones for Brazil + +Change 741 on 2002/09/16 by <gbarr@pobox.com> (Graham Barr) + + Time::Zone [cpan #1299] + - Allow $ENV{TZ} to have zomes like EST5 + +Change 733 on 2002/06/13 by <gbarr@pobox.com> (Graham Barr) + + Date::Language::French + - Fix missing ; + +Change 732 on 2002/06/06 by <gbarr@pobox.com> (Graham Barr) + + Release 1.13 + +Change 731 on 2002/06/06 by <gbarr@pobox.com> (Graham Barr) + + Fix pattern to allow single digits for month and day (eg '2002-6-1') + +Change 730 on 2002/06/03 by <gbarr@pobox.com> (Graham Barr) + + Release 1.12 + +Change 729 on 2002/06/03 by <gbarr@pobox.com> (Graham Barr) + + Fix month name abbreviations + +Change 720 on 2002/04/25 by <gbarr@pobox.com> (Graham Barr) + + Date::Parse + - Make it work with 5.004 again + +Change 719 on 2002/04/25 by <gbarr@pobox.com> (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 <gbarr@pobox.com> (Graham Barr) + + Change French @Dsuf, from Peter Samuelson <peter@cadcamlab.org> + +Change 712 on 2002/03/07 by <gbarr@pobox.com> (Graham Barr) + + Added %L format for month number as 1..12 from Adam Monsen + +Change 708 on 2002/02/28 by <gbarr@pobox.com> (Graham Barr) + + Release 1.11 + +Change 707 on 2002/02/28 by <gbarr@pobox.com> (Graham Barr) + + Fix format error in t/date.t + +Change 692 on 2002/01/09 by <gbarr@pobox.com> (Graham Barr) + + Be a bit more lenient on the ISO format + +Change 691 on 2002/01/02 by <gbarr@pobox.com> (Graham Barr) + + Fix typo in ISO-8601 formats in docs + +Change 690 on 2001/12/28 by <gbarr@pobox.com> (Graham Barr) + + Date::Format + - Fix array dereference syntax typo + +Change 689 on 2001/12/28 by <gbarr@pobox.com> (Graham Barr) + + Date::Format + - Fix doc typos + +Change 682 on 2001/11/20 by <gbarr@pobox.com> (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 <gbarr@pobox.com> (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 <gbarr@pobox.com> (Graham Barr) + + Time::Zone + - Add CEST Central European Daylight + +Change 679 on 2001/11/20 by <gbarr@pobox.com> (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 <gbarr@pobox.com> (Graham Barr) + + Add %P to be am or pm + +Change 677 on 2001/11/20 by <gbarr@pobox.com> (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 <gbarr@pobox.com> (Graham Barr) + + Date::Language::German + - Fix abbrev for October (patch from Stefan Niederhauser) + +Change 634 on 2001/09/03 by <gbarr@pobox.com> (Graham Barr) + + Add a check for invalid years in format 1995-01-24 + +Change 580 on 2000/09/04 by <gbarr@pobox.com> (Graham Barr) + + Release 1.10 + +Change 579 on 2000/09/04 by <gbarr@pobox.com> (Graham Barr) + + Date::Parse + - Support for more date formats + + Time::Zone + - Added more zones + +Change 539 on 2000/06/14 by <gbarr@pobox.com> (Graham Barr) + + Documentation updates + +Change 536 on 2000/06/06 by <gbarr@pobox.com> (Graham Barr) + + Fix VERSION numbers + +Change 535 on 2000/06/06 by <gbarr@pobox.com> (Graham Barr) + + Date::Format + - Added support for %O* to support output of roman numerals + +Change 443 on 2000/03/29 by <gbarr@pobox.com> (Graham Barr) + + Release 1.09 + +Change 442 on 2000/03/29 by <gbarr@pobox.com> (Graham Barr) + + Added PPD stuff to Makefile.PL + +Change 441 on 2000/03/29 by <gbarr@pobox.com> (Graham Barr) + + Date::Parse + - Allow "s after the timezone + +Change 440 on 2000/03/29 by <gbarr@pobox.com> (Graham Barr) + + Date::Format + - Fix doc for %c and %C + +Change 409 on 2000/03/28 by <gbarr@pobox.com> (Graham Barr) + + Moved .pm files into lib directory + +Change 408 on 2000/03/28 by <gbarr@pobox.com> (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 <gbarr@pobox.com> (Graham Barr) + + Added Eastern European Summer Time EEST + +Change 268 on 1999/03/18 by <gbarr@pobox.com> (Graham Barr) + + Date::Format, Time::Zone + - Fix problem with %z and %Z as suggested by + Jason A Smith <smithj4@rpi.edu> + +Change 267 on 1999/03/18 by <gbarr@pobox.com> (Graham Barr) + + - Make t/getdate.t more portable as suggested by + Paul Schinder <schinder@pobox.com> + +Change 250 on 1999/02/06 by <gbarr@pobox.com> (Graham Barr) + + Date::Format + - Correct docs for %d and %e + +Change 249 on 1999/02/06 by <gbarr@pobox.com> (Graham Barr) + + Added Date::Language::Czech + +Change 180 on 1998/08/05 by <gbarr@pobox.com> (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 <gbarr@pobox.com> (Graham Barr) + + Date::Format, Time::Zone + - Fix for formatting %z and %Z + + all + - Update Email address and year + +Tue Feb 17 1998 <gbarr@pobox.com> (Graham Barr) + + Date::Language + - Added format_o to German + +Fri Sep 12 1997 <gbarr@pobox.com> (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 <bodg@tiuk.ti.com> + + 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 <aas@bergen.sn.no> for the patch + +Thu 27 Jun 1996 <bodg@tiuk.ti.com> + + o Added %z to Date::Format to output timezone in +/-0000 format + o Added multi-language support via Date::Language,. + +Tue 25 Jun 1996 <bodg@tiuk.ti.com> + + o Some code tidying up + o added a new test, copied from Date::GetDate + o improved performance + +Wed 22 May 1996 <bodg@tiuk.ti.com> + + o Fixed a bug in the parser for dates in a default (local) timezone + but a different dst + +Wed 15 May 1996 <bodg@tiuk.ti.com> + + o Added support for mainframe type dates + +Fri 3 May 1996 <bodg@tiuk.ti.com> + + o Added %s to date formatting at request of Josh Osborne + <stripes@va.pubnix.com>. + diff --git a/MANIFEST b/MANIFEST new file mode 100644 index 0000000..227442e --- /dev/null +++ b/MANIFEST @@ -0,0 +1,47 @@ +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/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/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 +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 meta-data (added by MakeMaker) +SIGNATURE Public-key signature (added by MakeMaker) diff --git a/META.yml b/META.yml new file mode 100644 index 0000000..6434fd5 --- /dev/null +++ b/META.yml @@ -0,0 +1,21 @@ +--- #YAML:1.0 +name: TimeDate +version: 1.20 +abstract: ~ +author: + - Graham Barr <gbarr@pobox.com> +license: perl +distribution_type: module +configure_requires: + ExtUtils::MakeMaker: 0 +requires: {} +resources: + repository: http://github.com/gbarr/perl-TimeDate +no_index: + directory: + - t + - inc +generated_by: ExtUtils::MakeMaker version 6.48 +meta-spec: + url: http://module-build.sourceforge.net/META-spec-v1.4.html + version: 1.4 diff --git a/Makefile.PL b/Makefile.PL new file mode 100644 index 0000000..c7c6034 --- /dev/null +++ b/Makefile.PL @@ -0,0 +1,23 @@ +# This -*- perl -*- script makes the Makefile + +BEGIN { require 5.004 } + +use strict; +use warnings; +use ExtUtils::MakeMaker; + +WriteMakefile( + NAME => 'TimeDate', + AUTHOR => 'Graham Barr <gbarr@pobox.com>', + VERSION => '1.20', + (eval { ExtUtils::MakeMaker->VERSION(6.21) } ? (LICENSE => 'perl') : ()), + ( eval { ExtUtils::MakeMaker->VERSION(6.46) } ? ( + META_MERGE => { + resources => { ## + repository => 'http://github.com/gbarr/perl-TimeDate', + }, + } + ) + : () + ), +); @@ -0,0 +1,28 @@ +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 <gbarr@pobox.com> + +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 <gbarr@pobox.com> + diff --git a/SIGNATURE b/SIGNATURE new file mode 100644 index 0000000..b4879bb --- /dev/null +++ b/SIGNATURE @@ -0,0 +1,69 @@ +This file contains message digests of all files listed in MANIFEST, +signed via the Module::Signature module, version 0.55. + +To verify the content in this distribution, first make sure you have +Module::Signature installed, then type: + + % cpansign -v + +It will check each file's integrity, as well as the signature's +validity. If "==> Signature verified OK! <==" is not displayed, +the distribution may already have been compromised, and you should +not run its Makefile.PL or Build.PL. + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +SHA1 036da21b212a902ecb9d195565bbcd4c51bccecc ChangeLog +SHA1 efb2a90cd095d97ec148e6263fb921f560cfffb5 MANIFEST +SHA1 4efed966d43e74a6f53ef2bcdbfc4de05b92035f META.yml +SHA1 e111caf8b7da35935fa7004a17045cab55278445 Makefile.PL +SHA1 80cff3b1f65e7df95eaa1a992b688c2c5e1d2b6e README +SHA1 5ca10e18e888daf0883de553219f42ca2422763f lib/Date/Format.pm +SHA1 08342e72298e839f21236dff7555f2505f928d32 lib/Date/Language.pm +SHA1 50703aeade60a04398517416d30a2d8918c95578 lib/Date/Language/Afar.pm +SHA1 f9450ca0047510a4102c32cc4e20a435cdd85b31 lib/Date/Language/Amharic.pm +SHA1 f00534703736026830f729445d0d6f582481a05e lib/Date/Language/Austrian.pm +SHA1 c5af5f819bbd3eff3b404e62f1a3735d7e4a038b lib/Date/Language/Brazilian.pm +SHA1 e89738e9f3611a6de79cef7e791c20a05ac2a057 lib/Date/Language/Chinese.pm +SHA1 d8765df8f8368d6b467a87b1f32397d50253747a lib/Date/Language/Chinese_GB.pm +SHA1 f5061baf9b980aa0e8feefab059214775bb8182e lib/Date/Language/Czech.pm +SHA1 726c12ddd66f70ddcfd5bbdbc094777255eb2b9b lib/Date/Language/Danish.pm +SHA1 8566be869607c2b2024821def260de5a828f005f lib/Date/Language/Dutch.pm +SHA1 ab20e0b3487b85a54a3d6321b50d01d43fe78427 lib/Date/Language/English.pm +SHA1 9b057eea719ed24f643f4d284cf1fa6ae594e7dc lib/Date/Language/Finnish.pm +SHA1 105169f2848df40ac1111f0130ec1bb4b74647d8 lib/Date/Language/French.pm +SHA1 dc2f9c1cee48be3b73613ca9ed1291e9c976a37e lib/Date/Language/Gedeo.pm +SHA1 794a9b715e66fdcc428a65b2972ced4fee62b52c lib/Date/Language/German.pm +SHA1 863bb62fd08b3e61c63a2df3d65323d8e6c1b651 lib/Date/Language/Greek.pm +SHA1 8f0678fee75492f3675cf0b130fd39c7a589a552 lib/Date/Language/Hungarian.pm +SHA1 34da50806290fe731fd1e01290728fcd0b6d02a2 lib/Date/Language/Icelandic.pm +SHA1 de5069f424fed480586bc2dcff1cca1930bf98a1 lib/Date/Language/Italian.pm +SHA1 e4e81280ba513a3ab6e0bee01704913dd730c9a8 lib/Date/Language/Norwegian.pm +SHA1 13165e5b72586200a106aa2870fe92b49d94dd8c lib/Date/Language/Oromo.pm +SHA1 71eaea1d32b8fcfa23c5a815e3fa54b9f84af80c lib/Date/Language/Romanian.pm +SHA1 806f38e0789bf10f2e843c69f68bcfa50c0d78eb lib/Date/Language/Russian.pm +SHA1 292c36c93532a57b667d7deedc23cefbb9bf478c lib/Date/Language/Russian_cp1251.pm +SHA1 26efbebc7afd065da56ec09ee3b062a9ddd4a2d3 lib/Date/Language/Russian_koi8r.pm +SHA1 d1658daedcf106f01869a4371b9c3e572330f864 lib/Date/Language/Sidama.pm +SHA1 58f9ded75fc18c26eeb96ce6374e66565ad01494 lib/Date/Language/Somali.pm +SHA1 8b970f347eb0718e210d7613db5ba88b124d189e lib/Date/Language/Spanish.pm +SHA1 a52f8968a0fdf3e735d62f71b91d6b64a5f98fa3 lib/Date/Language/Swedish.pm +SHA1 5da829cf39dc01331ad58f66eced0a1f47e346b6 lib/Date/Language/Tigrinya.pm +SHA1 20fc6beb32657ca147719f713ff816bbb696da20 lib/Date/Language/TigrinyaEritrean.pm +SHA1 30f77a43a000f2ce3d22b1b633261a20289025aa lib/Date/Language/TigrinyaEthiopian.pm +SHA1 54288741c52b09ee92b0487848df74a08cdc3b9e lib/Date/Language/Turkish.pm +SHA1 b10ec48bd01b73638e4c6dce3f554e4c77267b6c lib/Date/Parse.pm +SHA1 394c7d372c25107ba5151ceca44c0599188907c7 lib/Time/Zone.pm +SHA1 ee65cf5b634d907c4cc2d414e49c06175461e6ac t/cpanrt.t +SHA1 7b16580497a96a4bc551b87b8b97ec89331e81f8 t/date.t +SHA1 bf6f4a7c599485ab11779c99fc821378e547d26d t/format.t +SHA1 acef4dd152cd391a3e7a7945c8405a50d965f335 t/getdate.t +SHA1 501dcb487e33f6b2d4577ef2e6e5f67f038d3c04 t/lang.t +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.10 (Darwin) + +iEYEARECAAYFAksjjt4ACgkQR0BL4gbYw3RCKgCePxf2QrH/3uvOofKewESV0zto +t+sAnA5dGEi945ziAfAkLyFUhIMWnm7U +=GqfE +-----END PGP SIGNATURE----- diff --git a/lib/Date/Format.pm b/lib/Date/Format.pm new file mode 100644 index 0000000..3a1ea90 --- /dev/null +++ b/lib/Date/Format.pm @@ -0,0 +1,403 @@ +# 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 = <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<strftime> and C<ctime>. + +=over 4 + +=item time2str(TEMPLATE, TIME [, ZONE]) + +C<time2str> converts C<TIME> into an ASCII string using the conversion +specification given in C<TEMPLATE>. C<ZONE> if given specifies the zone +which the output is required to be in, C<ZONE> defaults to your current zone. + + +=item strftime(TEMPLATE, TIME [, ZONE]) + +C<strftime> is similar to C<time2str> with the exception that the time is +passed as an array, such as the array returned by C<localtime>. + +=item ctime(TIME [, ZONE]) + +C<ctime> calls C<time2str> with the given arguments using the +conversion specification C<"%a %b %e %T %Y\n"> + +=item asctime(TIME [, ZONE]) + +C<asctime> calls C<time2str> with the given arguments using the +conversion specification C<"%a %b %e %T %Y\n"> + +=back + +=head1 MULTI-LANGUAGE SUPPORT + +Date::Format is capable of formating into several languages by creating +a language specific object and calling methods, see L<Date::Language> + + my $lang = Date::Language->new('German'); + $lang->time2str("%a %b %e %T %Y\n", time); + +I am open to suggestions on this. + +=head1 CONVERSION SPECIFICATION + +Each conversion specification is replaced by appropriate +characters as described in the following list. The +appropriate characters are determined by the LC_TIME +category of the program's locale. + + %% PERCENT + %a day of the week abbr + %A day of the week + %b month abbr + %B month + %c MM/DD/YY HH:MM:SS + %C ctime format: Sat Nov 19 21:05:57 1994 + %d numeric day of the month, with leading zeros (eg 01..31) + %e like %d, but a leading zero is replaced by a space (eg 1..32) + %D MM/DD/YY + %G GPS week number (weeks since January 6, 1980) + %h month abbr + %H hour, 24 hour clock, leading 0's) + %I hour, 12 hour clock, leading 0's) + %j day of the year + %k hour + %l hour, 12 hour clock + %L month number, starting with 1 + %m month number, starting with 01 + %M minute, leading 0's + %n NEWLINE + %o ornate day of month -- "1st", "2nd", "25th", etc. + %p AM or PM + %P am or pm (Yes %p and %P are backwards :) + %q Quarter number, starting with 1 + %r time format: 09:05:57 PM + %R time format: 21:05 + %s seconds since the Epoch, UCT + %S seconds, leading 0's + %t TAB + %T time format: 21:05:57 + %U week number, Sunday as first day of week + %w day of the week, numerically, Sunday == 0 + %W week number, Monday as first day of week + %x date format: 11/19/94 + %X time format: 21:05:57 + %y year (2 digits) + %Y year (4 digits) + %Z timezone in ascii. eg: PST + %z timezone in format -/+0000 + +C<%d>, C<%e>, C<%H>, C<%I>, C<%j>, C<%k>, C<%l>, C<%m>, C<%M>, C<%q>, +C<%y> and C<%Y> can be output in Roman numerals by prefixing the letter +with C<O>, e.g. C<%OY> will output the year as roman numerals. + +=head1 LIMITATION + +The functions in this module are limited to the time range that can be +represented by the time_t data type, i.e. 1901-12-13 20:45:53 GMT to +2038-01-19 03:14:07 GMT. + +=head1 AUTHOR + +Graham Barr <gbarr@pobox.com> + +=head1 COPYRIGHT + +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. + +=cut + + diff --git a/lib/Date/Language.pm b/lib/Date/Language.pm new file mode 100644 index 0000000..229a1c0 --- /dev/null +++ b/lib/Date/Language.pm @@ -0,0 +1,144 @@ + +package Date::Language; + +use strict; +use Time::Local; +use Carp; +use vars qw($VERSION @ISA); +require Date::Format; + +$VERSION = "1.10"; +@ISA = qw(Date::Format::Generic); + +sub new +{ + my $self = shift; + my $type = shift || $self; + + $type =~ s/^(\w+)$/Date::Language::$1/; + + croak "Bad language" + unless $type =~ /^[\w:]+$/; + + eval "require $type" + or croak $@; + + bless [], $type; +} + +# Stop AUTOLOAD being called ;-) +sub DESTROY {} + +sub AUTOLOAD +{ + use vars qw($AUTOLOAD); + + if($AUTOLOAD =~ /::strptime\Z/o) + { + my $self = $_[0]; + my $type = ref($self) || $self; + require Date::Parse; + + no strict 'refs'; + *{"${type}::strptime"} = Date::Parse::gen_parser( + \%{"${type}::DoW"}, + \%{"${type}::MoY"}, + \@{"${type}::Dsuf"}, + 1); + + goto &{"${type}::strptime"}; + } + + croak "Undefined method &$AUTOLOAD called"; +} + +sub str2time +{ + my $me = shift; + my @t = $me->strptime(@_); + + return undef + unless @t; + + my($ss,$mm,$hh,$day,$month,$year,$zone) = @t; + my @lt = localtime(time); + + $hh ||= 0; + $mm ||= 0; + $ss ||= 0; + + $month = $lt[4] + unless(defined $month); + + $day = $lt[3] + unless(defined $day); + + $year = ($month > $lt[4]) ? ($lt[5] - 1) : $lt[5] + unless(defined $year); + + return defined $zone ? timegm($ss,$mm,$hh,$day,$month,$year) - $zone + : timelocal($ss,$mm,$hh,$day,$month,$year); +} + +1; + +__END__ + + +=head1 NAME + +Date::Language - Language specific date formating and parsing + +=head1 SYNOPSIS + + use Date::Language; + + my $lang = Date::Language->new('German'); + $lang->time2str("%a %b %e %T %Y\n", time); + +=head1 DESCRIPTION + +L<Date::Language> provides objects to parse and format dates for specific languages. Available languages are + + Afar French Russian_cp1251 + Amharic Gedeo Russian_koi8r + Austrian German Sidama + Brazilian Greek Somali + Chinese Hungarian Spanish + Chinese_GB Icelandic Swedish + Czech Italian Tigrinya + Danish Norwegian TigrinyaEritrean + Dutch Oromo TigrinyaEthiopian + English Romanian Turkish + Finnish Russian + +=head1 METHODS + +=over + +=item time2str + +See L<Date::Format/time2str> + +=item strftime + +See L<Date::Format/strftime> + +=item ctime + +See L<Date::Format/ctime> + +=item asctime + +See L<Date::Format/asctime> + +=item str2time + +See L<Date::Parse/str2time> + +=item strptime + +See L<Date::Parse/strptime> + +=back + diff --git a/lib/Date/Language/Afar.pm b/lib/Date/Language/Afar.pm new file mode 100644 index 0000000..f67cf37 --- /dev/null +++ b/lib/Date/Language/Afar.pm @@ -0,0 +1,49 @@ +## +## Afar tables +## + +package Date::Language::Afar; + +use Date::Language (); +use vars qw(@ISA @DoW @DoWs @MoY @MoYs @AMPM @Dsuf %MoY %DoW $VERSION); +@ISA = qw(Date::Language); +$VERSION = "0.99"; + +@DoW = qw(Acaada Etleeni Talaata Arbaqa Kamiisi Gumqata Sabti); +@MoY = ( +"Qunxa Garablu", +"Kudo", +"Ciggilta Kudo", +"Agda Baxis", +"Caxah Alsa", +"Qasa Dirri", +"Qado Dirri", +"Liiqen", +"Waysu", +"Diteli", +"Ximoli", +"Kaxxa Garablu" +); +@DoWs = map { substr($_,0,3) } @DoW; +@MoYs = map { substr($_,0,3) } @MoY; +@AMPM = qw(saaku carra); + +@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); + +@MoY{@MoY} = (0 .. scalar(@MoY)); +@MoY{@MoYs} = (0 .. scalar(@MoYs)); +@DoW{@DoW} = (0 .. scalar(@DoW)); +@DoW{@DoWs} = (0 .. scalar(@DoWs)); + +# Formatting routines + +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] } + +1; diff --git a/lib/Date/Language/Amharic.pm b/lib/Date/Language/Amharic.pm new file mode 100644 index 0000000..a79984e --- /dev/null +++ b/lib/Date/Language/Amharic.pm @@ -0,0 +1,87 @@ +## +## Amharic tables +## + +package Date::Language::Amharic; + +use Date::Language (); +use vars qw(@ISA @DoW @DoWs @MoY @MoYs @AMPM @Dsuf %MoY %DoW $VERSION); +@ISA = qw(Date::Language); +$VERSION = "1.00"; + +if ( $] >= 5.006 ) { +@DoW = ( +"\x{12a5}\x{1211}\x{12f5}", +"\x{1230}\x{129e}", +"\x{121b}\x{12ad}\x{1230}\x{129e}", +"\x{1228}\x{1261}\x{12d5}", +"\x{1210}\x{1219}\x{1235}", +"\x{12d3}\x{122d}\x{1265}", +"\x{1245}\x{12f3}\x{121c}" +); +@MoY = ( +"\x{1303}\x{1295}\x{12e9}\x{12c8}\x{122a}", +"\x{134c}\x{1265}\x{1229}\x{12c8}\x{122a}", +"\x{121b}\x{122d}\x{127d}", +"\x{12a4}\x{1355}\x{1228}\x{120d}", +"\x{121c}\x{12ed}", +"\x{1301}\x{1295}", +"\x{1301}\x{120b}\x{12ed}", +"\x{12a6}\x{1308}\x{1235}\x{1275}", +"\x{1234}\x{1355}\x{1274}\x{121d}\x{1260}\x{122d}", +"\x{12a6}\x{12ad}\x{1270}\x{12cd}\x{1260}\x{122d}", +"\x{1296}\x{126c}\x{121d}\x{1260}\x{122d}", +"\x{12f2}\x{1234}\x{121d}\x{1260}\x{122d}" +); +@DoWs = map { substr($_,0,3) } @DoW; +@MoYs = map { substr($_,0,3) } @MoY; +@AMPM = ( "\x{1320}\x{12cb}\x{1275}", "\x{12a8}\x{1230}\x{12d3}\x{1275}" ); + +@Dsuf = ("\x{129b}" x 31); +} +else { +@DoW = ( +"እሑድ", +"ሰኞ", +"ማክሰኞ", +"ረቡዕ", +"ሐሙስ", +"ዓርብ", +"ቅዳሜ" +); +@MoY = ( +"ጃንዩወሪ", +"ፌብሩወሪ", +"ማርች", +"ኤፕረል", +"ሜይ", +"ጁን", +"ጁላይ", +"ኦገስት", +"ሴፕቴምበር", +"ኦክተውበር", +"ኖቬምበር", +"ዲሴምበር" +); +@DoWs = map { substr($_,0,9) } @DoW; +@MoYs = map { substr($_,0,9) } @MoY; +@AMPM = ( "ጠዋት", "ከሰዓት" ); + +@Dsuf = ("ኛ" x 31); +} + +@MoY{@MoY} = (0 .. scalar(@MoY)); +@MoY{@MoYs} = (0 .. scalar(@MoYs)); +@DoW{@DoW} = (0 .. scalar(@DoW)); +@DoW{@DoWs} = (0 .. scalar(@DoWs)); + +# Formatting routines + +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] } + +1; diff --git a/lib/Date/Language/Austrian.pm b/lib/Date/Language/Austrian.pm new file mode 100644 index 0000000..8ff398b --- /dev/null +++ b/lib/Date/Language/Austrian.pm @@ -0,0 +1,36 @@ +## +## Austrian tables +## + +package Date::Language::Austrian; + +use Date::Language (); +use vars qw(@ISA @DoW @DoWs @MoY @MoYs @AMPM @Dsuf %MoY %DoW $VERSION); +@ISA = qw(Date::Language); +$VERSION = "1.01"; + +@MoY = qw(Jnner Feber Mrz April Mai Juni + Juli August September Oktober November Dezember); +@MoYs = qw(Jn Feb Mr Apr Mai Jun Jul Aug Sep Oct Nov Dez); +@DoW = qw(Sonntag Montag Dienstag Mittwoch Donnerstag Freitag Samstag); +@DoWs = qw(Son Mon Die Mit Don Fre Sam); + +use Date::Language::English (); +@AMPM = @{Date::Language::English::AMPM}; +@Dsuf = @{Date::Language::English::Dsuf}; + +@MoY{@MoY} = (0 .. scalar(@MoY)); +@MoY{@MoYs} = (0 .. scalar(@MoYs)); +@DoW{@DoW} = (0 .. scalar(@DoW)); +@DoW{@DoWs} = (0 .. scalar(@DoWs)); + +# Formatting routines + +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] } + +1; diff --git a/lib/Date/Language/Brazilian.pm b/lib/Date/Language/Brazilian.pm new file mode 100644 index 0000000..fa4d15f --- /dev/null +++ b/lib/Date/Language/Brazilian.pm @@ -0,0 +1,35 @@ +## +## Brazilian tables, contributed by Christian Tosta (tosta@cce.ufmg.br) +## + +package Date::Language::Brazilian; + +use Date::Language (); +use vars qw(@ISA @DoW @DoWs @MoY @MoYs @AMPM @Dsuf %MoY %DoW $VERSION); +@ISA = qw(Date::Language); +$VERSION = "1.01"; + +@DoW = qw(Domingo Segunda Tera Quarta Quinta Sexta Sbado); +@MoY = qw(Janeiro Fevereiro Maro Abril Maio Junho + Julho Agosto Setembro Outubro Novembro Dezembro); +@DoWs = map { substr($_,0,3) } @DoW; +@MoYs = map { substr($_,0,3) } @MoY; +@AMPM = qw(AM PM); + +@Dsuf = (qw(mo ro do ro to to to mo vo no)) x 3; + +@MoY{@MoY} = (0 .. scalar(@MoY)); +@MoY{@MoYs} = (0 .. scalar(@MoYs)); +@DoW{@DoW} = (0 .. scalar(@DoW)); +@DoW{@DoWs} = (0 .. scalar(@DoWs)); + +# Formatting routines + +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] } + +1; diff --git a/lib/Date/Language/Chinese.pm b/lib/Date/Language/Chinese.pm new file mode 100644 index 0000000..abfb3c0 --- /dev/null +++ b/lib/Date/Language/Chinese.pm @@ -0,0 +1,36 @@ +## +## English tables +## + +package Date::Language::Chinese; + +use Date::Language (); +use vars qw(@ISA @DoW @DoWs @MoY @MoYs @AMPM @Dsuf %MoY %DoW $VERSION); +@ISA = qw(Date::Language); +$VERSION = "1.00"; + +@DoW = qw(星期日 星期一 星期二 星期三 星期四 星期五 星期六); +@MoY = qw(一月 二月 三月 四月 五月 六月 + 七月 八月 九月 十月 十一月 十二月); +@DoWs = map { $_ } @DoW; +@MoYs = map { $_ } @MoY; +@AMPM = qw(上午 下午); + +@Dsuf = (qw(日 日 日 日 日 日 日 日 日 日)) x 3; + +@MoY{@MoY} = (0 .. scalar(@MoY)); +@MoY{@MoYs} = (0 .. scalar(@MoYs)); +@DoW{@DoW} = (0 .. scalar(@DoW)); +@DoW{@DoWs} = (0 .. scalar(@DoWs)); + +# Formatting routines + +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_o { sprintf("%2d%s",$_[0]->[3],"日") } +1; diff --git a/lib/Date/Language/Chinese_GB.pm b/lib/Date/Language/Chinese_GB.pm new file mode 100644 index 0000000..7be0555 --- /dev/null +++ b/lib/Date/Language/Chinese_GB.pm @@ -0,0 +1,36 @@ +## +## English tables +## + +package Date::Language::Chinese_GB; + +use Date::Language (); +use vars qw(@ISA @DoW @DoWs @MoY @MoYs @AMPM @Dsuf %MoY %DoW $VERSION); +@ISA = qw(Date::Language); +$VERSION = "1.01"; + +@DoW = qw( һ ڶ ); +@MoY = qw(һ + ʮ ʮһ ʮ); +@DoWs = map { $_ } @DoW; +@MoYs = map { $_ } @MoY; +@AMPM = qw( ); + +@Dsuf = (qw( )) x 3; + +@MoY{@MoY} = (0 .. scalar(@MoY)); +@MoY{@MoYs} = (0 .. scalar(@MoYs)); +@DoW{@DoW} = (0 .. scalar(@DoW)); +@DoW{@DoWs} = (0 .. scalar(@DoWs)); + +# Formatting routines + +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_o { sprintf("%2d%s",$_[0]->[3],"") } +1; diff --git a/lib/Date/Language/Czech.pm b/lib/Date/Language/Czech.pm new file mode 100644 index 0000000..756f5c5 --- /dev/null +++ b/lib/Date/Language/Czech.pm @@ -0,0 +1,58 @@ +## +## Czech tables +## +## Contributed by Honza Pazdziora + +package Date::Language::Czech; + +use vars qw(@ISA @DoW @DoWs @MoY @MoYs @MoY2 @AMPM %MoY %DoW $VERSION); +@ISA = qw(Date::Language Date::Format::Generic); +$VERSION = "1.01"; + +@MoY = qw(leden nor bezen duben kvten erven ervenec srpen z + jen listopad prosinec); +@MoYs = qw(led nor be dub kv vn ec srp z j lis pro); +@MoY2 = @MoY; +for (@MoY2) + { s!en$!na! or s!ec$!ce! or s!ad$!adu! or s!or$!ora!; } + +@DoW = qw(nedle pondl ter steda tvrtek ptek sobota); +@DoWs = qw(Ne Po t St t P So); + +@AMPM = qw(dop. odp.); + +@MoY{@MoY} = (0 .. scalar(@MoY)); +@MoY{@MoYs} = (0 .. scalar(@MoYs)); +@DoW{@DoW} = (0 .. scalar(@DoW)); +@DoW{@DoWs} = (0 .. scalar(@DoWs)); + +# Formatting routines + +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_d { $_[0]->[3] } +sub format_m { $_[0]->[4] + 1 } +sub format_o { $_[0]->[3] . '.' } + +sub format_Q { $MoY2[$_[0]->[4]] } + +sub time2str { + my $ref = shift; + my @a = @_; + $a[0] =~ s/(%[do]\.?\s?)%B/$1%Q/; + $ref->SUPER::time2str(@a); + } + +sub strftime { + my $ref = shift; + my @a = @_; + $a[0] =~ s/(%[do]\.?\s?)%B/$1%Q/; + $ref->SUPER::time2str(@a); + } + +1; diff --git a/lib/Date/Language/Danish.pm b/lib/Date/Language/Danish.pm new file mode 100644 index 0000000..c43d085 --- /dev/null +++ b/lib/Date/Language/Danish.pm @@ -0,0 +1,36 @@ +##
+## Danish tables
+##
+
+package Date::Language::Danish;
+
+use Date::Language ();
+use vars qw(@ISA @DoW @DoWs @MoY @MoYs @AMPM @Dsuf %MoY %DoW $VERSION);
+@ISA = qw(Date::Language);
+$VERSION = "1.01";
+
+@MoY = qw(Januar Februar Marts April Maj Juni
+ Juli August September Oktober November December);
+@MoYs = qw(Jan Feb Mar Apr Maj Jun Jul Aug Sep Okt Nov Dec);
+@DoW = qw(Sndag Mandag Tirsdag Onsdag Torsdag Fredag Lrdag Sndag);
+@DoWs = qw(Sn Man Tir Ons Tor Fre Lr Sn);
+
+use Date::Language::English ();
+@AMPM = @{Date::Language::English::AMPM};
+@Dsuf = @{Date::Language::English::Dsuf};
+
+@MoY{@MoY} = (0 .. scalar(@MoY));
+@MoY{@MoYs} = (0 .. scalar(@MoYs));
+@DoW{@DoW} = (0 .. scalar(@DoW));
+@DoW{@DoWs} = (0 .. scalar(@DoWs));
+
+# Formatting routines
+
+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] }
+
+1;
diff --git a/lib/Date/Language/Dutch.pm b/lib/Date/Language/Dutch.pm new file mode 100644 index 0000000..219758b --- /dev/null +++ b/lib/Date/Language/Dutch.pm @@ -0,0 +1,40 @@ +## +## Dutch tables +## Contributed by Johannes la Poutre <jlpoutre@corp.nl.home.com> +## + +package Date::Language::Dutch; + +use Date::Language (); +use vars qw(@ISA @DoW @DoWs @MoY @MoYs @AMPM @Dsuf %MoY %DoW $VERSION); +@ISA = qw(Date::Language); +$VERSION = "1.02"; + +@MoY = qw(januari februari maart april mei juni juli + augustus september oktober november december); +@MoYs = map(substr($_, 0, 3), @MoY); +$MoYs[2] = 'mrt'; # mrt is more common (Frank Maas) +@DoW = map($_ . "dag", qw(zon maan dins woens donder vrij zater)); +@DoWs = map(substr($_, 0, 2), @DoW); + +# these aren't normally used... +@AMPM = qw(VM NM); +@Dsuf = ('e') x 31; + + +@MoY{@MoY} = (0 .. scalar(@MoY)); +@MoY{@MoYs} = (0 .. scalar(@MoYs)); +@DoW{@DoW} = (0 .. scalar(@DoW)); +@DoW{@DoWs} = (0 .. scalar(@DoWs)); + +# Formatting routines + +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_o { sprintf("%2de",$_[0]->[3]) } + +1; diff --git a/lib/Date/Language/English.pm b/lib/Date/Language/English.pm new file mode 100644 index 0000000..638cb3c --- /dev/null +++ b/lib/Date/Language/English.pm @@ -0,0 +1,37 @@ +## +## English tables +## + +package Date::Language::English; + +use Date::Language (); +use vars qw(@ISA @DoW @DoWs @MoY @MoYs @AMPM @Dsuf %MoY %DoW $VERSION); +@ISA = qw(Date::Language); +$VERSION = "1.01"; + +@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); + +@MoY{@MoY} = (0 .. scalar(@MoY)); +@MoY{@MoYs} = (0 .. scalar(@MoYs)); +@DoW{@DoW} = (0 .. scalar(@DoW)); +@DoW{@DoWs} = (0 .. scalar(@DoWs)); + +# Formatting routines + +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] } + +1; diff --git a/lib/Date/Language/Finnish.pm b/lib/Date/Language/Finnish.pm new file mode 100644 index 0000000..415b50c --- /dev/null +++ b/lib/Date/Language/Finnish.pm @@ -0,0 +1,45 @@ +## +## Finnish tables +## Contributed by Matthew Musgrove <muskrat@mindless.com> +## Corrected by roke +## + +package Date::Language::Finnish; + +use Date::Language (); +use vars qw(@ISA @DoW @DoWs @MoY @MoYs @AMPM @Dsuf %MoY %DoW $VERSION); +@ISA = qw(Date::Language); +$VERSION = "1.01"; + +# In Finnish, the names of the months and days are only capitalized at the beginning of sentences. +@MoY = map($_ . "kuu", qw(tammi helmi maalis huhti touko kes hein elo syys loka marras joulu)); +@DoW = qw(sunnuntai maanantai tiistai keskiviikko torstai perjantai lauantai); + +# it is not customary to use abbreviated names of months or days +# per Graham's suggestion: +@MoYs = @MoY; +@DoWs = @DoW; + +# the short form of ordinals +@Dsuf = ('.') x 31; + +# doesn't look like this is normally used... +@AMPM = qw(ap ip); + + +@MoY{@MoY} = (0 .. scalar(@MoY)); +@MoY{@MoYs} = (0 .. scalar(@MoYs)); +@DoW{@DoW} = (0 .. scalar(@DoW)); +@DoW{@DoWs} = (0 .. scalar(@DoWs)); + +# Formatting routines + +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_o { sprintf("%2de",$_[0]->[3]) } + +1;
\ No newline at end of file diff --git a/lib/Date/Language/French.pm b/lib/Date/Language/French.pm new file mode 100644 index 0000000..91b414c --- /dev/null +++ b/lib/Date/Language/French.pm @@ -0,0 +1,36 @@ +## +## French tables, contributed by Emmanuel Bataille (bem@residents.frmug.org) +## + +package Date::Language::French; + +use Date::Language (); +use vars qw(@ISA @DoW @DoWs @MoY @MoYs @AMPM @Dsuf %MoY %DoW $VERSION); +@ISA = qw(Date::Language); +$VERSION = "1.04"; + +@DoW = qw(dimanche lundi mardi mercredi jeudi vendredi samedi); +@MoY = qw(janvier fvrier mars avril mai juin + juillet aot septembre octobre novembre dcembre); +@DoWs = map { substr($_,0,3) } @DoW; +@MoYs = map { substr($_,0,3) } @MoY; +$MoYs[6] = 'jul'; +@AMPM = qw(AM PM); + +@Dsuf = ((qw(er e e e e e e e e e)) x 3, 'er'); + +@MoY{@MoY} = (0 .. scalar(@MoY)); +@MoY{@MoYs} = (0 .. scalar(@MoYs)); +@DoW{@DoW} = (0 .. scalar(@DoW)); +@DoW{@DoWs} = (0 .. scalar(@DoWs)); + +# Formatting routines + +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] } + +1; diff --git a/lib/Date/Language/Gedeo.pm b/lib/Date/Language/Gedeo.pm new file mode 100644 index 0000000..c18ad8c --- /dev/null +++ b/lib/Date/Language/Gedeo.pm @@ -0,0 +1,51 @@ +## +## Gedeo tables +## + +package Date::Language::Gedeo; + +use Date::Language (); +use vars qw(@ISA @DoW @DoWs @MoY @MoYs @AMPM @Dsuf %MoY %DoW $VERSION); +@ISA = qw(Date::Language); +$VERSION = "0.99"; + +@DoW = qw( Sanbbattaa Sanno Masano Roobe Hamusse Arbe Qiddamme); +@MoY = ( +"Oritto", +"Birre'a", +"Onkkollessa", +"Saddasa", +"Arrasa", +"Qammo", +"Ella", +"Waacibajje", +"Canissa", +"Addolessa", +"Bittitotessa", +"Hegeya" +); +@DoWs = map { substr($_,0,3) } @DoW; +$DoWs[0] = "Snb"; +$DoWs[1] = "Sno"; +@MoYs = map { substr($_,0,3) } @MoY; +@AMPM = qw(gorsa warreti-udumma); + +@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); + +@MoY{@MoY} = (0 .. scalar(@MoY)); +@MoY{@MoYs} = (0 .. scalar(@MoYs)); +@DoW{@DoW} = (0 .. scalar(@DoW)); +@DoW{@DoWs} = (0 .. scalar(@DoWs)); + +# Formatting routines + +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] } + +1; diff --git a/lib/Date/Language/German.pm b/lib/Date/Language/German.pm new file mode 100644 index 0000000..11242c4 --- /dev/null +++ b/lib/Date/Language/German.pm @@ -0,0 +1,37 @@ +## +## German tables +## + +package Date::Language::German; + +use Date::Language (); +use vars qw(@ISA @DoW @DoWs @MoY @MoYs @AMPM @Dsuf %MoY %DoW $VERSION); +@ISA = qw(Date::Language); +$VERSION = "1.02"; + +@MoY = qw(Januar Februar Mrz April Mai Juni + Juli August September Oktober November Dezember); +@MoYs = qw(Jan Feb Mr Apr Mai Jun Jul Aug Sep Okt Nov Dez); +@DoW = qw(Sonntag Montag Dienstag Mittwoch Donnerstag Freitag Samstag); +@DoWs = qw(Son Mon Die Mit Don Fre Sam); + +use Date::Language::English (); +@AMPM = @{Date::Language::English::AMPM}; +@Dsuf = @{Date::Language::English::Dsuf}; + +@MoY{@MoY} = (0 .. scalar(@MoY)); +@MoY{@MoYs} = (0 .. scalar(@MoYs)); +@DoW{@DoW} = (0 .. scalar(@DoW)); +@DoW{@DoWs} = (0 .. scalar(@DoWs)); + +# Formatting routines + +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_o { sprintf("%2d.",$_[0]->[3]) } + +1; diff --git a/lib/Date/Language/Greek.pm b/lib/Date/Language/Greek.pm new file mode 100644 index 0000000..00f917c --- /dev/null +++ b/lib/Date/Language/Greek.pm @@ -0,0 +1,91 @@ +## +## Greek tables +## +## Traditional date format is: DoW DD{eta} MoY Year (%A %o %B %Y) +## +## Matthew Musgrove <muskrat@mindless.com> +## Translations gratiously provided by Menelaos Stamatelos <men@kwsn.net> +## This module returns unicode (utf8) encoded characters. You will need to +## take the necessary steps for this to display correctly. +## + +package Date::Language::Greek; + +use utf8; +use Date::Language (); +use vars qw(@ISA @DoW @DoWs @MoY @MoYs @AMPM @Dsuf %MoY %DoW $VERSION); +@ISA = qw(Date::Language); +$VERSION = "1.00"; + +@DoW = ( +"\x{039a}\x{03c5}\x{03c1}\x{03b9}\x{03b1}\x{03ba}\x{03ae}", +"\x{0394}\x{03b5}\x{03c5}\x{03c4}\x{03ad}\x{03c1}\x{03b1}", +"\x{03a4}\x{03c1}\x{03af}\x{03c4}\x{03b7}", +"\x{03a4}\x{03b5}\x{03c4}\x{03ac}\x{03c1}\x{03c4}\x{03b7}", +"\x{03a0}\x{03ad}\x{03bc}\x{03c0}\x{03c4}\x{03b7}", +"\x{03a0}\x{03b1}\x{03c1}\x{03b1}\x{03c3}\x{03ba}\x{03b5}\x{03c5}\x{03ae}", +"\x{03a3}\x{03ac}\x{03b2}\x{03b2}\x{03b1}\x{03c4}\x{03bf}", +); + +@MoY = ( +"\x{0399}\x{03b1}\x{03bd}\x{03bf}\x{03c5}\x{03b1}\x{03c1}\x{03af}\x{03bf}\x{03c5}", +"\x{03a6}\x{03b5}\x{03b2}\x{03c1}\x{03bf}\x{03c5}\x{03b1}\x{03c1}\x{03af}\x{03bf}\x{03c5}", +"\x{039c}\x{03b1}\x{03c1}\x{03c4}\x{03af}\x{03bf}\x{03c5}", +"\x{0391}\x{03c0}\x{03c1}\x{03b9}\x{03bb}\x{03af}\x{03c5}", +"\x{039c}\x{03b1}\x{0390}\x{03bf}\x{03c5}", +"\x{0399}\x{03bf}\x{03c5}\x{03bd}\x{03af}\x{03bf}\x{03c5}", +"\x{0399}\x{03bf}\x{03c5}\x{03bb}\x{03af}\x{03bf}\x{03c5}", +"\x{0391}\x{03c5}\x{03b3}\x{03bf}\x{03cd}\x{03c3}\x{03c4}\x{03bf}\x{03c5}", +"\x{03a3}\x{03b5}\x{03c0}\x{03c4}\x{03b5}\x{03bc}\x{03c4}\x{03bf}\x{03c5}", +"\x{039f}\x{03ba}\x{03c4}\x{03c9}\x{03b2}\x{03c1}\x{03af}\x{03bf}\x{03c5}", +"\x{039d}\x{03bf}\x{03b5}\x{03bc}\x{03b2}\x{03c1}\x{03af}\x{03bf}\x{03c5}", +"\x{0394}\x{03b5}\x{03ba}\x{03b5}\x{03bc}\x{03b2}\x{03c1}\x{03bf}\x{03c5}", +); + +@DoWs = ( +"\x{039a}\x{03c5}", +"\x{0394}\x{03b5}", +"\x{03a4}\x{03c1}", +"\x{03a4}\x{03b5}", +"\x{03a0}\x{03b5}", +"\x{03a0}\x{03b1}", +"\x{03a3}\x{03b1}", +); +@MoYs = ( +"\x{0399}\x{03b1}\x{03bd}", +"\x{03a6}\x{03b5}", +"\x{039c}\x{03b1}\x{03c1}", +"\x{0391}\x{03c0}\x{03c1}", +"\x{039c}\x{03b1}", +"\x{0399}\x{03bf}\x{03c5}\x{03bd}", +"\x{0399}\x{03bf}\x{03c5}\x{03bb}", +"\x{0391}\x{03c5}\x{03b3}", +"\x{03a3}\x{03b5}\x{03c0}", +"\x{039f}\x{03ba}", +"\x{039d}\x{03bf}", +"\x{0394}\x{03b5}", +); + +@AMPM = ("\x{03c0}\x{03bc}", "\x{03bc}\x{03bc}"); + +@Dsuf = ("\x{03b7}" x 31); + +@MoY{@MoY} = (0 .. scalar(@MoY)); +@MoY{@MoYs} = (0 .. scalar(@MoYs)); +@DoW{@DoW} = (0 .. scalar(@DoW)); +@DoW{@DoWs} = (0 .. scalar(@DoWs)); + +# Formatting routines + +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_o { sprintf("%2d%s",$_[0]->[3],"\x{03b7}") } +sub format_p { $_[0]->[2] >= 12 ? $AMPM[1] : $AMPM[0] } + +1; + + + diff --git a/lib/Date/Language/Hungarian.pm b/lib/Date/Language/Hungarian.pm new file mode 100644 index 0000000..d9c838d --- /dev/null +++ b/lib/Date/Language/Hungarian.pm @@ -0,0 +1,88 @@ +## +## Hungarian tables based on English +## +# +# This is a just-because-I-stumbled-across-it +# -and-my-wife-is-Hungarian release: if Graham or +# someone adds to docs to Date::Format, I'd be +# glad to correct bugs and extend as neeed. +# + +package Date::Language::Hungarian; + +=head1 NAME + +Date::Language::Hungarian - Magyar format for Date::Format + +=head1 SYNOPSIS + + my $lang = Date::Language->new('Hungarian'); + print $lang->time2str("%a %b %e %T %Y", time); + + @lt = localtime(time); + print $lang->time2str($template, time); + print $lang->strftime($template, @lt); + + print $lang->time2str($template, time, $zone); + print $lang->strftime($template, @lt, $zone); + + print $lang->ctime(time); + print $lang->asctime(@lt); + + print $lang->ctime(time, $zone); + print $lang->asctime(@lt, $zone); + +See L<Date::Format>. + +=head1 AUTHOR + +Paula Goddard (paula -at- paulacska -dot- com) + +=head1 LICENCE + +Made available under the same terms as Perl itself. + +=cut + +use strict; +use warnings; +use base "Date::Language"; +use vars qw( @DoW @DoWs @MoY @MoYs @AMPM @Dsuf %MoY %DoW $VERSION); +$VERSION = "1.01"; + +@DoW = qw(Vasrnap Htf Kedd Szerda Cstrtk Pntek Szombat); +@MoY = qw(Janur Februr Mrcius prilis Mjus Jnius + Jlius Augusztus Szeptember Oktber November December); +@DoWs = map { substr($_,0,3) } @DoW; +@MoYs = map { substr($_,0,3) } @MoY; +@AMPM = qw(DE. DU.); + +# There is no 'th or 'nd in Hungarian, just a dot +@Dsuf = (".") x 31; + +@MoY{@MoY} = (0 .. scalar(@MoY)); +@MoY{@MoYs} = (0 .. scalar(@MoYs)); +@DoW{@DoW} = (0 .. scalar(@DoW)); +@DoW{@DoWs} = (0 .. scalar(@DoWs)); + +# Formatting routines + +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_o { $_[0]->[3].'.' } + + + +sub format_D { &format_y . "." . &format_m . "." . &format_d } + +sub format_y { sprintf("%02d",$_[0]->[5] % 100) } +sub format_d { sprintf("%02d",$_[0]->[3]) } +sub format_m { sprintf("%02d",$_[0]->[4] + 1) } + + +1; diff --git a/lib/Date/Language/Icelandic.pm b/lib/Date/Language/Icelandic.pm new file mode 100644 index 0000000..5ca3ee3 --- /dev/null +++ b/lib/Date/Language/Icelandic.pm @@ -0,0 +1,36 @@ +## +## Icelandic tables +## + +package Date::Language::Icelandic; + +use Date::Language (); +use vars qw(@ISA @DoW @DoWs @MoY @MoYs @AMPM @Dsuf %MoY %DoW $VERSION); +@ISA = qw(Date::Language); +$VERSION = "1.01"; + +@MoY = qw(Janar Febrar Mars Aprl Ma Jni + Jli gst September Oktber Nvember Desember); +@MoYs = qw(Jan Feb Mar Apr Ma Jn Jl g Sep Okt Nv Des); +@DoW = qw(Sunnudagur Mnudagur rijudagur Mivikudagur Fimmtudagur Fstudagur Laugardagur Sunnudagur); +@DoWs = qw(Sun Mn ri Mi Fim Fs Lau Sun); + +use Date::Language::English (); +@AMPM = @{Date::Language::English::AMPM}; +@Dsuf = @{Date::Language::English::Dsuf}; + +@MoY{@MoY} = (0 .. scalar(@MoY)); +@MoY{@MoYs} = (0 .. scalar(@MoYs)); +@DoW{@DoW} = (0 .. scalar(@DoW)); +@DoW{@DoWs} = (0 .. scalar(@DoWs)); + +# Formatting routines + +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] } + +1; diff --git a/lib/Date/Language/Italian.pm b/lib/Date/Language/Italian.pm new file mode 100644 index 0000000..6db0a8e --- /dev/null +++ b/lib/Date/Language/Italian.pm @@ -0,0 +1,36 @@ +## +## Italian tables +## + +package Date::Language::Italian; + +use Date::Language (); +use vars qw(@ISA @DoW @DoWs @MoY @MoYs @AMPM @Dsuf %MoY %DoW $VERSION); +@ISA = qw(Date::Language); +$VERSION = "1.01"; + +@MoY = qw(Gennaio Febbraio Marzo Aprile Maggio Giugno + Luglio Agosto Settembre Ottobre Novembre Dicembre); +@MoYs = qw(Gen Feb Mar Apr Mag Giu Lug Ago Set Ott Nov Dic); +@DoW = qw(Domenica Lunedi Martedi Mercoledi Giovedi Venerdi Sabato); +@DoWs = qw(Dom Lun Mar Mer Gio Ven Sab); + +use Date::Language::English (); +@AMPM = @{Date::Language::English::AMPM}; +@Dsuf = @{Date::Language::English::Dsuf}; + +@MoY{@MoY} = (0 .. scalar(@MoY)); +@MoY{@MoYs} = (0 .. scalar(@MoYs)); +@DoW{@DoW} = (0 .. scalar(@DoW)); +@DoW{@DoWs} = (0 .. scalar(@DoWs)); + +# Formatting routines + +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] } + +1; diff --git a/lib/Date/Language/Norwegian.pm b/lib/Date/Language/Norwegian.pm new file mode 100644 index 0000000..bbd997f --- /dev/null +++ b/lib/Date/Language/Norwegian.pm @@ -0,0 +1,36 @@ +## +## Norwegian tables +## + +package Date::Language::Norwegian; + +use Date::Language (); +use vars qw(@ISA @DoW @DoWs @MoY @MoYs @AMPM @Dsuf %MoY %DoW $VERSION); +@ISA = qw(Date::Language); +$VERSION = "1.01"; + +@MoY = qw(Januar Februar Mars April Mai Juni + Juli August September Oktober November Desember); +@MoYs = qw(Jan Feb Mar Apr Mai Jun Jul Aug Sep Okt Nov Des); +@DoW = qw(Sndag Mandag Tirsdag Onsdag Torsdag Fredag Lrdag Sndag); +@DoWs = qw(Sn Man Tir Ons Tor Fre Lr Sn); + +use Date::Language::English (); +@AMPM = @{Date::Language::English::AMPM}; +@Dsuf = @{Date::Language::English::Dsuf}; + +@MoY{@MoY} = (0 .. scalar(@MoY)); +@MoY{@MoYs} = (0 .. scalar(@MoYs)); +@DoW{@DoW} = (0 .. scalar(@DoW)); +@DoW{@DoWs} = (0 .. scalar(@DoWs)); + +# Formatting routines + +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] } + +1; diff --git a/lib/Date/Language/Oromo.pm b/lib/Date/Language/Oromo.pm new file mode 100644 index 0000000..b6a6230 --- /dev/null +++ b/lib/Date/Language/Oromo.pm @@ -0,0 +1,37 @@ +## +## Oromo tables +## + +package Date::Language::Oromo; + +use Date::Language (); +use vars qw(@ISA @DoW @DoWs @MoY @MoYs @AMPM @Dsuf %MoY %DoW $VERSION); +@ISA = qw(Date::Language); +$VERSION = "0.99"; + +@DoW = qw(Dilbata Wiixata Qibxata Roobii Kamiisa Jimaata Sanbata); +@MoY = qw(Amajjii Guraandhala Bitooteessa Elba Caamsa Waxabajjii + Adooleessa Hagayya Fuulbana Onkololeessa Sadaasa Muddee); +@DoWs = map { substr($_,0,3) } @DoW; +@MoYs = map { substr($_,0,3) } @MoY; +@AMPM = qw(WD WB); + +@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); + +@MoY{@MoY} = (0 .. scalar(@MoY)); +@MoY{@MoYs} = (0 .. scalar(@MoYs)); +@DoW{@DoW} = (0 .. scalar(@DoW)); +@DoW{@DoWs} = (0 .. scalar(@DoWs)); + +# Formatting routines + +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] } + +1; diff --git a/lib/Date/Language/Romanian.pm b/lib/Date/Language/Romanian.pm new file mode 100644 index 0000000..cbd2c8c --- /dev/null +++ b/lib/Date/Language/Romanian.pm @@ -0,0 +1,37 @@ +## +## Italian tables +## + +package Date::Language::Romanian; + +use Date::Language (); +use vars qw(@ISA @DoW @DoWs @MoY @MoYs @AMPM @Dsuf %MoY %DoW $VERSION); +@ISA = qw(Date::Language); +$VERSION = "1.01"; + +@MoY = qw(ianuarie februarie martie aprilie mai iunie + iulie august septembrie octombrie noembrie decembrie); +@DoW = qw(duminica luni marti miercuri joi vineri sambata); +@DoWs = map { substr($_,0,3) } @DoW; +@MoYs = map { substr($_,0,3) } @MoY; + +@AMPM = qw(AM PM); + +@Dsuf = ('') x 31; + + +@MoY{@MoY} = (0 .. scalar(@MoY)); +@MoY{@MoYs} = (0 .. scalar(@MoYs)); +@DoW{@DoW} = (0 .. scalar(@DoW)); +@DoW{@DoWs} = (0 .. scalar(@DoWs)); + +# Formatting routines + +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] } + +1; diff --git a/lib/Date/Language/Russian.pm b/lib/Date/Language/Russian.pm new file mode 100644 index 0000000..ca9f414 --- /dev/null +++ b/lib/Date/Language/Russian.pm @@ -0,0 +1,49 @@ +## +## Russian tables +## +## Contributed by Danil Pismenny <dapi@mail.ru> + +package Date::Language::Russian; + +use vars qw(@ISA @DoW @DoWs @MoY @MoYs @MoY2 @AMPM %MoY %DoW $VERSION); +@ISA = qw(Date::Language Date::Format::Generic); +$VERSION = "1.01"; + +@MoY = qw( ); +@MoY2 = qw( ); +@MoYs = qw( ); + +@DoW = qw( ); +@DoWs = qw( ); +@DoWs2 = qw( ); + +@AMPM = qw( ); + +@MoY{@MoY} = (0 .. scalar(@MoY)); +@MoY{@MoYs} = (0 .. scalar(@MoYs)); +@DoW{@DoW} = (0 .. scalar(@DoW)); +@DoW{@DoWs} = (0 .. scalar(@DoWs)); + +# Formatting routines + +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_d { $_[0]->[3] } +sub format_m { $_[0]->[4] + 1 } +sub format_o { $_[0]->[3] . '.' } + +sub format_Q { $MoY2[$_[0]->[4]] } + +sub str2time { + my ($self,$value) = @_; + map {$value=~s/(\s|^)$DoWs2[$_](\s)/$DoWs[$_]$2/ig} (0..6); + $value=~s/(\s+|^)(\s+)/$1$2/; + return $self->SUPER::str2time($value); +} + +1; diff --git a/lib/Date/Language/Russian_cp1251.pm b/lib/Date/Language/Russian_cp1251.pm new file mode 100755 index 0000000..cc28e6e --- /dev/null +++ b/lib/Date/Language/Russian_cp1251.pm @@ -0,0 +1,39 @@ +## +## Russian cp1251 +## + +package Date::Language::Russian_cp1251; + +use Date::Language (); +use vars qw(@ISA @DoW @DoWs @MoY @MoYs @AMPM @Dsuf %MoY %DoW $VERSION); +@ISA = qw(Date::Language); +$VERSION = "1.01"; + +@DoW = qw( ); +@MoY = qw( + ); +@DoWs = qw( ); +#@DoWs = map { substr($_,0,3) } @DoW; +@MoYs = map { substr($_,0,3) } @MoY; +@AMPM = qw(AM PM); + +@Dsuf = ('e') x 31; +#@Dsuf[11,12,13] = qw( ); +#@Dsuf[30,31] = qw( ); + +@MoY{@MoY} = (0 .. scalar(@MoY)); +@MoY{@MoYs} = (0 .. scalar(@MoYs)); +@DoW{@DoW} = (0 .. scalar(@DoW)); +@DoW{@DoWs} = (0 .. scalar(@DoWs)); + +# Formatting routines + +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_o { sprintf("%2de",$_[0]->[3]) } + +1; diff --git a/lib/Date/Language/Russian_koi8r.pm b/lib/Date/Language/Russian_koi8r.pm new file mode 100755 index 0000000..53de8d0 --- /dev/null +++ b/lib/Date/Language/Russian_koi8r.pm @@ -0,0 +1,39 @@ +## +## Russian koi8r +## + +package Date::Language::Russian_koi8r; + +use Date::Language (); +use vars qw(@ISA @DoW @DoWs @MoY @MoYs @AMPM @Dsuf %MoY %DoW $VERSION); +@ISA = qw(Date::Language); +$VERSION = "1.01"; + +@DoW = qw( ); +@MoY = qw( + ); +@DoWs = qw( ); +#@DoWs = map { substr($_,0,3) } @DoW; +@MoYs = map { substr($_,0,3) } @MoY; +@AMPM = qw(AM PM); + +@Dsuf = ('e') x 31; +#@Dsuf[11,12,13] = qw( ); +#@Dsuf[30,31] = qw( ); + +@MoY{@MoY} = (0 .. scalar(@MoY)); +@MoY{@MoYs} = (0 .. scalar(@MoYs)); +@DoW{@DoW} = (0 .. scalar(@DoW)); +@DoW{@DoWs} = (0 .. scalar(@DoWs)); + +# Formatting routines + +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_o { sprintf("%2de",$_[0]->[3]) } + +1; diff --git a/lib/Date/Language/Sidama.pm b/lib/Date/Language/Sidama.pm new file mode 100644 index 0000000..bc26d7c --- /dev/null +++ b/lib/Date/Language/Sidama.pm @@ -0,0 +1,37 @@ +## +## Sidama tables +## + +package Date::Language::Sidama; + +use Date::Language (); +use vars qw(@ISA @DoW @DoWs @MoY @MoYs @AMPM @Dsuf %MoY %DoW $VERSION); +@ISA = qw(Date::Language); +$VERSION = "0.99"; + +@DoW = qw(Sambata Sanyo Maakisanyo Roowe Hamuse Arbe Qidaame); +@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(soodo hawwaro); + +@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); + +@MoY{@MoY} = (0 .. scalar(@MoY)); +@MoY{@MoYs} = (0 .. scalar(@MoYs)); +@DoW{@DoW} = (0 .. scalar(@DoW)); +@DoW{@DoWs} = (0 .. scalar(@DoWs)); + +# Formatting routines + +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] } + +1; diff --git a/lib/Date/Language/Somali.pm b/lib/Date/Language/Somali.pm new file mode 100644 index 0000000..5b24961 --- /dev/null +++ b/lib/Date/Language/Somali.pm @@ -0,0 +1,62 @@ +## +## Somali tables +## + +package Date::Language::Somali; + +use Date::Language (); +use vars qw(@ISA @DoW @DoWs @MoY @MoYs @AMPM @Dsuf %MoY %DoW $VERSION); +@ISA = qw(Date::Language); +$VERSION = "0.99"; + +@DoW = qw(Axad Isniin Salaaso Arbaco Khamiis Jimco Sabti); +@MoY = ( +"Bisha Koobaad", +"Bisha Labaad", +"Bisha Saddexaad", +"Bisha Afraad", +"Bisha Shanaad", +"Bisha Lixaad", +"Bisha Todobaad", +"Bisha Sideedaad", +"Bisha Sagaalaad", +"Bisha Tobnaad", +"Bisha Kow iyo Tobnaad", +"Bisha Laba iyo Tobnaad" +); +@DoWs = map { substr($_,0,3) } @DoW; +@MoYs = ( +"Kob", +"Lab", +"Sad", +"Afr", +"Sha", +"Lix", +"Tod", +"Sid", +"Sag", +"Tob", +"KIT", +"LIT" +); +@AMPM = qw(SN GN); + +@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); + +@MoY{@MoY} = (0 .. scalar(@MoY)); +@MoY{@MoYs} = (0 .. scalar(@MoYs)); +@DoW{@DoW} = (0 .. scalar(@DoW)); +@DoW{@DoWs} = (0 .. scalar(@DoWs)); + +# Formatting routines + +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] } + +1; diff --git a/lib/Date/Language/Spanish.pm b/lib/Date/Language/Spanish.pm new file mode 100644 index 0000000..d464ae7 --- /dev/null +++ b/lib/Date/Language/Spanish.pm @@ -0,0 +1,35 @@ +## +## Spanish tables +## + +package Date::Language::Spanish; + +use Date::Language (); +use vars qw(@ISA @DoW @DoWs @MoY @MoYs @AMPM @Dsuf %MoY %DoW $VERSION); +@ISA = qw(Date::Language); +$VERSION = "1.00"; + +@DoW = qw(domingo lunes martes mircoles jueves viernes sbado); +@MoY = qw(enero febrero marzo abril mayo junio + julio agosto septiembre octubre noviembre diciembre); +@DoWs = map { substr($_,0,3) } @DoW; +@MoYs = map { substr($_,0,3) } @MoY; +@AMPM = qw(AM PM); + +@Dsuf = ((qw(ro do ro to to to mo vo no mo)) x 3, 'ro'); + +@MoY{@MoY} = (0 .. scalar(@MoY)); +@MoY{@MoYs} = (0 .. scalar(@MoYs)); +@DoW{@DoW} = (0 .. scalar(@DoW)); +@DoW{@DoWs} = (0 .. scalar(@DoWs)); + +# Formatting routines + +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] } + +1; diff --git a/lib/Date/Language/Swedish.pm b/lib/Date/Language/Swedish.pm new file mode 100644 index 0000000..8f16594 --- /dev/null +++ b/lib/Date/Language/Swedish.pm @@ -0,0 +1,41 @@ +## +## Swedish tables +## Contributed by Matthew Musgrove <muskrat@mindless.com> +## Corrected by dempa +## + +package Date::Language::Swedish; + +use Date::Language (); +use vars qw(@ISA @DoW @DoWs @MoY @MoYs @AMPM @Dsuf %MoY %DoW $VERSION); +@ISA = qw(Date::Language); +$VERSION = "1.01"; + +@MoY = qw(januari februari mars april maj juni juli augusti september oktober november december); +@MoYs = map { substr($_,0,3) } @MoY; +@DoW = map($_ . "dagen", qw(sn mn tis ons tors fre lr)); +@DoWs = map { substr($_,0,2) } @DoW; + +# the ordinals are not typically used in modern times +@Dsuf = ('a' x 2, 'e' x 29); + +use Date::Language::English (); +@AMPM = @{Date::Language::English::AMPM}; + + +@MoY{@MoY} = (0 .. scalar(@MoY)); +@MoY{@MoYs} = (0 .. scalar(@MoYs)); +@DoW{@DoW} = (0 .. scalar(@DoW)); +@DoW{@DoWs} = (0 .. scalar(@DoWs)); + +# Formatting routines + +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_o { sprintf("%2de",$_[0]->[3]) } + +1; diff --git a/lib/Date/Language/Tigrinya.pm b/lib/Date/Language/Tigrinya.pm new file mode 100644 index 0000000..ce4fcb3 --- /dev/null +++ b/lib/Date/Language/Tigrinya.pm @@ -0,0 +1,58 @@ +## +## Tigrinya tables +## + +package Date::Language::Tigrinya; + +use Date::Language (); +use vars qw(@ISA @DoW @DoWs @MoY @MoYs @AMPM @Dsuf %MoY %DoW $VERSION); +@ISA = qw(Date::Language); +$VERSION = "1.00"; + +@DoW = ( +"\x{1230}\x{1295}\x{1260}\x{1275}", +"\x{1230}\x{1291}\x{12ed}", +"\x{1230}\x{1209}\x{1235}", +"\x{1228}\x{1261}\x{12d5}", +"\x{1213}\x{1219}\x{1235}", +"\x{12d3}\x{122d}\x{1262}", +"\x{1240}\x{12f3}\x{121d}" +); +@MoY = ( +"\x{1303}\x{1295}\x{12e9}\x{12c8}\x{122a}", +"\x{134c}\x{1265}\x{1229}\x{12c8}\x{122a}", +"\x{121b}\x{122d}\x{127d}", +"\x{12a4}\x{1355}\x{1228}\x{120d}", +"\x{121c}\x{12ed}", +"\x{1301}\x{1295}", +"\x{1301}\x{120b}\x{12ed}", +"\x{12a6}\x{1308}\x{1235}\x{1275}", +"\x{1234}\x{1355}\x{1274}\x{121d}\x{1260}\x{122d}", +"\x{12a6}\x{12ad}\x{1270}\x{12cd}\x{1260}\x{122d}", +"\x{1296}\x{126c}\x{121d}\x{1260}\x{122d}", +"\x{12f2}\x{1234}\x{121d}\x{1260}\x{122d}" +); +@DoWs = map { substr($_,0,3) } @DoW; +@MoYs = map { substr($_,0,3) } @MoY; +@AMPM = ( +"\x{1295}/\x{1230}", +"\x{12F5}/\x{1230}" +); + +@Dsuf = ("\x{12ed}" x 31); + +@MoY{@MoY} = (0 .. scalar(@MoY)); +@MoY{@MoYs} = (0 .. scalar(@MoYs)); +@DoW{@DoW} = (0 .. scalar(@DoW)); +@DoW{@DoWs} = (0 .. scalar(@DoWs)); + +# Formatting routines + +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] } + +1; diff --git a/lib/Date/Language/TigrinyaEritrean.pm b/lib/Date/Language/TigrinyaEritrean.pm new file mode 100644 index 0000000..7ab8d0f --- /dev/null +++ b/lib/Date/Language/TigrinyaEritrean.pm @@ -0,0 +1,93 @@ +## +## Tigrinya-Eritrean tables +## + +package Date::Language::TigrinyaEritrean; + +use Date::Language (); +use vars qw(@ISA @DoW @DoWs @MoY @MoYs @AMPM @Dsuf %MoY %DoW $VERSION); +@ISA = qw(Date::Language); +$VERSION = "1.00"; + +if ( $] >= 5.006 ) { +@DoW = ( +"\x{1230}\x{1295}\x{1260}\x{1275}", +"\x{1230}\x{1291}\x{12ed}", +"\x{1230}\x{1209}\x{1235}", +"\x{1228}\x{1261}\x{12d5}", +"\x{1213}\x{1219}\x{1235}", +"\x{12d3}\x{122d}\x{1262}", +"\x{1240}\x{12f3}\x{121d}" +); +@MoY = ( +"\x{1303}\x{1295}\x{12e9}\x{12c8}\x{122a}", +"\x{134c}\x{1265}\x{1229}\x{12c8}\x{122a}", +"\x{121b}\x{122d}\x{127d}", +"\x{12a4}\x{1355}\x{1228}\x{120d}", +"\x{121c}\x{12ed}", +"\x{1301}\x{1295}", +"\x{1301}\x{120b}\x{12ed}", +"\x{12a6}\x{1308}\x{1235}\x{1275}", +"\x{1234}\x{1355}\x{1274}\x{121d}\x{1260}\x{122d}", +"\x{12a6}\x{12ad}\x{1270}\x{12cd}\x{1260}\x{122d}", +"\x{1296}\x{126c}\x{121d}\x{1260}\x{122d}", +"\x{12f2}\x{1234}\x{121d}\x{1260}\x{122d}" +); +@DoWs = map { substr($_,0,3) } @DoW; +@MoYs = map { substr($_,0,3) } @MoY; +@AMPM = ( +"\x{1295}/\x{1230}", +"\x{12F5}/\x{1230}" +); + +@Dsuf = ("\x{12ed}" x 31); +} +else { +@DoW = ( +"ሰንበት", +"ሰኑይ", +"ሰሉስ", +"ረቡዕ", +"ሓሙስ", +"ዓርቢ", +"ቀዳም" +); +@MoY = ( +"ጥሪ", +"ለካቲት", +"መጋቢት", +"ሚያዝያ", +"ግንቦት", +"ሰነ", +"ሓምለ", +"ነሓሰ", +"መስከረም", +"ጥቅምቲ", +"ሕዳር", +"ታሕሳስ" +); +@DoWs = map { substr($_,0,9) } @DoW; +@MoYs = map { substr($_,0,9) } @MoY; +@AMPM = ( +"ን/ሰ", +"ድ/ሰ" +); + +@Dsuf = ("ይ" x 31); +} + +@MoY{@MoY} = (0 .. scalar(@MoY)); +@MoY{@MoYs} = (0 .. scalar(@MoYs)); +@DoW{@DoW} = (0 .. scalar(@DoW)); +@DoW{@DoWs} = (0 .. scalar(@DoWs)); + +# Formatting routines + +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] } + +1; diff --git a/lib/Date/Language/TigrinyaEthiopian.pm b/lib/Date/Language/TigrinyaEthiopian.pm new file mode 100644 index 0000000..84fb723 --- /dev/null +++ b/lib/Date/Language/TigrinyaEthiopian.pm @@ -0,0 +1,93 @@ +## +## Tigrinya-Ethiopian tables +## + +package Date::Language::TigrinyaEthiopian; + +use Date::Language (); +use vars qw(@ISA @DoW @DoWs @MoY @MoYs @AMPM @Dsuf %MoY %DoW $VERSION); +@ISA = qw(Date::Language); +$VERSION = "1.00"; + +if ( $] >= 5.006 ) { +@DoW = ( +"\x{1230}\x{1295}\x{1260}\x{1275}", +"\x{1230}\x{1291}\x{12ed}", +"\x{1230}\x{1209}\x{1235}", +"\x{1228}\x{1261}\x{12d5}", +"\x{1213}\x{1219}\x{1235}", +"\x{12d3}\x{122d}\x{1262}", +"\x{1240}\x{12f3}\x{121d}" +); +@MoY = ( +"\x{1303}\x{1295}\x{12e9}\x{12c8}\x{122a}", +"\x{134c}\x{1265}\x{1229}\x{12c8}\x{122a}", +"\x{121b}\x{122d}\x{127d}", +"\x{12a4}\x{1355}\x{1228}\x{120d}", +"\x{121c}\x{12ed}", +"\x{1301}\x{1295}", +"\x{1301}\x{120b}\x{12ed}", +"\x{12a6}\x{1308}\x{1235}\x{1275}", +"\x{1234}\x{1355}\x{1274}\x{121d}\x{1260}\x{122d}", +"\x{12a6}\x{12ad}\x{1270}\x{12cd}\x{1260}\x{122d}", +"\x{1296}\x{126c}\x{121d}\x{1260}\x{122d}", +"\x{12f2}\x{1234}\x{121d}\x{1260}\x{122d}" +); +@DoWs = map { substr($_,0,3) } @DoW; +@MoYs = map { substr($_,0,3) } @MoY; +@AMPM = ( +"\x{1295}/\x{1230}", +"\x{12F5}/\x{1230}" +); + +@Dsuf = ("\x{12ed}" x 31); +} +else { +@DoW = ( +"ሰንበት", +"ሰኑይ", +"ሰሉስ", +"ረቡዕ", +"ሓሙስ", +"ዓርቢ", +"ቀዳም" +); +@MoY = ( +"ጃንዩወሪ", +"ፌብሩወሪ", +"ማርች", +"ኤፕረል", +"ሜይ", +"ጁን", +"ጁላይ", +"ኦገስት", +"ሴፕቴምበር", +"ኦክተውበር", +"ኖቬምበር", +"ዲሴምበር" +); +@DoWs = map { substr($_,0,9) } @DoW; +@MoYs = map { substr($_,0,9) } @MoY; +@AMPM = ( +"ን/ሰ", +"ድ/ሰ" +); + +@Dsuf = ("ይ" x 31); +} + +@MoY{@MoY} = (0 .. scalar(@MoY)); +@MoY{@MoYs} = (0 .. scalar(@MoYs)); +@DoW{@DoW} = (0 .. scalar(@DoW)); +@DoW{@DoWs} = (0 .. scalar(@DoWs)); + +# Formatting routines + +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] } + +1; diff --git a/lib/Date/Language/Turkish.pm b/lib/Date/Language/Turkish.pm new file mode 100755 index 0000000..593e209 --- /dev/null +++ b/lib/Date/Language/Turkish.pm @@ -0,0 +1,59 @@ +#----------------------------------------------------# +# +# Turkish tables +# Burak Grsoy <burak@cpan.org> +# Last modified: Sat Nov 15 20:28:32 2003 +# +# use Date::Language; +# my $turkish = Date::Language->new('Turkish'); +# print $turkish->time2str("%e %b %Y, %a %T\n", time); +# print $turkish->str2time("25 Haz 1996 21:09:55 +0100"); +#----------------------------------------------------# + +package Date::Language::Turkish; +use Date::Language (); +use vars qw(@ISA @DoW @DoWs @MoY @MoYs @AMPM @Dsuf %MoY %DoW $VERSION %DsufMAP); +@ISA = qw(Date::Language); +$VERSION = "1.0"; + +@DoW = qw(Pazar Pazartesi Sal aramba Perembe Cuma Cumartesi); +@MoY = qw(Ocak ubat Mart Nisan Mays Haziran Temmuz Austos Eyll Ekim Kasm Aralk); +@DoWs = map { substr($_,0,3) } @DoW; +$DoWs[1] = 'Pzt'; # Since we'll get two 'Paz' s +$DoWs[-1] = 'Cmt'; # Since we'll get two 'Cum' s +@MoYs = map { substr($_,0,3) } @MoY; +@AMPM = ('',''); # no am-pm thingy + +# not easy as in english... maybe we can just use a dot "." ? :) +%DsufMAP = ( +(map {$_ => 'inci', $_+10 => 'inci', $_+20 => 'inci' } 1,2,5,8 ), +(map {$_ => 'nci', $_+10 => 'nci', $_+20 => 'nci' } 7 ), +(map {$_ => 'nci', $_+10 => 'nci', $_+20 => 'nci' } 2 ), +(map {$_ => 'nc', $_+10 => 'nc', $_+20 => 'nc' } 3,4 ), +(map {$_ => 'uncu', $_+10 => 'uncu', $_+20 => 'uncu' } 9 ), +(map {$_ => 'nc', $_+10 => 'nc', $_+20 => 'nc' } 6 ), +(map {$_ => 'uncu', } 10,30 ), + 20 => 'nci', + 31 => 'inci', +); + +@Dsuf = map{ $DsufMAP{$_} } sort {$a <=> $b} keys %DsufMAP; +@MoY{@MoY} = (0 .. scalar(@MoY)); +@MoY{@MoYs} = (0 .. scalar(@MoYs)); +@DoW{@DoW} = (0 .. scalar(@DoW)); +@DoW{@DoWs} = (0 .. scalar(@DoWs)); + +# Formatting routines + +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 { '' } # disable +sub format_P { '' } # disable +sub format_o { sprintf("%2d%s",$_[0]->[3],$Dsuf[$_[0]->[3]-1]) } + +1; + +__END__ diff --git a/lib/Date/Parse.pm b/lib/Date/Parse.pm new file mode 100644 index 0000000..12b04c1 --- /dev/null +++ b/lib/Date/Parse.pm @@ -0,0 +1,380 @@ +# 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::Parse; + +require 5.000; +use strict; +use vars qw($VERSION @ISA @EXPORT); +use Time::Local; +use Carp; +use Time::Zone; +use Exporter; + +@ISA = qw(Exporter); +@EXPORT = qw(&strtotime &str2time &strptime); + +$VERSION = "2.30"; + +my %month = ( + january => 0, + february => 1, + march => 2, + april => 3, + may => 4, + june => 5, + july => 6, + august => 7, + september => 8, + sept => 8, + october => 9, + november => 10, + december => 11, + ); + +my %day = ( + sunday => 0, + monday => 1, + tuesday => 2, + tues => 2, + wednesday => 3, + wednes => 3, + thursday => 4, + thur => 4, + thurs => 4, + friday => 5, + saturday => 6, + ); + +my @suf = (qw(th st nd rd th th th th th th)) x 3; +@suf[11,12,13] = qw(th th th); + +#Abbreviations + +map { $month{substr($_,0,3)} = $month{$_} } keys %month; +map { $day{substr($_,0,3)} = $day{$_} } keys %day; + +my $strptime = <<'ESQ'; + my %month = map { lc $_ } %$mon_ref; + my $daypat = join("|", map { lc $_ } reverse sort keys %$day_ref); + my $monpat = join("|", reverse sort keys %month); + my $sufpat = join("|", reverse sort map { lc $_ } @$suf_ref); + + my %ampm = ( + 'a' => 0, # AM + 'p' => 12, # PM + ); + + my($AM, $PM) = (0,12); + +sub { + + my $dtstr = lc shift; + my $merid = 24; + + my($year,$month,$day,$hh,$mm,$ss,$zone,$dst,$frac); + + $zone = tz_offset(shift) if @_; + + 1 while $dtstr =~ s#\([^\(\)]*\)# #o; + + $dtstr =~ s#(\A|\n|\Z)# #sog; + + # ignore day names + $dtstr =~ s#([\d\w\s])[\.\,]\s#$1 #sog; + $dtstr =~ s/,/ /g; + $dtstr =~ s#($daypat)\s*(den\s)?\b# #o; + # Time: 12:00 or 12:00:00 with optional am/pm + + return unless $dtstr =~ /\S/; + + if ($dtstr =~ s/\s(\d{4})([-:]?)(\d\d?)\2(\d\d?)(?:[-Tt ](\d\d?)(?:([-:]?)(\d\d?)(?:\6(\d\d?)(?:[.,](\d+))?)?)?)?(?=\D)/ /) { + ($year,$month,$day,$hh,$mm,$ss,$frac) = ($1,$3-1,$4,$5,$7,$8,$9); + } + + unless (defined $hh) { + if ($dtstr =~ s#[:\s](\d\d?):(\d\d?)(:(\d\d?)(?:\.\d+)?)?(z)?\s*(?:([ap])\.?m?\.?)?\s# #o) { + ($hh,$mm,$ss) = ($1,$2,$4); + $zone = 0 if $5; + $merid = $ampm{$6} if $6; + } + + # Time: 12 am + + elsif ($dtstr =~ s#\s(\d\d?)\s*([ap])\.?m?\.?\s# #o) { + ($hh,$mm,$ss) = ($1,0,0); + $merid = $ampm{$2}; + } + } + + if (defined $hh and $hh <= 12 and $dtstr =~ s# ([ap])\.?m?\.?\s# #o) { + $merid = $ampm{$1}; + } + + + unless (defined $year) { + # Date: 12-June-96 (using - . or /) + + if ($dtstr =~ s#\s(\d\d?)([\-\./])($monpat)(\2(\d\d+))?\s# #o) { + ($month,$day) = ($month{$3},$1); + $year = $5 if $5; + } + + # Date: 12-12-96 (using '-', '.' or '/' ) + + elsif ($dtstr =~ s#\s(\d+)([\-\./])(\d\d?)(\2(\d+))?\s# #o) { + ($month,$day) = ($1 - 1,$3); + + if ($5) { + $year = $5; + # Possible match for 1995-01-24 (short mainframe date format); + ($year,$month,$day) = ($1, $3 - 1, $5) if $month > 12; + return if length($year) > 2 and $year < 1901; + } + } + elsif ($dtstr =~ s#\s(\d+)\s*($sufpat)?\s*($monpat)# #o) { + ($month,$day) = ($month{$3},$1); + } + elsif ($dtstr =~ s#($monpat)\s*(\d+)\s*($sufpat)?\s# #o) { + ($month,$day) = ($month{$1},$2); + } + elsif ($dtstr =~ s#($monpat)([\/-])(\d+)[\/-]# #o) { + ($month,$day) = ($month{$1},$3); + } + + # Date: 961212 + + elsif ($dtstr =~ s#\s(\d\d)(\d\d)(\d\d)\s# #o) { + ($year,$month,$day) = ($1,$2-1,$3); + } + + $year = $1 if !defined($year) and $dtstr =~ s#\s(\d{2}(\d{2})?)[\s\.,]# #o; + + } + + # Zone + + $dst = 1 if $dtstr =~ s#\bdst\b##o; + + if ($dtstr =~ s#\s"?([a-z]{3,4})(dst|\d+[a-z]*|_[a-z]+)?"?\s# #o) { + $dst = 1 if $2 and $2 eq 'dst'; + $zone = tz_offset($1); + return unless defined $zone; + } + elsif ($dtstr =~ s#\s([a-z]{3,4})?([\-\+]?)-?(\d\d?):?(\d\d)?(00)?\s# #o) { + my $m = defined($4) ? "$2$4" : 0; + my $h = "$2$3"; + $zone = defined($1) ? tz_offset($1) : 0; + return unless defined $zone; + $zone += 60 * ($m + (60 * $h)); + } + + if ($dtstr =~ /\S/) { + # now for some dumb dates + if ($dtstr =~ s/^\s*(ut?|z)\s*$//) { + $zone = 0; + } + elsif ($dtstr =~ s#\s([a-z]{3,4})?([\-\+]?)-?(\d\d?)(\d\d)?(00)?\s# #o) { + my $m = defined($4) ? "$2$4" : 0; + my $h = "$2$3"; + $zone = defined($1) ? tz_offset($1) : 0; + return unless defined $zone; + $zone += 60 * ($m + (60 * $h)); + } + + return if $dtstr =~ /\S/o; + } + + if (defined $hh) { + if ($hh == 12) { + $hh = 0 if $merid == $AM; + } + elsif ($merid == $PM) { + $hh += 12; + } + } + + $year -= 1900 if defined $year && $year > 1900; + + $zone += 3600 if defined $zone && $dst; + $ss += "0.$frac" if $frac; + + return ($ss,$mm,$hh,$day,$month,$year,$zone); +} +ESQ + +use vars qw($day_ref $mon_ref $suf_ref $obj); + +sub gen_parser +{ + local($day_ref,$mon_ref,$suf_ref,$obj) = @_; + + if($obj) + { + my $obj_strptime = $strptime; + substr($obj_strptime,index($strptime,"sub")+6,0) = <<'ESQ'; + shift; # package +ESQ + my $sub = eval "$obj_strptime" or die $@; + return $sub; + } + + eval "$strptime" or die $@; + +} + +*strptime = gen_parser(\%day,\%month,\@suf); + +sub str2time +{ + my @t = strptime(@_); + + return undef + unless @t; + + my($ss,$mm,$hh,$day,$month,$year,$zone) = @t; + my @lt = localtime(time); + + $hh ||= 0; + $mm ||= 0; + $ss ||= 0; + + my $frac = $ss - int($ss); + $ss = int $ss; + + $month = $lt[4] + unless(defined $month); + + $day = $lt[3] + unless(defined $day); + + $year = ($month > $lt[4]) ? ($lt[5] - 1) : $lt[5] + unless(defined $year); + + return undef + unless($month <= 11 && $day >= 1 && $day <= 31 + && $hh <= 23 && $mm <= 59 && $ss <= 59); + + my $result; + + if (defined $zone) { + $result = eval { + local $SIG{__DIE__} = sub {}; # Ick! + timegm($ss,$mm,$hh,$day,$month,$year); + }; + return undef + if !defined $result + or $result == -1 + && join("",$ss,$mm,$hh,$day,$month,$year) + ne "595923311169"; + $result -= $zone; + } + else { + $result = eval { + local $SIG{__DIE__} = sub {}; # Ick! + timelocal($ss,$mm,$hh,$day,$month,$year); + }; + return undef + if !defined $result + or $result == -1 + && join("",$ss,$mm,$hh,$day,$month,$year) + ne join("",(localtime(-1))[0..5]); + } + + return $result + $frac; +} + +1; + +__END__ + + +=head1 NAME + +Date::Parse - Parse date strings into time values + +=head1 SYNOPSIS + + use Date::Parse; + + $time = str2time($date); + + ($ss,$mm,$hh,$day,$month,$year,$zone) = strptime($date); + +=head1 DESCRIPTION + +C<Date::Parse> provides two routines for parsing date strings into time values. + +=over 4 + +=item str2time(DATE [, ZONE]) + +C<str2time> parses C<DATE> and returns a unix time value, or undef upon failure. +C<ZONE>, if given, specifies the timezone to assume when parsing if the +date string does not specify a timezone. + +=item strptime(DATE [, ZONE]) + +C<strptime> takes the same arguments as str2time but returns an array of +values C<($ss,$mm,$hh,$day,$month,$year,$zone)>. Elements are only defined +if they could be extracted from the date string. The C<$zone> element is +the timezone offset in seconds from GMT. An empty array is returned upon +failure. + +=head1 MULTI-LANGUAGE SUPPORT + +Date::Parse is capable of parsing dates in several languages, these include +English, French, German and Italian. + + $lang = Date::Language->new('German'); + $lang->str2time("25 Jun 1996 21:09:55 +0100"); + +=head1 EXAMPLE DATES + +Below is a sample list of dates that are known to be parsable with Date::Parse + + 1995:01:24T09:08:17.1823213 ISO-8601 + 1995-01-24T09:08:17.1823213 + Wed, 16 Jun 94 07:29:35 CST Comma and day name are optional + Thu, 13 Oct 94 10:13:13 -0700 + Wed, 9 Nov 1994 09:50:32 -0500 (EST) Text in ()'s will be ignored. + 21 dec 17:05 Will be parsed in the current time zone + 21-dec 17:05 + 21/dec 17:05 + 21/dec/93 17:05 + 1999 10:02:18 "GMT" + 16 Nov 94 22:28:20 PST + +=head1 LIMITATION + +Date::Parse uses L<Time::Local> internally, so is limited to only parsing dates +which result in valid values for Time::Local::timelocal. This generally means dates +between 1901-12-17 00:00:00 GMT and 2038-01-16 23:59:59 GMT + +=head1 BUGS + +When both the month and the date are specified in the date as numbers +they are always parsed assuming that the month number comes before the +date. This is the usual format used in American dates. + +The reason why it is like this and not dynamic is that it must be +deterministic. Several people have suggested using the current locale, +but this will not work as the date being parsed may not be in the format +of the current locale. + +My plans to address this, which will be in a future release, is to allow +the programmer to state what order they want these values parsed in. + +=head1 AUTHOR + +Graham Barr <gbarr@pobox.com> + +=head1 COPYRIGHT + +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. + +=cut + diff --git a/lib/Time/Zone.pm b/lib/Time/Zone.pm new file mode 100644 index 0000000..8a40f91 --- /dev/null +++ b/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; diff --git a/t/cpanrt.t b/t/cpanrt.t new file mode 100644 index 0000000..32b37e7 --- /dev/null +++ b/t/cpanrt.t @@ -0,0 +1,55 @@ +use Date::Format qw(time2str strftime); +use Date::Parse qw(strptime str2time); + +print "1..8\n"; + +my $i = 1; + +{ # RT#45067 Date::Format with %z gives wrong results for half-hour timezones + + foreach my $zone (qw(-0430 -0445)) { + my $zone_str = time2str("%Z %z", time, $zone); + print "# $zone => $zone_str\n"; + print "not " unless $zone_str eq "$zone $zone"; + print "ok ", $i++, "\n"; + } +} + + +{ # RT#48164: Date::Parse unable to set seconds correctly + + foreach my $str ("2008.11.30 22:35 CET", "2008-11-30 22:35 CET") { + my @t = strptime($str); + my $t = join ":", map { defined($_) ? $_ : "-" } @t; + print "# $str => $t\n"; + print "not " unless $t eq "-:35:22:30:10:108:3600"; + print "ok ", $i++, "\n"; + } +} + +{ # RT#17396: Parse error for french date with 'mars' (march) as month + use Date::Language; + my $dateP = Date::Language->new('French'); + my $timestamp = $dateP->str2time('4 mars 2005'); + my ($ss, $mm, $hh, $day, $month, $year, $zone) = localtime $timestamp; + $month++; + $year += 1900; + my $date = "$day/$month/$year"; + print "# $date\n"; + print "not " unless $date eq "4/3/2005"; + print "ok ", $i++, "\n"; +} + +{ # [rt.cpan.org #52387] seconds since the Epoch, UCT + my $time = time; + my @lt = localtime(time); + print "not " unless strftime("%s", @lt) eq $time; + print "ok ", $i++, "\n"; + print "not " unless time2str("%s",$time) eq $time; + print "ok ", $i++, "\n"; +} + +{ # [rt.cpan.org #51664] Change in str2time behaviour between 1.16 and 1.19 + print "not " if str2time('16 Oct 09') < 0; + print "ok ", $i++, "\n"; +} diff --git a/t/date.t b/t/date.t new file mode 100644 index 0000000..a2649ae --- /dev/null +++ b/t/date.t @@ -0,0 +1,193 @@ +#!/usr/local/bin/perl -w + +use Date::Parse; +use Date::Format qw(time2str); + +$data = qq!1995-01-24 +1995-01-24T09:08:17.1823213 +- 1935-01-24T09:08:17 +- Fri Dec 17 00:00:00 1901 GMT +Tue Jan 16 23:59:59 2038 GMT +2001-02-02 00:00:00 GMT +2035-02-02 00:00:00 GMT +- 16 Jun 33 07:29:35 CST +2002-02-26-10:37:21.141 GMT +Wed, 16 Jun 94 07:29:35 CST +Wed, 16 Nov 94 07:29:35 CST +Mon, 21 Nov 94 07:42:23 CST +Mon, 21 Nov 94 04:28:18 CST +Tue, 15 Nov 94 09:15:10 GMT +Wed, 16 Nov 94 09:39:49 GMT +Wed, 16 Nov 94 09:23:17 GMT +Wed, 16 Nov 94 12:39:49 GMT +Wed, 16 Nov 94 14:03:06 GMT +Wed, 16 Nov 94 05:30:51 CST +Thu, 17 Nov 94 03:19:30 CST +Mon, 21 Nov 94 14:05:32 GMT +Mon, 14 Nov 94 15:08:49 CST +Wed, 16 Nov 94 14:48:06 GMT +Thu, 17 Nov 94 14:22:03 GMT +Wed, 16 Nov 94 14:36:00 GMT +Wed, 16 Nov 94 09:23:17 GMT +Wed, 16 Nov 94 10:01:43 GMT +Wed, 16 Nov 94 15:03:35 GMT +Mon, 21 Nov 94 13:55:19 GMT +Wed, 16 Nov 94 08:46:11 CST +21 dec 17:05 +21-dec 17:05 +21/dec 17:05 +21/dec/93 17:05 +dec/21/93 17:05 +Dec/21/1993 17:05:00 +dec-21-1993 17:05 +Dec-21-93 17:05:00 +dec 21 1994 17:05 +dec 21 94 17:05 +dec 21 94 17:05 GMT +dec 21 94 17:05 BST +dec 21 94 00:05 -1700 +dec 21 94 17:05 -1700 +Wed, 9 Nov 1994 09:50:32 -0500 (EST) +Thu, 13 Oct 94 10:13:13 -0700 +Sat, 19 Nov 1994 16:59:14 +0100 +Thu, 3 Nov 94 14:10:47 EST +Thu, 3 Nov 94 21:51:09 EST +Fri, 4 Nov 94 9:24:52 EST +Wed, 9 Nov 94 09:38:54 EST +Mon, 14 Nov 94 13:20:12 EST +Wed, 16 Nov 94 17:09:13 EST +Tue, 15 Nov 94 12:27:01 PST +Fri, 18 Nov 1994 07:34:05 -0600 +Mon, 21 Nov 94 14:34:28 -0500 +Fri, 18 Nov 1994 12:05:47 -0800 (PST) +Fri, 18 Nov 1994 12:36:26 -0800 (PST) +Wed, 16 Nov 1994 15:58:58 GMT +1999 10:02:18 "GMT" +Sun, 06 Nov 94 14:27:40 -0500 +Mon, 07 Nov 94 08:20:13 -0500 +Mon, 07 Nov 94 16:48:42 -0500 +Wed, 09 Nov 94 15:46:16 -0500 +Fri, 4 Nov 94 16:17:40 "PST +Wed, 16 Nov 94 12:43:37 "PST +Sun, 6 Nov 1994 02:38:17 -0800 +Tue, 1 Nov 1994 13:53:49 -0500 +Tue, 15 Nov 94 08:31:59 +0100 +Sun, 6 Nov 1994 11:09:12 -0500 (IST) +Fri, 4 Nov 94 12:52:10 EST +Mon, 31 Oct 1994 14:17:39 -0500 (EST) +Mon, 14 Nov 94 11:25:00 CST +Mon, 14 Nov 94 13:26:29 CST +Fri, 18 Nov 94 8:42:47 CST +Thu, 17 Nov 94 14:32:01 +0900 +Wed, 2 Nov 94 18:16:31 +0100 +Fri, 18 Nov 94 10:46:26 +0100 +Tue, 8 Nov 1994 22:39:28 +0200 +Wed, 16 Nov 1994 10:01:08 -0500 (EST) +Wed, 2 Nov 1994 16:59:42 -0800 +Wed, 9 Nov 94 10:00:23 PST +Fri, 18 Nov 94 17:01:43 PST +Mon, 14 Nov 1994 14:47:46 -0500 +Mon, 21 Nov 1994 04:56:04 -0500 (EST) +Mon, 21 Nov 1994 11:50:12 -0800 +Sat, 5 Nov 1994 14:04:16 -0600 (CST) +Sat, 05 Nov 94 13:10:13 MST +Wed, 02 Nov 94 10:47:48 -0800 +Wed, 02 Nov 94 13:19:15 -0800 +Thu, 03 Nov 94 15:27:07 -0800 +Fri, 04 Nov 94 09:12:12 -0800 +Wed, 9 Nov 1994 10:13:03 +0000 (GMT) +Wed, 9 Nov 1994 15:28:37 +0000 (GMT) +Wed, 2 Nov 1994 17:37:41 +0100 (MET) +05 Nov 94 14:22:19 PST +16 Nov 94 22:28:20 PST +Tue, 1 Nov 1994 19:51:15 -0800 +Wed, 2 Nov 94 12:21:23 GMT +Fri, 18 Nov 94 18:07:03 GMT +Wed, 16 Nov 1994 11:26:27 -0500 +Sun, 6 Nov 1994 13:48:49 -0500 +Tue, 8 Nov 1994 13:19:37 -0800 +Fri, 18 Nov 1994 11:01:12 -0800 +Mon, 21 Nov 1994 00:47:58 -0500 +Mon, 7 Nov 1994 14:22:48 -0800 (PST) +Wed, 16 Nov 1994 15:56:45 -0800 (PST) +Thu, 3 Nov 1994 13:17:47 +0000 +Wed, 9 Nov 1994 17:32:50 -0500 (EST) +Wed, 9 Nov 94 16:31:52 PST +Wed, 09 Nov 94 10:41:10 -0800 +Wed, 9 Nov 94 08:42:22 MST +Mon, 14 Nov 1994 08:32:13 -0800 +Mon, 14 Nov 1994 11:34:32 -0500 (EST) +Mon, 14 Nov 94 16:48:09 GMT +Tue, 15 Nov 1994 10:27:33 +0000 +Wed, 02 Nov 94 13:56:54 MST +Thu, 03 Nov 94 15:24:45 MST +Thu, 3 Nov 1994 15:13:53 -0700 (MST) +Fri, 04 Nov 94 08:15:13 MST +Thu, 3 Nov 94 18:15:47 EST +Tue, 08 Nov 94 07:02:33 MST +Thu, 3 Nov 94 18:15:47 EST +Tue, 15 Nov 94 07:26:05 MST +Wed, 2 Nov 1994 00:00:55 -0600 (CST) +Sun, 6 Nov 1994 01:19:13 -0600 (CST) +Mon, 7 Nov 1994 23:16:57 -0600 (CST) +Tue, 08 Nov 1994 13:21:21 -0600 +Mon, 07 Nov 94 13:47:37 PST +Tue, 08 Nov 94 11:23:19 PST +Tue, 01 Nov 1994 11:28:25 -0800 +Tue, 15 Nov 1994 13:11:47 -0800 +Tue, 15 Nov 1994 13:18:38 -0800 +Tue, 15 Nov 1994 0:18:38 -0800 +10:00:00Z +10:00:00 +10:00 +10:00 +100 +10:00 +0100 +20020722T100000Z +Jul 22 10:00:00 UTC 2002 +2002-07-22 10:00:00Z +2002-07-22 10:00:00 Z +2002-07-22 10:00 Z +2002-07-22 10:00Z +2002-07-22 10:00 +100 +2002-07-22 10:00 +0100 +!; + +@data = split(/\n/, $data); + +print "1..", 1+@data,"\n"; + +print defined(str2time("")) ? "not ok 1\n" : "ok 1\n"; + +$loop = 2; + +foreach (@data) +{ + my $pre_1970 = s/^-\s*//; + + if ($pre_1970 and $^O eq "MSWin32") { + print "ok ",$loop++," # skip\n"; + next; + } + + $time = str2time($_); + + if(defined $time) + { + $time = int $time; + + $x = time2str("%a %b %e %T %Y %Z",$time,'GMT'); + + printf "%-40s\t%s\n", $_,$x,"\n"; + + $y = str2time($x); + + print "",($y == $time) ? "ok $loop\n" : "not ok $loop # $y != $time\n"; + } + else + { + print "not ok $loop # $_\n"; + } + + $loop++; +} + diff --git a/t/format.t b/t/format.t new file mode 100644 index 0000000..15765c2 --- /dev/null +++ b/t/format.t @@ -0,0 +1,184 @@ + +use Date::Format qw(ctime time2str); +use Date::Language; + +print "1..152\n"; + +my $i = 1; + +$pkg = 'Date::Format::Generic'; + +while(<DATA>) { + chomp; + if (/^(\d+)/) { + $t = $1; + next; + } + elsif (/^(\w+)/) { + $pkg = Date::Language->new($1); + next; + } + + my($fmt,$res) = split(/\t+/,$_); + my $str = $pkg->time2str($fmt,$t,'GMT'); + print "# '$fmt'$res'$str'\nnot " unless $str eq $res; + print "ok ",$i++,"\n"; +} + +__DATA__ +936709362 # Tue Sep 7 11:22:42 1999 GMT +%y 99 +%Y 1999 +%% % +%a Tue +%A Tuesday +%b Sep +%B September +%c 09/07/99 13:02:42 +%C Tue Sep 7 13:02:42 GMT 1999 +%d 07 +%e 7 +%D 09/07/99 +%G 1026 +%h Sep +%H 13 +%I 01 +%j 250 +%k 13 +%l 1 +%L 9 +%m 09 +%M 02 +%o 7th +%p PM +%q 3 +%r 01:02:42 PM +%R 13:02 +%s 936709362 +%S 42 +%T 13:02:42 +%U 36 +%w 2 +%W 36 +%x 09/07/99 +%X 13:02:42 +%y 99 +%Y 1999 +%Z GMT +%z +0000 +%Od VII +%Oe VII +%OH XIII +%OI I +%Oj CCL +%Ok XIII +%Ol I +%Om IX +%OM II +%Oq III +%OY MCMXCIX +%Oy XCIX +German +%y 99 +%Y 1999 +%% % +%a Die +%A Dienstag +%b Sep +%B September +%c 09/07/99 13:02:42 +%C Die Sep 7 13:02:42 GMT 1999 +%d 07 +%e 7 +%D 09/07/99 +%h Sep +%H 13 +%I 01 +%j 250 +%k 13 +%l 1 +%L 9 +%m 09 +%M 02 +%o 7. +%p PM +%q 3 +%r 01:02:42 PM +%R 13:02 +%s 936709362 +%S 42 +%T 13:02:42 +%U 36 +%w 2 +%W 36 +%x 09/07/99 +%X 13:02:42 +%y 99 +%Y 1999 +%Z GMT +%z +0000 +%Od VII +%Oe VII +%OH XIII +%OI I +%Oj CCL +%Ok XIII +%Ol I +%Om IX +%OM II +%Oq III +%OY MCMXCIX +%Oy XCIX +Italian +%y 99 +%Y 1999 +%% % +%a Mar +%A Martedi +%b Set +%B Settembre +%c 09/07/99 13:02:42 +%C Mar Set 7 13:02:42 GMT 1999 +%d 07 +%e 7 +%D 09/07/99 +%h Set +%H 13 +%I 01 +%j 250 +%k 13 +%l 1 +%L 9 +%m 09 +%M 02 +%o 7th +%p PM +%q 3 +%r 01:02:42 PM +%R 13:02 +%s 936709362 +%S 42 +%T 13:02:42 +%U 36 +%w 2 +%W 36 +%x 09/07/99 +%X 13:02:42 +%y 99 +%Y 1999 +%Z GMT +%z +0000 +%Od VII +%Oe VII +%OH XIII +%OI I +%Oj CCL +%Ok XIII +%Ol I +%Om IX +%OM II +%Oq III +%OY MCMXCIX +%Oy XCIX +316051200 # Mon Jan 7 00:00:00 1980 GMT +%G 0 diff --git a/t/getdate.t b/t/getdate.t new file mode 100644 index 0000000..31b577b --- /dev/null +++ b/t/getdate.t @@ -0,0 +1,209 @@ +#!/usr/local/bin/perl -w + +#Thanks to Andreas Koenig for converting all those dates to numbers +#and adding the folloing acknowledgement into Date/t/getdate.t +#Thanks to Graham Barr for writing these tests. Slightly adjusted for +#the C version by Andreas Koenig, 96-06-08. + +use Date::Parse; + +$data = qq!1995-01-24 ;790905600 +1995-06-24 ;803952000 +92/01/02 12:01 ;694353660 +92/01/02 12:01 AM ;694310460 +92/01/02 12:01 PM ;694353660 +2002-11-02 11pm GMT ;1036278000 +2002-11-02 11 pm GMT ;1036278000 +1995-01-24 GMT ;790905600 +1995-01-24 BST ;790902000 +1995-06-24 GMT ;803952000 +1995-06-24 BST ;803948400 +1992-1-2 12:01 GMT ;694353660 +1992-1-2-12:01:00 GMT ;694353660 +Wed, 16 Jun 94 07:29:35 CST ;771773375 +Wed,16 Jun 94 07:29:35 CST ;771773375 +Wed, 16 Nov 94 07:29:35 CST ;784992575 +Mon, 21 Nov 94 07:42:23 CST ;785425343 +Mon, 21 Nov 94 04:28:18 CST ;785413698 +Tue, 15 Nov 94 09:15:10 GMT ;784890910 +Wed, 16 Nov 94 09:39:49 GMT ;784978789 +Wed, 16 Nov 94 09:23:17 GMT ;784977797 +Wed, 16 Nov 94 12:39:49 GMT ;784989589 +Wed, 16 Nov 94 14:03:06 GMT ;784994586 +Wed, 16 Nov 94 05:30:51 CST ;784985451 +Thu, 17 Nov 94 03:19:30 CST ;785063970 +1994:11:21T14:05:32+0000 ;785426732 +Mon, 21 Nov 94 14:05:32 GMT ;785426732 +Mon, 14 Nov 94 15:08:49 CST ;784847329 +Wed, 16 Nov 94 14:48:06 GMT ;784997286 +Thu, 17 Nov 94 14:22:03 GMT ;785082123 +Wed, 16 Nov 94 14:36:00 GMT ;784996560 +Wed, 16 Nov 94 09:23:17 GMT ;784977797 +Wed, 16 Nov 94 10:01:43 GMT ;784980103 +Wed, 16 Nov 94 15:03:35 GMT ;784998215 +Mon, 21 Nov 94 13:55:19 GMT ;785426119 +Wed, 16 Nov 94 08:46:11 CST ;784997171 +Wed, 9 Nov 1994 09:50:32 -0500 (EST) ;784392632 +Thu, 13 Oct 94 10:13:13 -0700 ;782068393 +Sat, 19 Nov 1994 16:59:14 +0100 ;785260754 +Thu, 3 Nov 94 14:10:47 EST ;783889847 +Thu, 3 Nov 94 21:51:09 EST ;783917469 +Fri, 4 Nov 94 9:24:52 EST ;783959092 +Wed, 9 Nov 94 09:38:54 EST ;784391934 +Mon, 14 Nov 94 13:20:12 EST ;784837212 +Wed, 16 Nov 94 17:09:13 EST ;785023753 +Tue, 15 Nov 94 12:27:01 PST ;784931221 +Fri, 18 Nov 1994 07:34:05 -0600 ;785165645 +Mon, 21 Nov 94 14:34:28 -0500 ;785446468 +Fri, 18 Nov 1994 12:05:47 -0800 (PST);785189147 +Fri, 18 Nov 1994 12:36:26 -0800 (PST);785190986 +Wed, 16 Nov 1994 15:58:58 GMT ;785001538 +Sun, 06 Nov 94 14:27:40 -0500 ;784150060 +Mon, 07 Nov 94 08:20:13 -0500 ;784214413 +Mon, 07 Nov 94 16:48:42 -0500 ;784244922 +Wed, 09 Nov 94 15:46:16 -0500 ;784413976 +Sun, 6 Nov 1994 02:38:17 -0800 ;784118297 +Tue, 1 Nov 1994 13:53:49 -0500 ;783716029 +Tue, 15 Nov 94 08:31:59 +0100 ;784884719 +Sun, 6 Nov 1994 11:09:12 -0500 (IST) ;784138152 +Fri, 4 Nov 94 12:52:10 EST ;783971530 +Mon, 31 Oct 1994 14:17:39 -0500 (EST);783631059 +Mon, 14 Nov 94 11:25:00 CST ;784833900 +Mon, 14 Nov 94 13:26:29 CST ;784841189 +Fri, 18 Nov 94 8:42:47 CST ;785169767 +Thu, 17 Nov 94 14:32:01 +0900 ;785050321 +Wed, 2 Nov 94 18:16:31 +0100 ;783796591 +Fri, 18 Nov 94 10:46:26 +0100 ;785151986 +Tue, 8 Nov 1994 22:39:28 +0200 ;784327168 +Wed, 16 Nov 1994 10:01:08 -0500 (EST);784998068 +Wed, 2 Nov 1994 16:59:42 -0800 ;783824382 +Wed, 9 Nov 94 10:00:23 PST ;784404023 +Fri, 18 Nov 94 17:01:43 PST ;785206903 +Mon, 14 Nov 1994 14:47:46 -0500 ;784842466 +Mon, 21 Nov 1994 04:56:04 -0500 (EST);785411764 +Mon, 21 Nov 1994 11:50:12 -0800 ;785447412 +Sat, 5 Nov 1994 14:04:16 -0600 (CST) ;784065856 +Sat, 05 Nov 94 13:10:13 MST ;784066213 +Wed, 02 Nov 94 10:47:48 -0800 ;783802068 +Wed, 02 Nov 94 13:19:15 -0800 ;783811155 +Thu, 03 Nov 94 15:27:07 -0800 ;783905227 +Fri, 04 Nov 94 09:12:12 -0800 ;783969132 +Wed, 9 Nov 1994 10:13:03 +0000 (GMT) ;784375983 +Wed, 9 Nov 1994 15:28:37 +0000 (GMT) ;784394917 +Wed, 2 Nov 1994 17:37:41 +0100 (MET) ;783794261 +05 Nov 94 14:22:19 PST ;784074139 +16 Nov 94 22:28:20 PST ;785053700 +Tue, 1 Nov 1994 19:51:15 -0800 ;783748275 +Wed, 2 Nov 94 12:21:23 GMT ;783778883 +Fri, 18 Nov 94 18:07:03 GMT ;785182023 +Wed, 16 Nov 1994 11:26:27 -0500 ;785003187 +Sun, 6 Nov 1994 13:48:49 -0500 ;784147729 +Tue, 8 Nov 1994 13:19:37 -0800 ;784329577 +Fri, 18 Nov 1994 11:01:12 -0800 ;785185272 +Mon, 21 Nov 1994 00:47:58 -0500 ;785396878 +Mon, 7 Nov 1994 14:22:48 -0800 (PST) ;784246968 +Wed, 16 Nov 1994 15:56:45 -0800 (PST);785030205 +Thu, 3 Nov 1994 13:17:47 +0000 ;783868667 +Wed, 9 Nov 1994 17:32:50 -0500 (EST) ;784420370 +Wed, 9 Nov 94 16:31:52 PST ;784427512 +Wed, 09 Nov 94 10:41:10 -0800 ;784406470 +Wed, 9 Nov 94 08:42:22 MST ;784395742 +Mon, 14 Nov 1994 08:32:13 -0800 ;784830733 +Mon, 14 Nov 1994 11:34:32 -0500 (EST);784830872 +Mon, 14 Nov 94 16:48:09 GMT ;784831689 +Tue, 15 Nov 1994 10:27:33 +0000 ;784895253 +Wed, 02 Nov 94 13:56:54 MST ;783809814 +Thu, 03 Nov 94 15:24:45 MST ;783901485 +Thu, 3 Nov 1994 15:13:53 -0700 (MST) ;783900833 +Fri, 04 Nov 94 08:15:13 MST ;783962113 +Thu, 3 Nov 94 18:15:47 EST ;783904547 +Tue, 08 Nov 94 07:02:33 MST ;784303353 +Thu, 3 Nov 94 18:15:47 EST ;783904547 +Tue, 15 Nov 94 07:26:05 MST ;784909565 +Wed, 2 Nov 1994 00:00:55 -0600 (CST) ;783756055 +Sun, 6 Nov 1994 01:19:13 -0600 (CST) ;784106353 +Mon, 7 Nov 1994 23:16:57 -0600 (CST) ;784271817 +Tue, 08 Nov 1994 13:21:21 -0600 ;784322481 +Mon, 07 Nov 94 13:47:37 PST ;784244857 +Tue, 08 Nov 94 11:23:19 PST ;784322599 +Tue, 01 Nov 1994 11:28:25 -0800 ;783718105 +Tue, 15 Nov 1994 13:11:47 -0800 ;784933907 +Tue, 15 Nov 1994 13:18:38 -0800 ;784934318 +Tue, 15 Nov 1994 0:18:38 -0800 ;784887518 +Jul 13 1999 1:23P GMT ;931872180 +Jul 13 1999 1:23P.M GMT ;931872180 +Jul 13 1999 1:23P.M. GMT ;931872180 +Jul-13-1999 1:23P.M GMT ;931872180 +Jul/13/1999 1:23P.M. GMT ;931872180 +2001-02-26T13:44:12-0700 ;983220252 +2001-02-26T13:44-0700 ;983220240 +2001-02-26T13-0700 ;983217600 +2001-02-26T13-44-12-0700 ;983220252 +2001-02-26T13-44-0700 ;983220240 +2001-02-26T13-0700 ;983217600 +07/Nov/2000:16:45:56 +0100 ;973611956 +2002-11-07T23:31:49-05:00 ;1036729909 +2003-02-17T07:45:56Z ;1045467956 +2003-02-17T08:14:07.198189+0000 ;1045469647.198189 +20020722T100000Z ;1027332000 +Jul 22 10:00:00 UTC 2002 ;1027332000 +2002-07-22 10:00:00Z ;1027332000 +2002-07-22 10:00:00 Z ;1027332000 +2002-07-22 10:00 Z ;1027332000 +2002-07-22 10:00Z ;1027332000 +2002-07-22 10:00 +100 ;1027328400 +2002-07-22 10:00 +0100 ;1027328400 +!; + +require Time::Local; +my $offset = Time::Local::timegm(0,0,0,1,0,70); + +@data = split(/\n/, $data); + +print "1..", scalar(@data),"\n"; +$loop = 1; + +printf "# offset = %d\n", $offset; + +foreach (@data){ + my($str,$time_expect) = split ';', $_; + my $time = Date::Parse::str2time($str); + + if($loop < 6) { + + # The first five tests are parsed in the current time zone + # But the check number is in GMT + + my @lt = localtime($time_expect); + my @gt = gmtime($time_expect); + + $tzsec = ($gt[1] - $lt[1]) * 60 + ($gt[2] - $lt[2]) * 3600; + + my($lday,$gday) = ($lt[7],$gt[7]); + if($lt[5] > $gt[5]) { + $tzsec -= 24 * 3600; + } + elsif($gt[5] > $lt[5]) { + $tzsec += 24 * 3600; + } + else { + $tzsec += ($gt[7] - $lt[7]) * (24 * 3600); + } + $time -= $tzsec; + } + + $time_expect += $offset; + + if(defined($time) and $time==$time_expect) { + print "ok $loop\n"; + } + else { + require Date::Format; + print "-"x50,"\nFAIL $loop\n"; + printf "%s\nDiff: %d\n", $str, $time - $time_expect; + printf "Expect: %10f %s",$time_expect,Date::Format::ctime($time_expect); + printf "Got: %10f %s",$time, Date::Format::ctime($time); + } + $loop++; +} + diff --git a/t/lang.t b/t/lang.t new file mode 100644 index 0000000..02c96f4 --- /dev/null +++ b/t/lang.t @@ -0,0 +1,24 @@ +#!/usr/local/bin/perl -w + +use Date::Language; + + +my $time = time; +my $v; + +my @lang = qw(English German Italian); + +print "1..", scalar(@lang),"\n"; + +my $loop = 1; +my $lang; + +foreach $lang (@lang) +{ + my $l = Date::Language->new($lang); + $v = $l->str2time($l->ctime($time)); + + print $v == $time ? "ok $loop\n" : "FAIL $loop\n"; + $loop++; +} + |