diff options
author | Siep Kroonenberg <siepo@cybercomm.nl> | 2021-03-03 11:04:20 +0000 |
---|---|---|
committer | Siep Kroonenberg <siepo@cybercomm.nl> | 2021-03-03 11:04:20 +0000 |
commit | 13c3572d26e0868b9665513e4646ade860ae7810 (patch) | |
tree | 72f68d7c1270cc0a1d504f8eeb45d4de6b36f2d1 /Master/tlpkg/tlperl/site/lib/Date | |
parent | 87d16a01498a53c4bb455d78ae7131370e47591e (diff) |
Updated tlperl
git-svn-id: svn://tug.org/texlive/trunk@58075 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/tlperl/site/lib/Date')
37 files changed, 2650 insertions, 0 deletions
diff --git a/Master/tlpkg/tlperl/site/lib/Date/Format.pm b/Master/tlpkg/tlperl/site/lib/Date/Format.pm new file mode 100644 index 00000000000..3a1ea90ef1f --- /dev/null +++ b/Master/tlpkg/tlperl/site/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/Master/tlpkg/tlperl/site/lib/Date/Language.pm b/Master/tlpkg/tlperl/site/lib/Date/Language.pm new file mode 100644 index 00000000000..17568657e7e --- /dev/null +++ b/Master/tlpkg/tlperl/site/lib/Date/Language.pm @@ -0,0 +1,145 @@ + +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 Bulgarian + Occitan + +=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/Master/tlpkg/tlperl/site/lib/Date/Language/Afar.pm b/Master/tlpkg/tlperl/site/lib/Date/Language/Afar.pm new file mode 100644 index 00000000000..f67cf37685c --- /dev/null +++ b/Master/tlpkg/tlperl/site/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/Master/tlpkg/tlperl/site/lib/Date/Language/Amharic.pm b/Master/tlpkg/tlperl/site/lib/Date/Language/Amharic.pm new file mode 100644 index 00000000000..a79984ecffa --- /dev/null +++ b/Master/tlpkg/tlperl/site/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/Master/tlpkg/tlperl/site/lib/Date/Language/Austrian.pm b/Master/tlpkg/tlperl/site/lib/Date/Language/Austrian.pm new file mode 100644 index 00000000000..8ff398bd106 --- /dev/null +++ b/Master/tlpkg/tlperl/site/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/Master/tlpkg/tlperl/site/lib/Date/Language/Brazilian.pm b/Master/tlpkg/tlperl/site/lib/Date/Language/Brazilian.pm new file mode 100644 index 00000000000..fa4d15fff91 --- /dev/null +++ b/Master/tlpkg/tlperl/site/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/Master/tlpkg/tlperl/site/lib/Date/Language/Bulgarian.pm b/Master/tlpkg/tlperl/site/lib/Date/Language/Bulgarian.pm new file mode 100644 index 00000000000..cf3d127486e --- /dev/null +++ b/Master/tlpkg/tlperl/site/lib/Date/Language/Bulgarian.pm @@ -0,0 +1,92 @@ +## +## Bulgarian tables contributed by Krasimir Berov +## + +package Date::Language::Bulgarian; +use strict; +use warnings; +use utf8; +use base qw(Date::Language); +our (@DoW, @DoWs, @MoY, @MoYs, @AMPM, @Dsuf, %MoY, %DoW, $VERSION); +$VERSION = "1.01"; + +@DoW = qw(неделя понеделник вторник сряда четвъртък петък събота); +@MoY = qw(януари февруари март април май юни + юли август септември октомври ноември декември); +@DoWs = qw(нд пн вт ср чт пт сб); +@MoYs = map { substr($_,0,3) } @MoY; +@AMPM = qw(AM PM); + +@Dsuf = (qw(ти ви ри ти ти ти ти ми ми ти)) x 3; +@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 { ($_[0]->[3]<10?' ':'').$_[0]->[3].$Dsuf[$_[0]->[3]] } + +1; + +__END__ + +=encoding utf8 + +=head1 NAME + +Date::Language::Bulgarian - localization for Date::Format + +=head1 DESCRIPTION + +This is Bulgarian localization for Date::Format. +It is important to note that this module source code is in utf8. +All strings which it outputs are in utf8, so it is safe to use it +currently only with English. You are left alone to try and convert +the output when using different Date::Language::* in the same application. +This should be addresed in the future. + +=head1 SYNOPSIS + + use strict; + use warnings; + use Date::Language; + local $\=$/; + my $template ='%a %b %e %T %Y (%Y-%m-%d %H:%M:%S)'; + my $time=1290883821; #or just use time(); + my @lt = localtime($time); + my %languages = qw(English GMT German EEST Bulgarian EET); + binmode(select,':utf8'); + + foreach my $l(keys %languages){ + my $lang = Date::Language->new($l); + my $zone = $languages{$l}; + print $/. "$l $zone"; + print $lang->time2str($template, $time); + print $lang->time2str($template, $time, $zone); + + print $lang->strftime($template, \@lt); + } + +=head1 AUTHOR + +Krasimir Berov (berov@cpan.org) + +=head1 COPYRIGHT + +Copyright (c) 2010 Krasimir Berov. This program is free +software; you can redistribute it and/or modify it under the same terms +as Perl itself. + +=cut + + diff --git a/Master/tlpkg/tlperl/site/lib/Date/Language/Chinese.pm b/Master/tlpkg/tlperl/site/lib/Date/Language/Chinese.pm new file mode 100644 index 00000000000..abfb3c05728 --- /dev/null +++ b/Master/tlpkg/tlperl/site/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/Master/tlpkg/tlperl/site/lib/Date/Language/Chinese_GB.pm b/Master/tlpkg/tlperl/site/lib/Date/Language/Chinese_GB.pm new file mode 100644 index 00000000000..7be05552266 --- /dev/null +++ b/Master/tlpkg/tlperl/site/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/Master/tlpkg/tlperl/site/lib/Date/Language/Czech.pm b/Master/tlpkg/tlperl/site/lib/Date/Language/Czech.pm new file mode 100644 index 00000000000..756f5c552fc --- /dev/null +++ b/Master/tlpkg/tlperl/site/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/Master/tlpkg/tlperl/site/lib/Date/Language/Danish.pm b/Master/tlpkg/tlperl/site/lib/Date/Language/Danish.pm new file mode 100644 index 00000000000..e143c545132 --- /dev/null +++ b/Master/tlpkg/tlperl/site/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/Master/tlpkg/tlperl/site/lib/Date/Language/Dutch.pm b/Master/tlpkg/tlperl/site/lib/Date/Language/Dutch.pm new file mode 100644 index 00000000000..219758b4b29 --- /dev/null +++ b/Master/tlpkg/tlperl/site/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/Master/tlpkg/tlperl/site/lib/Date/Language/English.pm b/Master/tlpkg/tlperl/site/lib/Date/Language/English.pm new file mode 100644 index 00000000000..638cb3c2a21 --- /dev/null +++ b/Master/tlpkg/tlperl/site/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/Master/tlpkg/tlperl/site/lib/Date/Language/Finnish.pm b/Master/tlpkg/tlperl/site/lib/Date/Language/Finnish.pm new file mode 100644 index 00000000000..415b50c73df --- /dev/null +++ b/Master/tlpkg/tlperl/site/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/Master/tlpkg/tlperl/site/lib/Date/Language/French.pm b/Master/tlpkg/tlperl/site/lib/Date/Language/French.pm new file mode 100644 index 00000000000..f9aa95d0779 --- /dev/null +++ b/Master/tlpkg/tlperl/site/lib/Date/Language/French.pm @@ -0,0 +1,37 @@ +## +## 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] } +sub format_o { $_[0]->[3] } + +1; diff --git a/Master/tlpkg/tlperl/site/lib/Date/Language/Gedeo.pm b/Master/tlpkg/tlperl/site/lib/Date/Language/Gedeo.pm new file mode 100644 index 00000000000..c18ad8cadda --- /dev/null +++ b/Master/tlpkg/tlperl/site/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/Master/tlpkg/tlperl/site/lib/Date/Language/German.pm b/Master/tlpkg/tlperl/site/lib/Date/Language/German.pm new file mode 100644 index 00000000000..11242c4c46a --- /dev/null +++ b/Master/tlpkg/tlperl/site/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/Master/tlpkg/tlperl/site/lib/Date/Language/Greek.pm b/Master/tlpkg/tlperl/site/lib/Date/Language/Greek.pm new file mode 100644 index 00000000000..00f917ce474 --- /dev/null +++ b/Master/tlpkg/tlperl/site/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/Master/tlpkg/tlperl/site/lib/Date/Language/Hungarian.pm b/Master/tlpkg/tlperl/site/lib/Date/Language/Hungarian.pm new file mode 100644 index 00000000000..d9c838d15b9 --- /dev/null +++ b/Master/tlpkg/tlperl/site/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/Master/tlpkg/tlperl/site/lib/Date/Language/Icelandic.pm b/Master/tlpkg/tlperl/site/lib/Date/Language/Icelandic.pm new file mode 100644 index 00000000000..5ca3ee32099 --- /dev/null +++ b/Master/tlpkg/tlperl/site/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/Master/tlpkg/tlperl/site/lib/Date/Language/Italian.pm b/Master/tlpkg/tlperl/site/lib/Date/Language/Italian.pm new file mode 100644 index 00000000000..6db0a8e67c9 --- /dev/null +++ b/Master/tlpkg/tlperl/site/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/Master/tlpkg/tlperl/site/lib/Date/Language/Norwegian.pm b/Master/tlpkg/tlperl/site/lib/Date/Language/Norwegian.pm new file mode 100644 index 00000000000..bbd997f0b4d --- /dev/null +++ b/Master/tlpkg/tlperl/site/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/Master/tlpkg/tlperl/site/lib/Date/Language/Occitan.pm b/Master/tlpkg/tlperl/site/lib/Date/Language/Occitan.pm new file mode 100644 index 00000000000..cf58abdfba3 --- /dev/null +++ b/Master/tlpkg/tlperl/site/lib/Date/Language/Occitan.pm @@ -0,0 +1,36 @@ +## +## Occitan tables, contributed by Quentn PAGÈS +## + +package Date::Language::Occitan; + +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(dimenge diluns dimars dimècres dijòus divendres dissabte); +@MoY = qw(genièr febrièr mars abrial mai junh + julhet agost octòbre novembre decembre); +@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/Master/tlpkg/tlperl/site/lib/Date/Language/Oromo.pm b/Master/tlpkg/tlperl/site/lib/Date/Language/Oromo.pm new file mode 100644 index 00000000000..b6a6230c87d --- /dev/null +++ b/Master/tlpkg/tlperl/site/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/Master/tlpkg/tlperl/site/lib/Date/Language/Romanian.pm b/Master/tlpkg/tlperl/site/lib/Date/Language/Romanian.pm new file mode 100644 index 00000000000..cbd2c8cbc4d --- /dev/null +++ b/Master/tlpkg/tlperl/site/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/Master/tlpkg/tlperl/site/lib/Date/Language/Russian.pm b/Master/tlpkg/tlperl/site/lib/Date/Language/Russian.pm new file mode 100644 index 00000000000..ca9f4142327 --- /dev/null +++ b/Master/tlpkg/tlperl/site/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/Master/tlpkg/tlperl/site/lib/Date/Language/Russian_cp1251.pm b/Master/tlpkg/tlperl/site/lib/Date/Language/Russian_cp1251.pm new file mode 100644 index 00000000000..cc28e6ed43a --- /dev/null +++ b/Master/tlpkg/tlperl/site/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/Master/tlpkg/tlperl/site/lib/Date/Language/Russian_koi8r.pm b/Master/tlpkg/tlperl/site/lib/Date/Language/Russian_koi8r.pm new file mode 100644 index 00000000000..53de8d0567b --- /dev/null +++ b/Master/tlpkg/tlperl/site/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/Master/tlpkg/tlperl/site/lib/Date/Language/Sidama.pm b/Master/tlpkg/tlperl/site/lib/Date/Language/Sidama.pm new file mode 100644 index 00000000000..bc26d7c3f09 --- /dev/null +++ b/Master/tlpkg/tlperl/site/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/Master/tlpkg/tlperl/site/lib/Date/Language/Somali.pm b/Master/tlpkg/tlperl/site/lib/Date/Language/Somali.pm new file mode 100644 index 00000000000..5b2496170e9 --- /dev/null +++ b/Master/tlpkg/tlperl/site/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/Master/tlpkg/tlperl/site/lib/Date/Language/Spanish.pm b/Master/tlpkg/tlperl/site/lib/Date/Language/Spanish.pm new file mode 100644 index 00000000000..d464ae78ad1 --- /dev/null +++ b/Master/tlpkg/tlperl/site/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/Master/tlpkg/tlperl/site/lib/Date/Language/Swedish.pm b/Master/tlpkg/tlperl/site/lib/Date/Language/Swedish.pm new file mode 100644 index 00000000000..8f16594ba73 --- /dev/null +++ b/Master/tlpkg/tlperl/site/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/Master/tlpkg/tlperl/site/lib/Date/Language/Tigrinya.pm b/Master/tlpkg/tlperl/site/lib/Date/Language/Tigrinya.pm new file mode 100644 index 00000000000..ce4fcb3a1cb --- /dev/null +++ b/Master/tlpkg/tlperl/site/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/Master/tlpkg/tlperl/site/lib/Date/Language/TigrinyaEritrean.pm b/Master/tlpkg/tlperl/site/lib/Date/Language/TigrinyaEritrean.pm new file mode 100644 index 00000000000..7ab8d0fdd1e --- /dev/null +++ b/Master/tlpkg/tlperl/site/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/Master/tlpkg/tlperl/site/lib/Date/Language/TigrinyaEthiopian.pm b/Master/tlpkg/tlperl/site/lib/Date/Language/TigrinyaEthiopian.pm new file mode 100644 index 00000000000..84fb7237c31 --- /dev/null +++ b/Master/tlpkg/tlperl/site/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/Master/tlpkg/tlperl/site/lib/Date/Language/Turkish.pm b/Master/tlpkg/tlperl/site/lib/Date/Language/Turkish.pm new file mode 100644 index 00000000000..593e20925cf --- /dev/null +++ b/Master/tlpkg/tlperl/site/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/Master/tlpkg/tlperl/site/lib/Date/Parse.pm b/Master/tlpkg/tlperl/site/lib/Date/Parse.pm new file mode 100644 index 00000000000..afdcc1c1fff --- /dev/null +++ b/Master/tlpkg/tlperl/site/lib/Date/Parse.pm @@ -0,0 +1,388 @@ +# 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.33"; + +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($century,$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; + } + } + + if (defined $year && $year > 1900) { + $century = int($year / 100); + $year -= 1900; + } + + $zone += 3600 if defined $zone && $dst; + $ss += "0.$frac" if $frac; + + return ($ss,$mm,$hh,$day,$month,$year,$zone,$century); +} +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, $century) = @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); + + # we were given a 4 digit year, so let's keep using those + $year += 1900 if defined $century; + + 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,$century)>. 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. + +=back + +=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 + |