summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfukachan <fukachan>2012-02-18 10:01:34 +0000
committerfukachan <fukachan>2012-02-18 10:01:34 +0000
commit44e690055046752aeb39f753ba51c9f024d5e0d6 (patch)
treec66080590e96053c9f4e0aa3704745fb5cee0a69
parentb653588fd14399a3acd1aca1f77e0bced91f804d (diff)
downloadfml8-44e690055046752aeb39f753ba51c9f024d5e0d6.tar.gz
fml8-44e690055046752aeb39f753ba51c9f024d5e0d6.tar.bz2
fml8-44e690055046752aeb39f753ba51c9f024d5e0d6.zip
update Time-modules to 2011.0517 (sync w/ pkgsrc/time/p5-Time-modules).
bump up the FML_CURRENT_VERSION to 7.98.17 to clarify the dependence among the version and modules.
-rw-r--r--CHANGES.txt25
-rw-r--r--cpan/MANIFEST4
-rw-r--r--cpan/dist/Time-modules/CHANGELOG91
-rw-r--r--cpan/dist/Time-modules/MANIFEST4
-rw-r--r--cpan/dist/Time-modules/META.yml23
-rw-r--r--cpan/dist/Time-modules/Makefile.PL24
-rw-r--r--cpan/dist/Time-modules/lib/Time/CTime.pm22
-rw-r--r--cpan/dist/Time-modules/lib/Time/DaysInMonth.pm18
-rw-r--r--cpan/dist/Time-modules/lib/Time/JulianDay.pm32
-rw-r--r--cpan/dist/Time-modules/lib/Time/ParseDate.pm246
-rw-r--r--cpan/dist/Time-modules/lib/Time/Timezone.pm180
-rwxr-xr-xcpan/dist/Time-modules/t/datetime.t126
-rw-r--r--cpan/dist/Time-modules/t/metdate.t72
-rw-r--r--cpan/dist/Time-modules/t/order1.t33
-rw-r--r--cpan/dist/Time-modules/t/order2.t33
-rw-r--r--cpan/lib/Time/CTime.pm22
-rw-r--r--cpan/lib/Time/DaysInMonth.pm18
-rw-r--r--cpan/lib/Time/JulianDay.pm32
-rw-r--r--cpan/lib/Time/ParseDate.pm246
-rw-r--r--cpan/lib/Time/Timezone.pm180
20 files changed, 1105 insertions, 326 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 91fc5c76..a764baf6 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -3,9 +3,10 @@
[最近のまとめ]
- FML_CURRENT_VERSION=7.98.16
+ FML_CURRENT_VERSION=7.98.17
8.0 PRE_ALPHA
+ 7.98.17 update modules: cpan modules, IM et.al (to be planned).
7.98.16 FML::Install is enhanced.
7.98.15 IM updated to IM-150.
fix wrong ID incrementation in article to html conversion.
@@ -47,6 +48,26 @@
2004/09 以降の fml8 は疑似 MTA 的な動作をしていて、自分のメー
ルキューイングシステムを使ってエラー処理や再送処理を行ないます。
+2012/02/18
+
+ update Time-modules to 2011.0517 (sync w/ pkgsrc/time/p5-Time-modules).
+
+ bump up the FML_CURRENT_VERSION to 7.98.17
+ to clarify the dependence among the version and modules.
+
+2011/09/26
+
+ FML::Config
+ include ErrorStatus module within it.
+ remove "use ErrorStatus".
+
+ FML::Credential
+ include ErrorStatus module within it.
+ remove "use ErrorStatus".
+
+ ErrorStatus
+ modified to not use this top level package. remove this.
+
2011/08/25
Mail::Message::Encode
@@ -10571,4 +10592,4 @@
このファイルを創設する:)
-$FML: CHANGES.txt,v 1.325 2011/08/23 15:11:37 fukachan Exp $
+$FML: CHANGES.txt,v 1.326 2011/08/31 03:17:16 fukachan Exp $
diff --git a/cpan/MANIFEST b/cpan/MANIFEST
index 88210cb8..96362f6a 100644
--- a/cpan/MANIFEST
+++ b/cpan/MANIFEST
@@ -28,7 +28,7 @@ Rcs 0.09 perl itself
Socket6 0.07 WIDE (BSD flabour)
-Time-modules 100.010301 unknown (your own risk)
+Time-modules 2011.0517 unknown (your own risk)
VCS-CVS 2.00 perl itself
@@ -36,4 +36,4 @@ Text-CSV 0.01 perl itself
Unicode-Japanese 0.09 perl itself
-$FML: MANIFEST,v 1.15 2008/05/11 13:11:06 fukachan Exp $
+$FML: MANIFEST,v 1.16 2008/08/20 21:14:33 fukachan Exp $
diff --git a/cpan/dist/Time-modules/CHANGELOG b/cpan/dist/Time-modules/CHANGELOG
index 3a2a69d9..c0847f25 100644
--- a/cpan/dist/Time-modules/CHANGELOG
+++ b/cpan/dist/Time-modules/CHANGELOG
@@ -1,3 +1,94 @@
+2011.0517:
+ Bugfix from Sophie Hamilton: call tzset() when changing timezones.
+
+ Bugfix: bail out of tests cleanly when tzset doesn't work.
+2011.0505:
+ Bugfix: make sure $ampm is defined so no undefined string warnings
+ are issued.
+
+ Honor the GMT flag when parsing time specs. Patch from
+ kris at shannon.id.au.
+
+ Bugfix: RT#31477 noon & midnight would match in the middle of strings.
+
+ Added %v conversion for Time::CTime
+
+ Added tests to disprove invalid bug reports.
+2006.0814:
+ A bugfix for negative offsets that overflowed (from Vernon Lyon
+ <vlyon at uk.yahoo-inc.com>)
+
+ Add a few more timezones (from Peter Ludemann <ludemann at yahoo-inc.com>
+ and Alex Bowley <kilinrax at cpan.org>)
+
+ Recognize fractional times counts like "1.5 minutes ago"
+ (from Simon Wistow <simon@thegestalt.org>)
+
+ Recognize Dow "before last" (from Ole Craig <ocraig at stillsecure.com>)
+
+ Change various __DATA__ to __END__ (from Nick Ing-Simmons
+ <nick at ing-simmons.net>)
+2003.1125:
+ Various folks have complained that JulianDay isn't correct. An
+ errata section has been added to the documentation.
+
+ Mark Ivey <mivey@r2tech.com> add '@' as a synonym for 'at'.
+ Fixed typos.
+
+ Bryan Henderson <bryanh@giraffe-data.com> sent in a patch to
+ allow NOW => 0 so that ParseDate can be used to parse relative
+ times.
+
+ ewan@baremetal.com sent in a patch adding a bit of ISO 8601
+ support.
+
+ David Alban <david@responsible.com> doesn't like allowing the
+ hour 24:00. I agree. Gone if you have VALIDATE=>1.
+
+ Still to be done: the support the large number of ISO 8601
+ date formats: http://hydracen.com/dx/iso8601.htm
+2003.0211:
+ Mike Cramer <cramer@webkist.com> sent a patch to Timezone to
+ handle changes in $ENV{TZ}.
+
+ Rani Pinchuk <rani@cpan.org> sent in a definition for the
+ CEST timezone.
+
+ On Phil.Moore@msdw.com's behalf the timezone 'MET DST' is now
+ supported.
+
+2002.1001:
+ No real changes, just added a license.
+
+101.062001:
+ Paul Zimmer <pzimmer@bepress.com> found that '7/17/01' with
+ PREFER_FUTURE failed badly. Fixed. This was also submitted
+ by Dana Burd <DBurd@cpr.org>.
+
+ Ben Daglish <bdaglish@yahoo.com> noted that array context
+ was implying WHOLE and DATE_REQUIRED. Fixed.
+
+ Streppone Cosimo <cstrep@idgroup.it> requested support for
+ postgresql's date format ("dd/mm/yyyy hh:mn:ss +tzo")
+
+ Ameeth Linus Daniel <linus@teil.soft.net> found that IST wasn't
+ a defined timezone. I've defined it as +0530, but I'm not
+ positive that's correct.
+
+ Gautam Tripathi <dayalpura@hotmail.com> sent in a fix for
+ timezone offset calculations making them consistent across
+ all systems (no more problems with differing interpretations
+ of negative modulus operations).
+
+ Mike Nerone <mnerone@idworld.net> requested the syntax
+ "4 days ago". He says that that syntax is suppored by
+ GNU date. This was also requested by Townsend, John E.
+ <John.Townsend@lexis-nexis.com>.
+
+ Anton Berezin <tobez@heechee.tobez.org> notice that ParseDate
+ couldn't handle "Sunday, 06-Nov-94 08:49:37 GMT" and sent
+ in a patch.
+
100.010301:
W. Phillip Moore <Phil.Moore@msdw.com> reproted a Y2K bug: it could
not parse 'Jan 1 2000 10:30:30AM'. Fixed. This is embarassing
diff --git a/cpan/dist/Time-modules/MANIFEST b/cpan/dist/Time-modules/MANIFEST
index 75076d8a..040e4a44 100644
--- a/cpan/dist/Time-modules/MANIFEST
+++ b/cpan/dist/Time-modules/MANIFEST
@@ -8,3 +8,7 @@ lib/Time/JulianDay.pm
lib/Time/ParseDate.pm
lib/Time/Timezone.pm
t/datetime.t
+t/metdate.t
+t/order1.t
+t/order2.t
+META.yml Module meta-data (added by MakeMaker)
diff --git a/cpan/dist/Time-modules/META.yml b/cpan/dist/Time-modules/META.yml
new file mode 100644
index 00000000..5ed556ca
--- /dev/null
+++ b/cpan/dist/Time-modules/META.yml
@@ -0,0 +1,23 @@
+--- #YAML:1.0
+name: Time-modules
+version: 2011.0517
+abstract: Parse and format time values
+author:
+ - David Muir Sharnoff <cpan@dave.sharnoff.org>
+license: unknown
+distribution_type: module
+configure_requires:
+ ExtUtils::MakeMaker: 0
+build_requires:
+ ExtUtils::MakeMaker: 0
+requires: {}
+resources:
+ repository: http://github.com/muir/Time-modules
+no_index:
+ directory:
+ - t
+ - inc
+generated_by: ExtUtils::MakeMaker version 6.56
+meta-spec:
+ url: http://module-build.sourceforge.net/META-spec-v1.4.html
+ version: 1.4
diff --git a/cpan/dist/Time-modules/Makefile.PL b/cpan/dist/Time-modules/Makefile.PL
index 0340d250..d4537f2e 100644
--- a/cpan/dist/Time-modules/Makefile.PL
+++ b/cpan/dist/Time-modules/Makefile.PL
@@ -2,10 +2,20 @@
use ExtUtils::MakeMaker;
WriteMakefile(
- 'VERSION' => 100.010301,
- 'NAME' => 'Time-modules',
- ($] >= 5.005 ?
- ('ABSTRACT' => 'Parse and format time values',
- 'AUTHOR' => 'David Muir Sharnoff <muir@idiom.com>') : ()),
- 'dist' => { COMPRESS=>"gzip", SUFFIX=>"gz" },
- );
+ VERSION_FROM => 'lib/Time/ParseDate.pm',
+ NAME => 'Time-modules',
+ ($] >= 5.005
+ ?
+ (
+ ABSTRACT => 'Parse and format time values',
+ AUTHOR => 'David Muir Sharnoff <cpan@dave.sharnoff.org>',
+ META_MERGE => {
+ resources => {
+ repository => 'http://github.com/muir/Time-modules',
+ },
+ },
+ )
+ : ()
+ ),
+ dist => { COMPRESS=>"gzip", SUFFIX=>"gz" },
+);
diff --git a/cpan/dist/Time-modules/lib/Time/CTime.pm b/cpan/dist/Time-modules/lib/Time/CTime.pm
index 530a6094..29b259d1 100644
--- a/cpan/dist/Time-modules/lib/Time/CTime.pm
+++ b/cpan/dist/Time-modules/lib/Time/CTime.pm
@@ -16,7 +16,7 @@ use strict;
use vars qw(@DoW @DayOfWeek @MoY @MonthOfYear %strftime_conversion $VERSION);
use vars qw($template $sec $min $hour $mday $mon $year $wday $yday $isdst);
-$VERSION = 99.06_22_01;
+$VERSION = 2011.0505;
CONFIG: {
@DoW = qw(Sun Mon Tue Wed Thu Fri Sat);
@@ -54,6 +54,7 @@ CONFIG: {
't', sub { "\t" },
'T', sub { sprintf("%02d:%02d:%02d", $hour, $min, $sec) },
'U', sub { wkyr(0, $wday, $yday) },
+ 'v', sub { sprintf("%2d-%s-%4d", $mday, $MoY[$mon], $year+1900) },
'w', sub { $wday },
'W', sub { wkyr(1, $wday, $yday) },
'y', sub { sprintf("%02d",$year%100) },
@@ -61,6 +62,7 @@ CONFIG: {
'x', sub { sprintf("%02d/%02d/%02d", $mon + 1, $mday, $year%100) },
'X', sub { sprintf("%02d:%02d:%02d", $hour, $min, $sec) },
'Z', sub { &tz2zone(undef,undef,$isdst) }
+ # z sprintf("%+03d%02d", $offset / 3600, ($offset % 3600)/60);
);
@@ -115,14 +117,14 @@ sub strftime {
local ($template, $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = @_;
undef $@;
- $template =~ s/%([%aAbBcdDefFhHIjklmMnopQrRStTUwWxXyYZ])/&{$Time::CTime::strftime_conversion{$1}}()/egs;
+ $template =~ s/%([%aAbBcdDefFhHIjklmMnopQrRStTUvwWxXyYZ])/&{$Time::CTime::strftime_conversion{$1}}()/egs;
die $@ if $@;
return $template;
}
1;
-__DATA__
+__END__
=head1 NAME
@@ -154,7 +156,7 @@ Time::CTime -- format times ala POSIX asctime
%j day of the year
%k hour
%l hour, 12 hour clock
- %m month number, starting with 1
+ %m month number, starting with 1, leading 0's
%M minute, leading 0's
%n NEWLINE
%o ornate day of month -- "1st", "2nd", "25th", etc.
@@ -165,6 +167,7 @@ Time::CTime -- format times ala POSIX asctime
%t TAB
%T time format: 21:05:57
%U week number, Sunday as first day of week
+ %v DD-Mon-Year
%w day of the week, numerically, Sunday == 0
%W week number, Monday as first day of week
%x date format: 11/19/94
@@ -187,11 +190,16 @@ libraries.
=head1 GENESIS
-Written by David Muir Sharnoff <muir@idiom.com>.
+Written by David Muir Sharnoff <muir@idiom.org>.
The starting point for this package was a posting by
Paul Foley <paul@ascent.com>
-Copyright (C) 1996-1999 David Muir Sharnoff. All Rights Reserved.
-Use and redistribution allowed at user's own risk.
+=head1 LICENSE
+
+Copyright (C) 1996-2010 David Muir Sharnoff.
+Copyright (C) 2011 Google, Inc.
+License hereby
+granted for anyone to use, modify or redistribute this module at
+their own risk. Please feed useful changes back to cpan@dave.sharnoff.org.
diff --git a/cpan/dist/Time-modules/lib/Time/DaysInMonth.pm b/cpan/dist/Time-modules/lib/Time/DaysInMonth.pm
index 2139f2f8..60a75086 100644
--- a/cpan/dist/Time-modules/lib/Time/DaysInMonth.pm
+++ b/cpan/dist/Time-modules/lib/Time/DaysInMonth.pm
@@ -12,7 +12,7 @@ use strict;
use vars qw($VERSION %mltable);
-$VERSION = 96.032702;
+$VERSION = 99.1117;
CONFIG: {
%mltable = qw(
@@ -49,7 +49,7 @@ sub is_leap
1;
-__DATA__
+__END__
=head1 NAME
@@ -68,8 +68,16 @@ a month. That's all it does. Really!
=head1 AUTHOR
-David Muir Sharnoff <muir@idiom.com>
+David Muir Sharnoff <muir@idiom.org>
-Copyright (C) 1996-1999 David Muir Sharnoff. All Rights Reserved.
-Use and redistribution allowed at user's own risk.
+=head1 BUGS
+
+This only deals with the "modern" calendar. Look elsewhere for
+historical time and date support.
+
+=head1 LICENSE
+
+Copyright (C) 1996-1999 David Muir Sharnoff. License hereby
+granted for anyone to use, modify or redistribute this module at
+their own risk. Please feed useful changes back to muir@idiom.org.
diff --git a/cpan/dist/Time-modules/lib/Time/JulianDay.pm b/cpan/dist/Time-modules/lib/Time/JulianDay.pm
index 1b011da1..a749c798 100644
--- a/cpan/dist/Time-modules/lib/Time/JulianDay.pm
+++ b/cpan/dist/Time-modules/lib/Time/JulianDay.pm
@@ -19,14 +19,13 @@ use integer;
# constants
use vars qw($brit_jd $jd_epoch $jd_epoch_remainder $VERSION);
-$VERSION = 99.061501;
+$VERSION = 2011.0505;
# calculate the julian day, given $year, $month and $day
sub julian_day
{
my($year, $month, $day) = @_;
my($tmp);
- my($secs);
use Carp;
# confess() unless defined $day;
@@ -157,7 +156,7 @@ sub jd_timegm
1;
-__DATA__
+__END__
=head1 NAME
@@ -189,12 +188,37 @@ using julian days...
The day_of_week returned by day_of_week() is 0 for Sunday, and 6 for
Saturday and everything else is in between.
+=head1 ERRATA
+
+Time::JulianDay is not a correct implementation. There are two
+problems. The first problem is that Time::JulianDay only works
+with integers. Julian Day can be fractional to represent time
+within a day. If you call inverse_julian_day() with a non-integer
+time, it will often give you an incorrect result.
+
+The second problem is that Julian Days start at noon rather than
+midnight. The julian_day() function returns results that are too
+large by 0.5.
+
+What to do about these problems is currently open for debate. I'm
+tempted to leave the current functions alone and add a second set
+with more accurate behavior.
+
+There is another implementation in Astro::Time that may be more accurate.
+
=head1 GENESIS
-Written by David Muir Sharnoff <muir@idiom.com> with help from
+Written by David Muir Sharnoff <cpan@dave.sharnoff.org> with help from
previous work by
Kurt Jaeger aka PI <zrzr0111@helpdesk.rus.uni-stuttgart.de>
based on postings from: Ian Miller <ian_m@cix.compulink.co.uk>;
Gary Puckering <garyp%cognos.uucp@uunet.uu.net>
based on Collected Algorithms of the ACM ?;
and the unknown-to-me author of Time::Local.
+
+=head1 LICENSE
+
+Copyright (C) 1996-1999 David Muir Sharnoff. License hereby
+granted for anyone to use, modify or redistribute this module at
+their own risk. Please feed useful changes back to cpan@dave.sharnoff.org.
+
diff --git a/cpan/dist/Time-modules/lib/Time/ParseDate.pm b/cpan/dist/Time-modules/lib/Time/ParseDate.pm
index 8f1c18fb..c46b7323 100644
--- a/cpan/dist/Time-modules/lib/Time/ParseDate.pm
+++ b/cpan/dist/Time-modules/lib/Time/ParseDate.pm
@@ -12,11 +12,12 @@ require Exporter;
@EXPORT_OK = qw(pd_raw %mtable %umult %wdays);
use strict;
+#use diagnostics;
# constants
use vars qw(%mtable %umult %wdays $VERSION);
-$VERSION = 100.01_03_01;
+$VERSION = 2011.0517;
# globals
use vars qw($debug);
@@ -49,7 +50,8 @@ CONFIG: {
min 60 minute 60
hour 3600
day 86400
- week 604800 );
+ week 604800
+ fortnight 1209600);
%wdays = qw(
sun 0 sunday 0
mon 1 monday 1
@@ -76,7 +78,7 @@ sub parsedate
my $rel; # time&|date is relative
my $isspec;
- my $now = $options{NOW} || time;
+ my $now = defined($options{NOW}) ? $options{NOW} : time;
my $passes = 0;
my $uk = defined($options{UK}) ? $options{UK} : 0;
@@ -157,7 +159,7 @@ sub parsedate
}
}
if (defined $M or defined $rd) {
- if ($t =~ s/^\s*(?:at|\+)\s*(\s+|$)//x) {
+ if ($t =~ s/^\s*(?:at|\@|\+)\s*(\s+|$)//x) {
$rel = 1;
$parse .= " ".__LINE__ if $debug;
next;
@@ -165,8 +167,9 @@ sub parsedate
}
last;
} continue {
- print "context$parse remaider = $t.\n" if $debug;
$passes++;
+ &debug_display($tz, $tzo, $H, $M, $S, $m, $d, $y, $rs, $rd, $rel, $passes, $parse, $t) if $debug;
+
}
if ($passes == 0) {
@@ -177,32 +180,18 @@ sub parsedate
}
}
- if ($debug) {
- print "t: $t.\n";
- print defined($tz) ? "tz: $tz.\n" : "no tz\n";
- print defined($tzo) ? "tzo: $tzo.\n" : "no tzo\n";
- print "HMS: ";
- print defined($H) ? "$H, " : "no H, ";
- print defined($M) ? "$M, " : "no M, ";
- print defined($S) ? "$S\n" : "no S.\n";
- print "mdy: ";
- print defined($m) ? "$m, " : "no m, ";
- print defined($d) ? "$d, " : "no d, ";
- print defined($y) ? "$y\n" : "no y.\n";
- print defined($rs) ? "rs: $rs.\n" : "no rs\n";
- print defined($rd) ? "rd: $rd.\n" : "no rd\n";
- print "parse:$parse\n";
- print "passes: $passes\n";
- }
+ &debug_display($tz, $tzo, $H, $M, $S, $m, $d, $y, $rs, $rd, $rel, $passes, $parse, $t) if $debug;
$t =~ s/^\s+//;
if ($t ne '') {
# we didn't manage to eat the string
print "NOT WHOLE\n" if $debug;
- return undef if $options{WHOLE};
- return (undef, "characters left over after parse")
- if wantarray();
+ if ($options{WHOLE}) {
+ return (undef, "characters left over after parse")
+ if wantarray();
+ return undef
+ }
}
# define a date if there isn't one already
@@ -211,9 +200,11 @@ sub parsedate
print "no date defined, trying to find one." if $debug;
if (defined $rs or defined $H) {
# we do have a time.
- return (undef, "no date specified")
- if wantarray();
- return undef if $options{DATE_REQUIRED};
+ if ($options{DATE_REQUIRED}) {
+ return (undef, "no date specified")
+ if wantarray();
+ return undef;
+ }
if (defined $rs) {
print "simple offset: $rs\n" if $debug;
my $rv = $now + $rs;
@@ -264,7 +255,9 @@ sub parsedate
}
print "relative date\n" if $debug;
- $jd = local_julian_day($now);
+ $jd = $options{GMT}
+ ? gm_julian_day($now)
+ : local_julian_day($now);
print "jd($now) = $jd\n" if $debug;
$jd += $rd;
} else {
@@ -338,16 +331,13 @@ sub parsedate
}
$S += $rs if defined $rs;
- $carry = int($S / 60);
- my($frac) = $S - int($S);
- $S = int($S);
- $S %= 60;
- $S += $frac;
+ $carry = int($S / 60) - ($S < 0 && $S % 60 && 1);
+ $S -= $carry * 60;
$M += $carry;
- $carry = int($M / 60);
+ $carry = int($M / 60) - ($M < 0 && $M % 60 && 1);
$M %= 60;
$H += $carry;
- $carry = int($H / 24);
+ $carry = int($H / 24) - ($H < 0 && $H % 24 && 1);
$H %= 24;
$jd += $carry;
@@ -365,17 +355,28 @@ sub parsedate
my $tzadj;
if ($tz) {
$tzadj = tz_offset($tz, $secs);
- print "adjusting secs for $tz: $tzadj\n" if $debug;
- $tzadj = tz_offset($tz, $secs-$tzadj);
- $secs -= $tzadj;
+ if (defined $tzadj) {
+ print "adjusting secs for $tz: $tzadj\n" if $debug;
+ $tzadj = tz_offset($tz, $secs-$tzadj);
+ $secs -= $tzadj;
+ } else {
+ print "unknown timezone: $tz\n" if $debug;
+ undef $secs;
+ undef $t;
+ }
} elsif (defined $tzo) {
print "adjusting time for offset: $tzo\n" if $debug;
$secs -= $tzo;
} else {
unless ($options{GMT}) {
if ($options{ZONE}) {
- $tzadj = tz_offset($options{ZONE}, $secs);
+ $tzadj = tz_offset($options{ZONE}, $secs) || 0;
$tzadj = tz_offset($options{ZONE}, $secs-$tzadj);
+ unless (defined($tzadj)) {
+ return (undef, "could not convert '$options{ZONE}' to time offset")
+ if wantarray();
+ return undef;
+ }
print "adjusting secs for $options{ZONE}: $tzadj\n" if $debug;
$secs -= $tzadj;
} else {
@@ -402,7 +403,7 @@ sub mkoff
{
my($offset) = @_;
- if (defined $offset and $offset =~ s#^([-+])(\d\d)(\d\d)$##) {
+ if (defined $offset and $offset =~ s#^([-+])(\d\d):?(\d\d)$##) {
return ($1 eq '+' ?
3600 * $2 + 60 * $3
: -3600 * $2 + -60 * $3 );
@@ -418,7 +419,7 @@ sub parse_tz_only
my $o;
if ($$tr =~ s#^
- ([-+]\d\d\d\d)
+ ([-+]\d\d:?\d\d)
\s+
\(
"?
@@ -441,7 +442,7 @@ sub parse_tz_only
return 1;
} elsif ($$tr =~ s#^GMT\s*([-+]\d{1,2})(\s+|$)##x) {
$o = $1;
- if ($o <= 24 and $o !~ /^0/) {
+ if ($o < 24 and $o !~ /^0/) {
# probably hours.
printf "adjusted at %d. ($o 00)\n", __LINE__ if $debug;
$o = "${o}00";
@@ -450,14 +451,16 @@ sub parse_tz_only
$$tzo = &mkoff($o);
printf "matched at %d. ($$tzo, $o)\n", __LINE__ if $debug;
return 1;
- } elsif ($$tr =~ s#^(?:GMT\s*)?([-+]\d\d\d\d)(\s+|$)##x) {
+ } elsif ($$tr =~ s#^(?:GMT\s*)?([-+]\d\d:?\d\d)(\s+|$)##x) {
$o = $1;
$$tzo = &mkoff($o);
printf "matched at %d.\n", __LINE__ if $debug;
return 1;
} elsif ($$tr =~ s#^"?((?:[A-Z]{1,4}[TCW56])|IDLE)(?:\s+|$ )##x) { #"
$$tz = $1;
- printf "matched at %d.\n", __LINE__ if $debug;
+ $$tz .= " DST"
+ if $$tz eq 'MET' && $$tr =~ s#^DST(?:\s+|$ )##x;
+ printf "matched at %d: '$$tz'.\n", __LINE__ if $debug;
return 1;
}
return 0;
@@ -469,7 +472,7 @@ sub parse_date_only
$$tr =~ s#^\s+##;
- if ($$tr =~ s#^(\d\d\d\d)([-./])(\d\d?)\2(\d\d?)(\s+|$)##) {
+ if ($$tr =~ s#^(\d\d\d\d)([-./])(\d\d?)\2(\d\d?)(\s+|T|$)##) {
# yyyy/mm/dd
($$yr, $$mr, $$dr) = ($1, $3, $4);
@@ -494,7 +497,9 @@ sub parse_date_only
return 1;
} elsif ($$tr =~ s#^(?xi)
(?:
- (?:Mon|Tue|Wed|Thu|Fri|Sat|Sun),?
+ (?:Mon|Monday|Tue|Tuesday|Wed|Wednesday|
+ Thu|Thursday|Fri|Friday|
+ Sat|Saturday|Sun|Sunday),?
\s+
)?
(\d\d?)
@@ -518,7 +523,9 @@ sub parse_date_only
return 1;
} elsif ($$tr =~ s#^(?xi)
(?:
- (?:Mon|Tue|Wed|Thu|Fri|Sat|Sun),?
+ (?:Mon|Monday|Tue|Tuesday|Wed|Wednesday|
+ Thu|Thursday|Fri|Friday|
+ Sat|Saturday|Sun|Sunday),?
\s+
)?
(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\.?
@@ -678,7 +685,7 @@ sub parse_time_only
)?
)
\s*
- ([ap]m)? (?# $4)
+ ([apAP][mM])? (?# $4)
) | (?:
(\d{1,2}) (?# $5)
(?:
@@ -689,7 +696,7 @@ sub parse_time_only
(\d\d) (?# $7)
(
(?# don't barf on database sub-second timings)
- (?:\:|\.)
+ [:.,]
\d{1,6}
)? (?# $8)
)?
@@ -711,7 +718,7 @@ sub parse_time_only
)
)?
(?:
- \s+
+ \s*
|
$
)
@@ -727,19 +734,18 @@ sub parse_time_only
$$sr += $frac;
}
print "S = $$sr\n" if $debug;
- $ampm = $4 || $9 || $11;
+ $ampm = $4 || $9 || $11 || '';
$$tzr = $12;
$$hr += 12 if $ampm and "\U$ampm" eq "PM" && $$hr != 12;
$$hr = 0 if $$hr == 12 && "\U$ampm" eq "AM";
- $$hr = 0 if $$hr == 24;
printf "matched at %d, rem = %s.\n", __LINE__, $$tr if $debug;
return 1;
- } elsif ($$tr =~ s#noon(?:\s+|$ )##ix) {
+ } elsif ($$tr =~ s#^noon(?:\s+|$ )##ix) {
# noon
($$hr, $$mr, $$sr) = (12, 0, 0);
printf "matched at %d.\n", __LINE__ if $debug;
return 1;
- } elsif ($$tr =~ s#midnight(?:\s+|$ )##ix) {
+ } elsif ($$tr =~ s#^midnight(?:\s+|$ )##ix) {
# midnight
($$hr, $$mr, $$sr) = (0, 0, 0);
printf "matched at %d.\n", __LINE__ if $debug;
@@ -756,21 +762,41 @@ sub parse_time_offset
return 0 if $options{NO_RELATIVE};
- if ($$tr =~ s#^(?xi)
- ([-+]?)
+ if ($$tr =~ s{^(?xi)
+ (?:
+ (-) (?# 1)
+ |
+ [+]
+ )?
\s*
- (\d+)
+ (?:
+ (\d+(?:\.\d+)?) (?# 2)
+ |
+ (?:(\d+)\s+(\d+)/(\d+)) (?# 3 4/5)
+ )
\s*
- (sec|second|min|minute|hour)s?
+ (sec|second|min|minute|hour)s? (?# 6)
+ (
+ \s+
+ ago (?# 7)
+ )?
(?:
\s+
|
$
)
- ##) {
+ }{}) {
# count units
$$rsr = 0 unless defined $$rsr;
- $$rsr += $umult{"\L$3"} * "$1$2";
+ return 0 if defined($5) && $5 == 0;
+ my $num = defined($2)
+ ? $2
+ : $3 + $4/$5;
+ $num = -$num if $1;
+ $$rsr += $umult{"\L$6"} * $num;
+
+ $$rsr = -$$rsr if $7 ||
+ $$tr =~ /\b(day|mon|month|year)s?\s*ago\b/;
printf "matched at %d.\n", __LINE__ if $debug;
return 1;
}
@@ -810,7 +836,7 @@ sub expand_two_digit_year
}
} elsif ($options{PREFER_FUTURE}) {
# being strict here would be silly
- if ($yr < $within+10) {
+ if ($yr < $within-20) {
# it's 2019 and the date is '08'
$r = $yr + $century + 100;
}
@@ -837,7 +863,9 @@ sub calc
{
my ($rsr, $yr, $mr, $dr, $rdr, $now, $units, $count, %options) = @_;
+ confess unless $units;
$units = "\L$units";
+ print "calc based on $units\n" if $debug;
if ($units eq 'day') {
$$rdr = $count;
@@ -946,6 +974,29 @@ sub parse_date_offset
$$tr =~ s#^\s+##;
if ($$tr =~ s#^(?xi)
+ \s*
+ (\d+)
+ \s*
+ (day|week|month|year)s?
+ (
+ \s+
+ ago
+ )?
+ (?:
+ \s+
+ |
+ $
+ )
+ ##) {
+ my $amt = $1 + 0;
+ my $units = $2;
+ $amt = -$amt if $3 ||
+ $$tr =~ m#\b(sec|second|min|minute|hour)s?\s*ago\b#;
+ &calc($rsr, $yr, $mr, $dr, $rdr, $now, $units,
+ $amt, %options);
+ printf "matched at %d.\n", __LINE__ if $debug;
+ return 1;
+ } elsif ($$tr =~ s#^(?xi)
(?:
(?:
now
@@ -957,12 +1008,17 @@ sub parse_date_offset
(\d+)
\s*
(day|week|month|year)s?
+ (?:
+ \s+
+ |
+ $
+ )
##) {
- my ($one, $two) = ($1, $2);
- $one = '' unless defined $one;
- $two = '' unless defined $two;
+ my $one = $1 || '';
+ my $two = $2 || '';
+ my $amt = "$one$two"+0;
&calc($rsr, $yr, $mr, $dr, $rdr, $now, $3,
- "$one$two", %options);
+ $amt, %options);
printf "matched at %d.\n", __LINE__ if $debug;
return 1;
} elsif ($$tr =~ s#^(?xi)
@@ -979,6 +1035,19 @@ sub parse_date_offset
printf "matched at %d.\n", __LINE__ if $debug;
return 1;
} elsif ($$tr =~ s#^(?xi)
+ (Mon|Tue|Wed|Thu|Fri|Sat|Sun|Monday|Tuesday
+ |Wednesday|Thursday|Friday|Saturday|Sunday)
+ \s+
+ before
+ \s+
+ last
+ (?: \s+ | $ )
+ ##) {
+ # Dow "before last"
+ $$rdr = $wdays{"\L$1"} - $wday - ( $wdays{"\L$1"} < $wday ? 7 : 14);
+ printf "matched at %d.\n", __LINE__ if $debug;
+ return 1;
+ } elsif ($$tr =~ s#^(?xi)
next\s+
(Mon|Tue|Wed|Thu|Fri|Sat|Sun|Monday|Tuesday
|Wednesday|Thursday|Friday|Saturday|Sunday)
@@ -1046,9 +1115,31 @@ sub parse_date_offset
return 0;
}
+sub debug_display
+{
+ my ($tz, $tzo, $H, $M, $S, $m, $d, $y, $rs, $rd, $rel, $passes, $parse, $t) = @_;
+ print "---------<<\n";
+ print defined($tz) ? "tz: $tz.\n" : "no tz\n";
+ print defined($tzo) ? "tzo: $tzo.\n" : "no tzo\n";
+ print "HMS: ";
+ print defined($H) ? "$H, " : "no H, ";
+ print defined($M) ? "$M, " : "no M, ";
+ print defined($S) ? "$S\n" : "no S.\n";
+ print "mdy: ";
+ print defined($m) ? "$m, " : "no m, ";
+ print defined($d) ? "$d, " : "no d, ";
+ print defined($y) ? "$y\n" : "no y.\n";
+ print defined($rs) ? "rs: $rs.\n" : "no rs\n";
+ print defined($rd) ? "rd: $rd.\n" : "no rd\n";
+ print $rel ? "relative\n" : "not relative\n";
+ print "passes: $passes\n";
+ print "parse:$parse\n";
+ print "t: $t.\n";
+ print "--------->>\n";
+}
1;
-__DATA__
+__END__
=head1 NAME
@@ -1093,6 +1184,7 @@ Date parsing can also use options. The options are as follows:
Month day{st,nd,rd,th}
Mon dd yyyy
yyyy/mm/dd
+ yyyy-mm-dd (usually the best date specification syntax)
yyyy/mm
mm/dd/yy
mm/dd/yyyy
@@ -1110,6 +1202,7 @@ Date parsing can also use options. The options are as follows:
count "months"
count "years"
Dow "after next"
+ Dow "before last"
Dow (requires PREFER_PAST or PREFER_FUTURE)
"next" Dow
"tomorrow"
@@ -1120,8 +1213,9 @@ Date parsing can also use options. The options are as follows:
"now"
"now" "+" count units
"now" "-" count units
- "+" count units
+ "+" count units
"-" count units
+ count units "ago"
=head2 Absolute time formats:
@@ -1135,13 +1229,14 @@ Date parsing can also use options. The options are as follows:
=head2 Relative time formats:
- count "minuts"
+ count "minutes" (count can be franctional "1.5" or "1 1/2")
count "seconds"
count "hours"
"+" count units
"+" count
"-" count units
"-" count
+ count units "ago"
=head2 Timezone formats:
@@ -1167,7 +1262,7 @@ or undef if it was unable to parse the time.
If a timezone is specified it must be after the time. Year specifications
can be tacked onto the end of absolute times.
-If C<parsedate()> is called from array contect, then it will return two
+If C<parsedate()> is called from array context, then it will return two
elements. On sucessful parses, it will return the seconds and what
remains of its input string. On unsucessful parses, it will return
C<undef> and an error string.
@@ -1182,13 +1277,16 @@ C<undef> and an error string.
$seconds = parsedate("+3 secs", NOW => 796978800);
$seconds = parsedate("2 months", NOW => 796720932);
$seconds = parsedate("last Tuesday");
+ $seconds = parsedate("Sunday before last");
($seconds, $remaining) = parsedate("today is the day");
($seconds, $error) = parsedate("today is", WHOLE=>1);
-=head1 AUTHOR
+=head1 LICENSE
-David Muir Sharnoff <muir@idiom.com>. Copyright (C) 1996-1999 All
-Rights Reserved. Use and redistribution allowed at user's own
-risk.
+Copyright (C) 1996-2010 David Muir Sharnoff.
+Copyright (C) 2011 Google, Inc.
+License hereby
+granted for anyone to use, modify or redistribute this module at
+their own risk. Please feed useful changes back to cpan@dave.sharnoff.org.
diff --git a/cpan/dist/Time-modules/lib/Time/Timezone.pm b/cpan/dist/Time-modules/lib/Time/Timezone.pm
index 9a013fd0..d5af6111 100644
--- a/cpan/dist/Time-modules/lib/Time/Timezone.pm
+++ b/cpan/dist/Time-modules/lib/Time/Timezone.pm
@@ -15,7 +15,7 @@ use strict;
use vars qw($VERSION);
-$VERSION = 99.062401;
+$VERSION = 2006.0814;
sub tz2zone
{
@@ -64,14 +64,16 @@ sub tz_local_offset
$time = time() unless $time;
my (@l) = localtime($time);
my $isdst = $l[8] || 0;
+ my $tzenv = defined($ENV{TZ}) ? $ENV{TZ} : "__notz";
- if (@Timezone::tz_local && defined($Timezone::tz_local[$isdst])) {
- return $Timezone::tz_local[$isdst];
+ if ($Timezone::tz_local{$tzenv} &&
+ defined($Timezone::tz_local{$tzenv}[$isdst])) {
+ return $Timezone::tz_local{$tzenv}[$isdst];
}
- $Timezone::tz_local[$isdst] = &calc_off($time);
+ $Timezone::tz_local{$tzenv}[$isdst] = &calc_off($time);
- return $Timezone::tz_local[$isdst];
+ return $Timezone::tz_local{$tzenv}[$isdst];
}
sub calc_off
@@ -83,7 +85,7 @@ sub calc_off
my $off;
- $off = $l[0] - $g[0]
+ $off = $l[0] - $g[0]
+ ($l[1] - $g[1]) * 60
+ ($l[2] - $g[2]) * 3600;
@@ -108,77 +110,136 @@ sub calc_off
}
# constants
-# The rest of the file comes from Graham Barr <bodg@tiuk.ti.com>
+# The rest of the file originally comes from Graham Barr <bodg@tiuk.ti.com>
+#
+# Some references:
+# http://www.weltzeituhr.com/laender/zeitzonen_e.shtml
+# http://www.worldtimezone.com/wtz-names/timezonenames.html
+# http://www.timegenie.com/timezones.php
CONFIG: {
use vars qw(%dstZone %zoneOff %dstZoneOff %Zone);
%dstZone = (
- # "ndt" => -2*3600-1800, # Newfoundland 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
- "ydt" => -8*3600, # Yukon Daylight
- "hdt" => -9*3600, # Hawaii Daylight
- "bst" => +1*3600, # British Summer
- "mest" => +2*3600, # Middle European Summer
- "sst" => +2*3600, # Swedish Summer
- "fst" => +2*3600, # French Summer
- "wadt" => +8*3600, # West Australian 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
+ "ydt" => -8*3600, # Yukon Daylight
+ "hdt" => -9*3600, # Hawaii Daylight
+ "bst" => +1*3600, # British Summer
+ "mest" => +2*3600, # Middle European Summer
+ "met dst" => +2*3600, # Middle European Summer
+ "sst" => +2*3600, # Swedish Summer
+ "fst" => +2*3600, # French Summer
+ "eest" => +3*3600, # Eastern European Summer
+ "cest" => +2*3600, # Central European Daylight
+ "wadt" => +8*3600, # West Australian Daylight
+ "kdt" => +10*3600, # Korean Daylight
# "cadt" => +10*3600+1800, # Central Australian Daylight
- "eadt" => +11*3600, # Eastern Australian Daylight
- "nzdt" => +13*3600, # New Zealand Daylight
+ "eadt" => +11*3600, # Eastern Australian Daylight
+ "nzdt" => +13*3600, # New Zealand Daylight
);
+ # not included due to ambiguity:
+ # IST Indian Standard Time +5.5
+ # Ireland Standard Time 0
+ # Israel Standard Time +2
+ # IDT Ireland Daylight Time +1
+ # Israel Daylight Time +3
+ # AMST Amazon Standard Time / -3
+ # Armenia Standard Time +8
+ # BST Brazil Standard -3
+
%Zone = (
- "gmt" => 0, # Greenwich Mean
- "ut" => 0, # Universal (Coordinated)
- "utc" => 0,
- "wet" => 0, # Western European
- "wat" => -1*3600, # West Africa
- "at" => -2*3600, # Azores
+ "gmt" => 0, # Greenwich Mean
+ "ut" => 0, # Universal (Coordinated)
+ "utc" => 0,
+ "wet" => 0, # Western European
+ "wat" => -1*3600, # West Africa
+ "azost" => -1*3600, # Azores Standard Time
+ "cvt" => -1*3600, # Cape Verde Time
+ "at" => -2*3600, # Azores
+ "fnt" => -2*3600, # Brazil Time (Extreme East - Fernando Noronha)
+ "ndt" => -2*3600-1800,# Newfoundland Daylight
+ "art" => -3*3600, # Argentina Time
# 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
- "ast" => -4*3600, # Atlantic Standard
- "est" => -5*3600, # Eastern Standard
- "cst" => -6*3600, # Central Standard
- "mst" => -7*3600, # Mountain Standard
- "pst" => -8*3600, # Pacific 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
+ "bot" => -4*3600, # Bolivia Time
+ "vet" => -4*3600, # Venezuela Time
+ "est" => -5*3600, # Eastern Standard
+ "cot" => -5*3600, # Colombia Time
+ "act" => -5*3600, # Brazil Time (Extreme West - Acre)
+ "pet" => -5*3600, # Peru Time
+ "cst" => -6*3600, # Central Standard
+ "cest" => +2*3600, # Central European Summer
+ "mst" => -7*3600, # Mountain Standard
+ "pst" => -8*3600, # Pacific Standard
"yst" => -9*3600, # Yukon Standard
"hst" => -10*3600, # Hawaii Standard
"cat" => -10*3600, # Central Alaska
"ahst" => -10*3600, # Alaska-Hawaii Standard
+ "taht" => -10*3600, # Tahiti Time
"nt" => -11*3600, # Nome
"idlw" => -12*3600, # International Date Line West
- "cet" => +1*3600, # Central European
- "met" => +1*3600, # Middle European
- "mewt" => +1*3600, # Middle European Winter
- "swt" => +1*3600, # Swedish Winter
- "fwt" => +1*3600, # French Winter
- "eet" => +2*3600, # Eastern Europe, USSR Zone 1
- "bt" => +3*3600, # Baghdad, USSR Zone 2
+ "cet" => +1*3600, # Central European
+ "mez" => +1*3600, # Central European (German)
+ "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
+ "west" => +1*3600, # Western Europe Summer Time
+ "eet" => +2*3600, # Eastern Europe, USSR Zone 1
+ "ukr" => +2*3600, # Ukraine
+ "sast" => +2*3600, # South Africa Standard Time
+ "bt" => +3*3600, # Baghdad, USSR Zone 2
+ "eat" => +3*3600, # East Africa Time
# "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
+ "irst" => +3*3600+1800,# Iran Standard Time
+ "zp4" => +4*3600, # USSR Zone 3
+ "msd" => +4*3600, # Moscow Daylight Time
+ "sct" => +4*3600, # Seychelles Time
+ "zp5" => +5*3600, # USSR Zone 4
+ "azst" => +5*3600, # Azerbaijan Summer Time
+ "mvt" => +5*3600, # Maldives Time
+ "uzt" => +5*3600, # Uzbekistan Time
+ "ist" => +5*3600+1800,# Indian Standard
+ "zp6" => +6*3600, # USSR Zone 5
+ "lkt" => +6*3600, # Sri Lanka Time
+ "pkst" => +6*3600, # Pakistan Summer Time
+ "yekst" => +6*3600, # Yekaterinburg Summer Time
# 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
- "wast" => +7*3600, # West Australian Standard
+ # "sst" => +7*3600, # South Sumatra, USSR Zone 6
+ "wast" => +7*3600, # West Australian Standard
+ "ict" => +7*3600, # Indochina Time
+ "wit" => +7*3600, # Western Indonesia Time
# "jt" => +7*3600+1800,# Java (3pm in Cronusland!)
- "cct" => +8*3600, # China Coast, USSR Zone 7
+ "cct" => +8*3600, # China Coast, USSR Zone 7
+ "wst" => +8*3600, # West Australian Standard
+ "hkt" => +8*3600, # Hong Kong
+ "bnt" => +8*3600, # Brunei Darussalam Time
+ "cit" => +8*3600, # Central Indonesia Time
+ "myt" => +8*3600, # Malaysia Time
+ "pht" => +8*3600, # Philippines Time
+ "sgt" => +8*3600, # Singapore Time
"jst" => +9*3600, # Japan Standard, USSR Zone 8
+ "kst" => +9*3600, # Korean Standard
# "cast" => +9*3600+1800,# Central Australian Standard
"east" => +10*3600, # Eastern Australian Standard
"gst" => +10*3600, # Guam Standard, USSR Zone 9
+ "nct" => +11*3600, # New Caledonia Time
"nzt" => +12*3600, # New Zealand
"nzst" => +12*3600, # New Zealand Standard
+ "fjt" => +12*3600, # Fiji Time
"idle" => +12*3600, # International Date Line East
);
@@ -187,7 +248,7 @@ CONFIG: {
# Preferences
- $zoneOff{0} = 'gmt';
+ $zoneOff{0} = 'gmt';
$dstZoneOff{3600} = 'bst';
}
@@ -205,8 +266,9 @@ sub tz_offset
$zone = lc $zone;
if ($zone =~ /^([\-\+]\d{3,4})$/) {
- my $v = 0 + $1;
- return int($v / 100) * 60 + ($v % 100);
+ my $sign = $1 < 0 ? -1 : 1 ;
+ my $v = abs(0 + $1);
+ return $sign * 60 * (int($v / 100) * 60 + ($v % 100));
} elsif (exists $dstZone{$zone} && ($dst || !exists $Zone{$zone})) {
return $dstZone{$zone};
} elsif(exists $Zone{$zone}) {
@@ -233,7 +295,7 @@ sub tz_name
1;
-__DATA__
+__END__
=head1 NAME
@@ -268,5 +330,11 @@ C<tz_name()> determines the name of the timezone based on its offset
=head1 AUTHORS
Graham Barr <bodg@tiuk.ti.com>
-David Muir Sharnoff <muir@idiom.com>
+David Muir Sharnoff <muir@idiom.org>
Paul Foley <paul@ascent.com>
+
+=head1 LICENSE
+
+David Muir Sharnoff disclaims any copyright and puts his contribution
+to this module in the public domain.
+
diff --git a/cpan/dist/Time-modules/t/datetime.t b/cpan/dist/Time-modules/t/datetime.t
index a2273c1c..416ebc8e 100755
--- a/cpan/dist/Time-modules/t/datetime.t
+++ b/cpan/dist/Time-modules/t/datetime.t
@@ -1,6 +1,4 @@
-#!/usr/local/bin/perl -I. -w
-
-# David Muir Sharnoff <muir@idiom.com>
+#!/usr/bin/perl -I. -w
# find out why it died if not running under make
@@ -8,7 +6,7 @@ $debug = 0;
$Time::ParseDate::debug = $debug;
-BEGIN {
+BEGIN {
$okat = 12;
$ENV{'LANG'} = 'C';
$ENV{'TZ'} = 'PST8PDT';
@@ -42,6 +40,7 @@ BEGIN {
't' => "\t",
'T' => "21:05:57",
'U' => "46",
+ 'v' => "19-Nov-1994",
'w' => "6",
'W' => "46",
'x' => "11/19/94",
@@ -106,6 +105,7 @@ BEGIN {
827878812, ['Tue Mar 26 23:20:12 GMT+0100 1996'],
827878812, ['Wed Mar 27 05:20:12 GMT+0700 1996'],
827878812, ['Wed Mar 27 05:20:12 +0700 1996'],
+ 827878812, ['Wed Mar 27 05:20:12 +07:00 1996'],
827878812, ['Wed Mar 27 05:20:12 +0700 (EST) 1996'],
796980132, ['1995/04/04 00:22:12 PDT'],
796720932, ['1995/04 00:22:12 PDT'],
@@ -237,6 +237,8 @@ BEGIN {
1924675200, ['12/28/30', NOW => 1262304000],
946751430, ['Jan 1 2000 10:30:30AM'],
946722083, ['Sat Jan 1 02:21:23 2000'],
+ 946774740, ['Jan 1 2000 4:59PM', WHOLE => 1],
+ 946774740, ['Jan 1 2000 4:59PM', WHOLE => 1],
0, ['1970/01/01 00:00:00', ZONE => GMT],
796980132, ['Tue 4 Apr 1995 00:22:12 PDT 8', WHOLE => 0],
789008700, ['dec 32 94 17:05'],
@@ -256,6 +258,58 @@ BEGIN {
-1231084800, ['28/12/30', NOW => 1262304000, PREFER_PAST => 1, UK => 1],
1577520000, ['12/28/19', NOW => 902938515, PREFER_FUTURE => 1],
1766908800, ['12/28/25', NOW => 902938515],
+ 958521600, ['17 May 2000 00:00:00 GMT'],
+ 979718400, ['1/17/01', NOW => 993067736],
+ 995353200, ['7/17/01', NOW => 993067736],
+ 995353200, ['7/17/01', NOW => 993067736, PREFER_FUTURE => 1],
+ 995366188, ['17/07/2001 18:36:28 +0800', WHOLE => 1],
+ 995366188, ['17/07/2001 18:36:28+0800', WHOLE => 1],
+ 995330188, ['17/07/2001 0:36:28+0000', WHOLE => 1],
+ 995416588, ['17/07/2001 24:36:28+0000', WHOLE => 1],
+ undef, ['17/07/2001 24:36:28+0000', WHOLE => 1, VALIDATE => 1],
+ 995330188, ['17/07/2001 0:36:28+0000', WHOLE => 1, VALIDATE => 1],
+ 796375332, ['4 days ago', WHOLE =>1, ZONE => PDT, NOW => 796720932],
+ 796720931, ['1 second ago', WHOLE =>1, ZONE => PDT, NOW => 796720932],
+ 796375331, ['4 days 1 second ago', WHOLE =>1, ZONE => PDT, NOW => 796720932],
+ 796375331, ['1 second 4 days ago', WHOLE =>1, ZONE => PDT, NOW => 796720932],
+ 953467299, ['Sun Mar 19 17:31:39 IST 2000'],
+ 784111777, ['Sunday, 06-Nov-94 08:49:37 GMT' ],
+ 954933672, ['Wed Apr 5 13:21:12 MET DST 2000' ],
+ 729724230, ['1993-02-14T13:10:30', NOW => 796980132],
+#ISO8601 729724230, ['19930214T131030', NOW => 796980132],
+ 14400, ['+4 hours', NOW => 0],
+ 345600, ['+4 days', NOW => 0],
+ 957744000, ['Sunday before last', NOW => 958521600],
+ 957139200, ['Sunday before last', NOW => 958348800],
+ 796720930.5, ['1.5 second ago', WHOLE =>1.5, ZONE => PDT, NOW => 796720932],
+ 796720930.5, ['1 1/2 second ago', WHOLE =>1.5, ZONE => PDT, NOW => 796720932],
+ 5, ['5 seconds', UK => 1, NOW => 0],
+ 6, ['5 seconds', UK => 1, NOW => 1],
+ 1078876800, ['2004-03-10 00:00:00 GMT'],
+ 1081551599, ['-1 second +1 month', NOW => 1078876800, ZONE => 'PDT'],
+ 1081526399, ['-1 second +1 month', NOW => 1078876800, ZONE => 'GMT'],
+ 1304661600, ['11pm', NOW => 1304611460],
+ 1304636400, ['11pm', NOW => 1304611460, GMT => 1],
+ 1304557200, ['1am', NOW => 1304611460, GMT => 1],
+ 1246950000, ['2009/7/7'],
+ -1636819200, ['1918/2/18'],
+ 1246950000, ['2009/7/7'],
+ 1256435700, ['2009-10-25 02:55:00', ZONE => 'MET'],
+ 1256439300, ['+ 1 hour', NOW => 1256435700, ZONE => 'MET'],
+ 1256464500, ['2009-10-25 02:55:00', ZONE => 'PDT'],
+ 1256468100, ['+ 1 hour', NOW => 1256464500, ZONE => 'PDT'],
+ 1256468100, ['2009-10-25 02:55:00', ZONE => 'PST'],
+ 1256471700, ['+ 1 hour', NOW => 1256468100, ZONE => 'PST'],
+ [1304622000, 'Foo'], ['12pm Foo', NOW => 1304611460, WHOLE => 0],
+ undef, ['Foo 12pm', NOW => 1304611460, WHOLE => 0],
+ undef, ['Foo noon', NOW => 1304611460, WHOLE => 0],
+ undef, ['Foo midnight', NOW => 1304611460, WHOLE => 0],
+ 1011252345, ['Wed Jan 16 23:25:45 2002'],
+ 1012550400, ['Feb 1', NOW => 1011252345],
+ 1012550400, ['Feb 1', NOW => 1011252345, FUZZY => 1, PREFER_FUTURE => 1],
+ 1012550400, ['2/1/02', NOW => 1011252345, FUZZY => 1, PREFER_FUTURE => 1],
+ 1011247200, ['6am', GMT => 1, NOW => 1011252345],
+ 1256435700, ['2009-10-25 02:55:00', ZONE => 'MEZ'],
);
%tztests = (
@@ -272,10 +326,26 @@ use Time::JulianDay;
use Time::ParseDate;
use Time::Local;
use Time::Timezone;
+use POSIX qw(tzset);
+
+tzset;
+
+my @x = localtime(785307957);
+my @y = gmtime(785307957);
+my $hd = $y[2] - $x[2];
+$hd += 24 if $hd < 0;
+$hd %= 24;
+if ($hd != 8) {
+ print "1..0 # Skipped: It seems localtime() does not honor \$ENV{TZ} when set in the test script. Please set the TZ environment variable to PST8PDT and rerun.";
+ print "hd = $hd, x = @x, y = @y\n" if $debug || -t STDOUT;
+ exit 0;
+}
my $before_big = $okat-1+scalar(keys %k)+scalar(keys %tztests);
-printf "1..%d\n", $before_big + @sdt/2;
+printf "1..%d\n", $before_big + scalar(grep(ref($_), @sdt));
+
+print "ok 1\n";
$epoch = ($Time::JulianDay::jd_epoch - 2440588) * 86400
+ $Time::JulianDay::jd_epoch_remainder;
@@ -283,18 +353,6 @@ print STDERR "\nEpoch = $epoch\n" if $epoch;
$etime = 785307957.5 - $epoch;
-@x = localtime(785307957);
-@y = gmtime(785307957);
-my $hd = $y[2] - $x[2];
-$hd += 24 if $hd < 0;
-$hd %= 24;
-if ($hd != 8) {
- print STDERR "\nIt seems localtime() does not honor \$ENV{TZ} when set in the test script.\nPlease set the TZ environment variable to PST8PDT and rerun.\n";
- print "hd = $hd, x = @x, y = @y\n" if $debug || -t STDOUT;
- print "not ok 1\n";
-} else {
- print "ok 1\n";
-}
eval " 1/0; "; # tests a bug in ctime!
$x = ctime($etime);
@@ -349,7 +407,7 @@ $c = $okat;
$lt[0] += ($etime - int($etime));
foreach $i (sort keys %k) {
$x = strftime("-%$i-", @lt);
- print $x eq "-$k{$i}-" ? "ok $c\n" : "not ok $c\n";
+ print $x eq "-$k{$i}-" ? "ok $c # $i - $k{$i}\n" : "not ok $c # $i - $k{$i}: $x\n";
if ($debug && $x ne "-$k{$i}-") {
print "strftime(\"-%$i-\") = $x.\n\tshould be: $k{$i}.\n";
exit(0);
@@ -367,8 +425,14 @@ foreach $i (keys %tztests) {
$c++;
}
+
while (@sdt) {
$es = shift(@sdt);
+ my $eremaining;
+ if (ref($es)) {
+ $eremaining = $es->[1];
+ $es = $es->[0];
+ }
$es -= $epoch if defined($es);
$ar = shift(@sdt);
$toparse = shift(@$ar);
@@ -377,13 +441,18 @@ while (@sdt) {
$opts{NOW} -= $epoch;
}
$opts{WHOLE} = 1 unless defined $opts{WHOLE};
- $s = parsedate($toparse, %opts);
+ my $remaining;
+ if (defined $eremaining) {
+ ($s, $remaining) = parsedate($toparse, %opts);
+ } else {
+ $s = parsedate($toparse, %opts);
+ }
if (! defined($es) && ! defined($s)) {
- print "ok $c\n";
- } elsif ($es == $s) {
- print "ok $c\n";
+ print "ok $c # $toparse\n";
+ } elsif (defined($es) && defined($s) && $es == $s) {
+ print "ok $c # $toparse\n";
} else {
- print "not ok $c\n";
+ print "not ok $c # $toparse\n";
if (-t STDOUT || $debug) {
if (defined($es)) {
print strftime("Expected($es): %c %Z\n", localtime($es));
@@ -412,5 +481,16 @@ while (@sdt) {
}
}
}
+ if (defined($eremaining)) {
+ $c++;
+ if ($remaining eq $eremaining) {
+ print "ok $c # remaining = '$eremaining'\n";
+ } else {
+ print "not ok $c # remaining = '$eremaining'\n";
+ if (-t STDOUT || $debug) {
+ print "# got '$remaining' instead\n";
+ }
+ }
+ }
$c++;
}
diff --git a/cpan/dist/Time-modules/t/metdate.t b/cpan/dist/Time-modules/t/metdate.t
new file mode 100644
index 00000000..8b6baedd
--- /dev/null
+++ b/cpan/dist/Time-modules/t/metdate.t
@@ -0,0 +1,72 @@
+#!/usr/bin/perl -I. -w
+
+use strict;
+use warnings;
+use Test::More;
+use Time::ParseDate;
+use Time::CTime;
+use POSIX qw(tzset);
+
+my $finished;
+END { ok($finished, 'finished') if defined $finished }
+
+$ENV{'LANG'} = 'C';
+$ENV{'TZ'} = 'PST8PDT';
+tzset;
+
+my @x = localtime(785307957);
+my @y = gmtime(785307957);
+my $hd = $y[2] - $x[2];
+$hd += 24 if $hd < 0;
+$hd %= 24;
+if ($hd != 8) {
+ import Test::More skip_all => "It seems localtime() does not honor \$ENV{TZ} when set in the test script.";
+ exit 0;
+}
+import Test::More qw(no_plan);
+
+$ENV{'TZ'} = 'MET';
+tzset;
+
+@x = localtime(785307957);
+@y = gmtime(785307957);
+$hd = $y[2] - $x[2];
+$hd += 24 if $hd < 0;
+$hd %= 24;
+if ($hd != 23) {
+ print "1..0 # Skipped: It seems localtime() does not honor \$ENV{TZ} when set in the test script.\n";
+ exit 0;
+}
+
+$finished = 0;
+
+$ENV{TZ} = 'MET';
+tzset;
+
+my $t0 = parsedate("2009-10-25 02:55:00");
+my $t1 = parsedate("+ 1 hour", NOW => scalar(parsedate("2009-10-25 02:55:00")));
+my $lt1 = scalar(localtime($t1));
+
+is($t0, 1256435700, "testing TZ=MET seconds");
+is($t1, 1256439300, "testing TZ=MET seconds +1 h");
+is($lt1, "Sun Oct 25 03:55:00 2009", "testing TZ=MET +1 h localtime");
+
+$ENV{TZ} = "PST8PDT";
+tzset;
+
+my $p0 = parsedate("2009-11-01 01:55:00");
+my $p1 = parsedate("+ 1 hour", NOW => scalar(parsedate("2009-11-01 01:55:00")));
+my $lp0 = scalar(localtime($p0));
+my $lp1 = scalar(localtime($p1));
+my $lpz0 = strftime("%R %Z",localtime($p0));
+my $lpz1 = strftime("%R %Z",localtime($p1));
+
+is($p0, 1257065700, "testing PST8PDT");
+is($lp0, "Sun Nov 1 01:55:00 2009", "testing PST8PDT localtime");
+is($p1, 1257069300, "testing PST8PDT");
+is($lp1, "Sun Nov 1 01:55:00 2009", "testing PST8PDT localtime");
+is($lpz0, "01:55 PDT", "zone 0");
+is($lpz1, "01:55 PST", "zone 1");
+
+$finished = 1;
+
diff --git a/cpan/dist/Time-modules/t/order1.t b/cpan/dist/Time-modules/t/order1.t
new file mode 100644
index 00000000..b0c2a30c
--- /dev/null
+++ b/cpan/dist/Time-modules/t/order1.t
@@ -0,0 +1,33 @@
+#!/usr/bin/perl -I. -w
+
+use strict;
+use warnings;
+use Test::More;
+use Time::ParseDate;
+use POSIX qw(tzset);
+
+my $finished;
+END { ok($finished, 'finished') if defined $finished }
+
+$ENV{'LANG'} = 'C';
+$ENV{'TZ'} = 'PST8PDT';
+tzset;
+
+my @x = localtime(785307957);
+my @y = gmtime(785307957);
+my $hd = $y[2] - $x[2];
+$hd += 24 if $hd < 0;
+$hd %= 24;
+if ($hd != 8) {
+ import Test::More skip_all => "It seems localtime() does not honor \$ENV{TZ} when set in the test script. Please set the TZ environment variable to PST8PDT and rerun.";
+ exit 0;
+}
+import Test::More qw(no_plan);
+
+$finished = 0;
+
+is(parsedate('1918/2/18'), -1636819200, "year 1918");
+is(parsedate('2009/7/7'), 1246950000, "year 2009");
+
+$finished = 1;
+
diff --git a/cpan/dist/Time-modules/t/order2.t b/cpan/dist/Time-modules/t/order2.t
new file mode 100644
index 00000000..cf4ea65d
--- /dev/null
+++ b/cpan/dist/Time-modules/t/order2.t
@@ -0,0 +1,33 @@
+#!/usr/bin/perl -I. -w
+
+use strict;
+use warnings;
+use Time::ParseDate;
+use Test::More;
+use POSIX qw(tzset);
+
+my $finished;
+END { ok($finished, 'finished') if defined $finished }
+
+$ENV{'LANG'} = 'C';
+$ENV{'TZ'} = 'PST8PDT';
+tzset;
+
+my @x = localtime(785307957);
+my @y = gmtime(785307957);
+my $hd = $y[2] - $x[2];
+$hd += 24 if $hd < 0;
+$hd %= 24;
+if ($hd != 8) {
+ import Test::More skip_all => "It seems localtime() does not honor \$ENV{TZ} when set in the test script. Please set the TZ environment variable to PST8PDT and rerun.";
+ exit 0;
+}
+import Test::More qw(no_plan);
+
+$finished = 0;
+
+is(parsedate('2009/7/7'), 1246950000, "year 2009");
+is(parsedate('1918/2/18'), -1636819200, "year 1918");
+
+$finished = 1;
+
diff --git a/cpan/lib/Time/CTime.pm b/cpan/lib/Time/CTime.pm
index 530a6094..29b259d1 100644
--- a/cpan/lib/Time/CTime.pm
+++ b/cpan/lib/Time/CTime.pm
@@ -16,7 +16,7 @@ use strict;
use vars qw(@DoW @DayOfWeek @MoY @MonthOfYear %strftime_conversion $VERSION);
use vars qw($template $sec $min $hour $mday $mon $year $wday $yday $isdst);
-$VERSION = 99.06_22_01;
+$VERSION = 2011.0505;
CONFIG: {
@DoW = qw(Sun Mon Tue Wed Thu Fri Sat);
@@ -54,6 +54,7 @@ CONFIG: {
't', sub { "\t" },
'T', sub { sprintf("%02d:%02d:%02d", $hour, $min, $sec) },
'U', sub { wkyr(0, $wday, $yday) },
+ 'v', sub { sprintf("%2d-%s-%4d", $mday, $MoY[$mon], $year+1900) },
'w', sub { $wday },
'W', sub { wkyr(1, $wday, $yday) },
'y', sub { sprintf("%02d",$year%100) },
@@ -61,6 +62,7 @@ CONFIG: {
'x', sub { sprintf("%02d/%02d/%02d", $mon + 1, $mday, $year%100) },
'X', sub { sprintf("%02d:%02d:%02d", $hour, $min, $sec) },
'Z', sub { &tz2zone(undef,undef,$isdst) }
+ # z sprintf("%+03d%02d", $offset / 3600, ($offset % 3600)/60);
);
@@ -115,14 +117,14 @@ sub strftime {
local ($template, $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = @_;
undef $@;
- $template =~ s/%([%aAbBcdDefFhHIjklmMnopQrRStTUwWxXyYZ])/&{$Time::CTime::strftime_conversion{$1}}()/egs;
+ $template =~ s/%([%aAbBcdDefFhHIjklmMnopQrRStTUvwWxXyYZ])/&{$Time::CTime::strftime_conversion{$1}}()/egs;
die $@ if $@;
return $template;
}
1;
-__DATA__
+__END__
=head1 NAME
@@ -154,7 +156,7 @@ Time::CTime -- format times ala POSIX asctime
%j day of the year
%k hour
%l hour, 12 hour clock
- %m month number, starting with 1
+ %m month number, starting with 1, leading 0's
%M minute, leading 0's
%n NEWLINE
%o ornate day of month -- "1st", "2nd", "25th", etc.
@@ -165,6 +167,7 @@ Time::CTime -- format times ala POSIX asctime
%t TAB
%T time format: 21:05:57
%U week number, Sunday as first day of week
+ %v DD-Mon-Year
%w day of the week, numerically, Sunday == 0
%W week number, Monday as first day of week
%x date format: 11/19/94
@@ -187,11 +190,16 @@ libraries.
=head1 GENESIS
-Written by David Muir Sharnoff <muir@idiom.com>.
+Written by David Muir Sharnoff <muir@idiom.org>.
The starting point for this package was a posting by
Paul Foley <paul@ascent.com>
-Copyright (C) 1996-1999 David Muir Sharnoff. All Rights Reserved.
-Use and redistribution allowed at user's own risk.
+=head1 LICENSE
+
+Copyright (C) 1996-2010 David Muir Sharnoff.
+Copyright (C) 2011 Google, Inc.
+License hereby
+granted for anyone to use, modify or redistribute this module at
+their own risk. Please feed useful changes back to cpan@dave.sharnoff.org.
diff --git a/cpan/lib/Time/DaysInMonth.pm b/cpan/lib/Time/DaysInMonth.pm
index 2139f2f8..60a75086 100644
--- a/cpan/lib/Time/DaysInMonth.pm
+++ b/cpan/lib/Time/DaysInMonth.pm
@@ -12,7 +12,7 @@ use strict;
use vars qw($VERSION %mltable);
-$VERSION = 96.032702;
+$VERSION = 99.1117;
CONFIG: {
%mltable = qw(
@@ -49,7 +49,7 @@ sub is_leap
1;
-__DATA__
+__END__
=head1 NAME
@@ -68,8 +68,16 @@ a month. That's all it does. Really!
=head1 AUTHOR
-David Muir Sharnoff <muir@idiom.com>
+David Muir Sharnoff <muir@idiom.org>
-Copyright (C) 1996-1999 David Muir Sharnoff. All Rights Reserved.
-Use and redistribution allowed at user's own risk.
+=head1 BUGS
+
+This only deals with the "modern" calendar. Look elsewhere for
+historical time and date support.
+
+=head1 LICENSE
+
+Copyright (C) 1996-1999 David Muir Sharnoff. License hereby
+granted for anyone to use, modify or redistribute this module at
+their own risk. Please feed useful changes back to muir@idiom.org.
diff --git a/cpan/lib/Time/JulianDay.pm b/cpan/lib/Time/JulianDay.pm
index 1b011da1..a749c798 100644
--- a/cpan/lib/Time/JulianDay.pm
+++ b/cpan/lib/Time/JulianDay.pm
@@ -19,14 +19,13 @@ use integer;
# constants
use vars qw($brit_jd $jd_epoch $jd_epoch_remainder $VERSION);
-$VERSION = 99.061501;
+$VERSION = 2011.0505;
# calculate the julian day, given $year, $month and $day
sub julian_day
{
my($year, $month, $day) = @_;
my($tmp);
- my($secs);
use Carp;
# confess() unless defined $day;
@@ -157,7 +156,7 @@ sub jd_timegm
1;
-__DATA__
+__END__
=head1 NAME
@@ -189,12 +188,37 @@ using julian days...
The day_of_week returned by day_of_week() is 0 for Sunday, and 6 for
Saturday and everything else is in between.
+=head1 ERRATA
+
+Time::JulianDay is not a correct implementation. There are two
+problems. The first problem is that Time::JulianDay only works
+with integers. Julian Day can be fractional to represent time
+within a day. If you call inverse_julian_day() with a non-integer
+time, it will often give you an incorrect result.
+
+The second problem is that Julian Days start at noon rather than
+midnight. The julian_day() function returns results that are too
+large by 0.5.
+
+What to do about these problems is currently open for debate. I'm
+tempted to leave the current functions alone and add a second set
+with more accurate behavior.
+
+There is another implementation in Astro::Time that may be more accurate.
+
=head1 GENESIS
-Written by David Muir Sharnoff <muir@idiom.com> with help from
+Written by David Muir Sharnoff <cpan@dave.sharnoff.org> with help from
previous work by
Kurt Jaeger aka PI <zrzr0111@helpdesk.rus.uni-stuttgart.de>
based on postings from: Ian Miller <ian_m@cix.compulink.co.uk>;
Gary Puckering <garyp%cognos.uucp@uunet.uu.net>
based on Collected Algorithms of the ACM ?;
and the unknown-to-me author of Time::Local.
+
+=head1 LICENSE
+
+Copyright (C) 1996-1999 David Muir Sharnoff. License hereby
+granted for anyone to use, modify or redistribute this module at
+their own risk. Please feed useful changes back to cpan@dave.sharnoff.org.
+
diff --git a/cpan/lib/Time/ParseDate.pm b/cpan/lib/Time/ParseDate.pm
index 8f1c18fb..c46b7323 100644
--- a/cpan/lib/Time/ParseDate.pm
+++ b/cpan/lib/Time/ParseDate.pm
@@ -12,11 +12,12 @@ require Exporter;
@EXPORT_OK = qw(pd_raw %mtable %umult %wdays);
use strict;
+#use diagnostics;
# constants
use vars qw(%mtable %umult %wdays $VERSION);
-$VERSION = 100.01_03_01;
+$VERSION = 2011.0517;
# globals
use vars qw($debug);
@@ -49,7 +50,8 @@ CONFIG: {
min 60 minute 60
hour 3600
day 86400
- week 604800 );
+ week 604800
+ fortnight 1209600);
%wdays = qw(
sun 0 sunday 0
mon 1 monday 1
@@ -76,7 +78,7 @@ sub parsedate
my $rel; # time&|date is relative
my $isspec;
- my $now = $options{NOW} || time;
+ my $now = defined($options{NOW}) ? $options{NOW} : time;
my $passes = 0;
my $uk = defined($options{UK}) ? $options{UK} : 0;
@@ -157,7 +159,7 @@ sub parsedate
}
}
if (defined $M or defined $rd) {
- if ($t =~ s/^\s*(?:at|\+)\s*(\s+|$)//x) {
+ if ($t =~ s/^\s*(?:at|\@|\+)\s*(\s+|$)//x) {
$rel = 1;
$parse .= " ".__LINE__ if $debug;
next;
@@ -165,8 +167,9 @@ sub parsedate
}
last;
} continue {
- print "context$parse remaider = $t.\n" if $debug;
$passes++;
+ &debug_display($tz, $tzo, $H, $M, $S, $m, $d, $y, $rs, $rd, $rel, $passes, $parse, $t) if $debug;
+
}
if ($passes == 0) {
@@ -177,32 +180,18 @@ sub parsedate
}
}
- if ($debug) {
- print "t: $t.\n";
- print defined($tz) ? "tz: $tz.\n" : "no tz\n";
- print defined($tzo) ? "tzo: $tzo.\n" : "no tzo\n";
- print "HMS: ";
- print defined($H) ? "$H, " : "no H, ";
- print defined($M) ? "$M, " : "no M, ";
- print defined($S) ? "$S\n" : "no S.\n";
- print "mdy: ";
- print defined($m) ? "$m, " : "no m, ";
- print defined($d) ? "$d, " : "no d, ";
- print defined($y) ? "$y\n" : "no y.\n";
- print defined($rs) ? "rs: $rs.\n" : "no rs\n";
- print defined($rd) ? "rd: $rd.\n" : "no rd\n";
- print "parse:$parse\n";
- print "passes: $passes\n";
- }
+ &debug_display($tz, $tzo, $H, $M, $S, $m, $d, $y, $rs, $rd, $rel, $passes, $parse, $t) if $debug;
$t =~ s/^\s+//;
if ($t ne '') {
# we didn't manage to eat the string
print "NOT WHOLE\n" if $debug;
- return undef if $options{WHOLE};
- return (undef, "characters left over after parse")
- if wantarray();
+ if ($options{WHOLE}) {
+ return (undef, "characters left over after parse")
+ if wantarray();
+ return undef
+ }
}
# define a date if there isn't one already
@@ -211,9 +200,11 @@ sub parsedate
print "no date defined, trying to find one." if $debug;
if (defined $rs or defined $H) {
# we do have a time.
- return (undef, "no date specified")
- if wantarray();
- return undef if $options{DATE_REQUIRED};
+ if ($options{DATE_REQUIRED}) {
+ return (undef, "no date specified")
+ if wantarray();
+ return undef;
+ }
if (defined $rs) {
print "simple offset: $rs\n" if $debug;
my $rv = $now + $rs;
@@ -264,7 +255,9 @@ sub parsedate
}
print "relative date\n" if $debug;
- $jd = local_julian_day($now);
+ $jd = $options{GMT}
+ ? gm_julian_day($now)
+ : local_julian_day($now);
print "jd($now) = $jd\n" if $debug;
$jd += $rd;
} else {
@@ -338,16 +331,13 @@ sub parsedate
}
$S += $rs if defined $rs;
- $carry = int($S / 60);
- my($frac) = $S - int($S);
- $S = int($S);
- $S %= 60;
- $S += $frac;
+ $carry = int($S / 60) - ($S < 0 && $S % 60 && 1);
+ $S -= $carry * 60;
$M += $carry;
- $carry = int($M / 60);
+ $carry = int($M / 60) - ($M < 0 && $M % 60 && 1);
$M %= 60;
$H += $carry;
- $carry = int($H / 24);
+ $carry = int($H / 24) - ($H < 0 && $H % 24 && 1);
$H %= 24;
$jd += $carry;
@@ -365,17 +355,28 @@ sub parsedate
my $tzadj;
if ($tz) {
$tzadj = tz_offset($tz, $secs);
- print "adjusting secs for $tz: $tzadj\n" if $debug;
- $tzadj = tz_offset($tz, $secs-$tzadj);
- $secs -= $tzadj;
+ if (defined $tzadj) {
+ print "adjusting secs for $tz: $tzadj\n" if $debug;
+ $tzadj = tz_offset($tz, $secs-$tzadj);
+ $secs -= $tzadj;
+ } else {
+ print "unknown timezone: $tz\n" if $debug;
+ undef $secs;
+ undef $t;
+ }
} elsif (defined $tzo) {
print "adjusting time for offset: $tzo\n" if $debug;
$secs -= $tzo;
} else {
unless ($options{GMT}) {
if ($options{ZONE}) {
- $tzadj = tz_offset($options{ZONE}, $secs);
+ $tzadj = tz_offset($options{ZONE}, $secs) || 0;
$tzadj = tz_offset($options{ZONE}, $secs-$tzadj);
+ unless (defined($tzadj)) {
+ return (undef, "could not convert '$options{ZONE}' to time offset")
+ if wantarray();
+ return undef;
+ }
print "adjusting secs for $options{ZONE}: $tzadj\n" if $debug;
$secs -= $tzadj;
} else {
@@ -402,7 +403,7 @@ sub mkoff
{
my($offset) = @_;
- if (defined $offset and $offset =~ s#^([-+])(\d\d)(\d\d)$##) {
+ if (defined $offset and $offset =~ s#^([-+])(\d\d):?(\d\d)$##) {
return ($1 eq '+' ?
3600 * $2 + 60 * $3
: -3600 * $2 + -60 * $3 );
@@ -418,7 +419,7 @@ sub parse_tz_only
my $o;
if ($$tr =~ s#^
- ([-+]\d\d\d\d)
+ ([-+]\d\d:?\d\d)
\s+
\(
"?
@@ -441,7 +442,7 @@ sub parse_tz_only
return 1;
} elsif ($$tr =~ s#^GMT\s*([-+]\d{1,2})(\s+|$)##x) {
$o = $1;
- if ($o <= 24 and $o !~ /^0/) {
+ if ($o < 24 and $o !~ /^0/) {
# probably hours.
printf "adjusted at %d. ($o 00)\n", __LINE__ if $debug;
$o = "${o}00";
@@ -450,14 +451,16 @@ sub parse_tz_only
$$tzo = &mkoff($o);
printf "matched at %d. ($$tzo, $o)\n", __LINE__ if $debug;
return 1;
- } elsif ($$tr =~ s#^(?:GMT\s*)?([-+]\d\d\d\d)(\s+|$)##x) {
+ } elsif ($$tr =~ s#^(?:GMT\s*)?([-+]\d\d:?\d\d)(\s+|$)##x) {
$o = $1;
$$tzo = &mkoff($o);
printf "matched at %d.\n", __LINE__ if $debug;
return 1;
} elsif ($$tr =~ s#^"?((?:[A-Z]{1,4}[TCW56])|IDLE)(?:\s+|$ )##x) { #"
$$tz = $1;
- printf "matched at %d.\n", __LINE__ if $debug;
+ $$tz .= " DST"
+ if $$tz eq 'MET' && $$tr =~ s#^DST(?:\s+|$ )##x;
+ printf "matched at %d: '$$tz'.\n", __LINE__ if $debug;
return 1;
}
return 0;
@@ -469,7 +472,7 @@ sub parse_date_only
$$tr =~ s#^\s+##;
- if ($$tr =~ s#^(\d\d\d\d)([-./])(\d\d?)\2(\d\d?)(\s+|$)##) {
+ if ($$tr =~ s#^(\d\d\d\d)([-./])(\d\d?)\2(\d\d?)(\s+|T|$)##) {
# yyyy/mm/dd
($$yr, $$mr, $$dr) = ($1, $3, $4);
@@ -494,7 +497,9 @@ sub parse_date_only
return 1;
} elsif ($$tr =~ s#^(?xi)
(?:
- (?:Mon|Tue|Wed|Thu|Fri|Sat|Sun),?
+ (?:Mon|Monday|Tue|Tuesday|Wed|Wednesday|
+ Thu|Thursday|Fri|Friday|
+ Sat|Saturday|Sun|Sunday),?
\s+
)?
(\d\d?)
@@ -518,7 +523,9 @@ sub parse_date_only
return 1;
} elsif ($$tr =~ s#^(?xi)
(?:
- (?:Mon|Tue|Wed|Thu|Fri|Sat|Sun),?
+ (?:Mon|Monday|Tue|Tuesday|Wed|Wednesday|
+ Thu|Thursday|Fri|Friday|
+ Sat|Saturday|Sun|Sunday),?
\s+
)?
(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\.?
@@ -678,7 +685,7 @@ sub parse_time_only
)?
)
\s*
- ([ap]m)? (?# $4)
+ ([apAP][mM])? (?# $4)
) | (?:
(\d{1,2}) (?# $5)
(?:
@@ -689,7 +696,7 @@ sub parse_time_only
(\d\d) (?# $7)
(
(?# don't barf on database sub-second timings)
- (?:\:|\.)
+ [:.,]
\d{1,6}
)? (?# $8)
)?
@@ -711,7 +718,7 @@ sub parse_time_only
)
)?
(?:
- \s+
+ \s*
|
$
)
@@ -727,19 +734,18 @@ sub parse_time_only
$$sr += $frac;
}
print "S = $$sr\n" if $debug;
- $ampm = $4 || $9 || $11;
+ $ampm = $4 || $9 || $11 || '';
$$tzr = $12;
$$hr += 12 if $ampm and "\U$ampm" eq "PM" && $$hr != 12;
$$hr = 0 if $$hr == 12 && "\U$ampm" eq "AM";
- $$hr = 0 if $$hr == 24;
printf "matched at %d, rem = %s.\n", __LINE__, $$tr if $debug;
return 1;
- } elsif ($$tr =~ s#noon(?:\s+|$ )##ix) {
+ } elsif ($$tr =~ s#^noon(?:\s+|$ )##ix) {
# noon
($$hr, $$mr, $$sr) = (12, 0, 0);
printf "matched at %d.\n", __LINE__ if $debug;
return 1;
- } elsif ($$tr =~ s#midnight(?:\s+|$ )##ix) {
+ } elsif ($$tr =~ s#^midnight(?:\s+|$ )##ix) {
# midnight
($$hr, $$mr, $$sr) = (0, 0, 0);
printf "matched at %d.\n", __LINE__ if $debug;
@@ -756,21 +762,41 @@ sub parse_time_offset
return 0 if $options{NO_RELATIVE};
- if ($$tr =~ s#^(?xi)
- ([-+]?)
+ if ($$tr =~ s{^(?xi)
+ (?:
+ (-) (?# 1)
+ |
+ [+]
+ )?
\s*
- (\d+)
+ (?:
+ (\d+(?:\.\d+)?) (?# 2)
+ |
+ (?:(\d+)\s+(\d+)/(\d+)) (?# 3 4/5)
+ )
\s*
- (sec|second|min|minute|hour)s?
+ (sec|second|min|minute|hour)s? (?# 6)
+ (
+ \s+
+ ago (?# 7)
+ )?
(?:
\s+
|
$
)
- ##) {
+ }{}) {
# count units
$$rsr = 0 unless defined $$rsr;
- $$rsr += $umult{"\L$3"} * "$1$2";
+ return 0 if defined($5) && $5 == 0;
+ my $num = defined($2)
+ ? $2
+ : $3 + $4/$5;
+ $num = -$num if $1;
+ $$rsr += $umult{"\L$6"} * $num;
+
+ $$rsr = -$$rsr if $7 ||
+ $$tr =~ /\b(day|mon|month|year)s?\s*ago\b/;
printf "matched at %d.\n", __LINE__ if $debug;
return 1;
}
@@ -810,7 +836,7 @@ sub expand_two_digit_year
}
} elsif ($options{PREFER_FUTURE}) {
# being strict here would be silly
- if ($yr < $within+10) {
+ if ($yr < $within-20) {
# it's 2019 and the date is '08'
$r = $yr + $century + 100;
}
@@ -837,7 +863,9 @@ sub calc
{
my ($rsr, $yr, $mr, $dr, $rdr, $now, $units, $count, %options) = @_;
+ confess unless $units;
$units = "\L$units";
+ print "calc based on $units\n" if $debug;
if ($units eq 'day') {
$$rdr = $count;
@@ -946,6 +974,29 @@ sub parse_date_offset
$$tr =~ s#^\s+##;
if ($$tr =~ s#^(?xi)
+ \s*
+ (\d+)
+ \s*
+ (day|week|month|year)s?
+ (
+ \s+
+ ago
+ )?
+ (?:
+ \s+
+ |
+ $
+ )
+ ##) {
+ my $amt = $1 + 0;
+ my $units = $2;
+ $amt = -$amt if $3 ||
+ $$tr =~ m#\b(sec|second|min|minute|hour)s?\s*ago\b#;
+ &calc($rsr, $yr, $mr, $dr, $rdr, $now, $units,
+ $amt, %options);
+ printf "matched at %d.\n", __LINE__ if $debug;
+ return 1;
+ } elsif ($$tr =~ s#^(?xi)
(?:
(?:
now
@@ -957,12 +1008,17 @@ sub parse_date_offset
(\d+)
\s*
(day|week|month|year)s?
+ (?:
+ \s+
+ |
+ $
+ )
##) {
- my ($one, $two) = ($1, $2);
- $one = '' unless defined $one;
- $two = '' unless defined $two;
+ my $one = $1 || '';
+ my $two = $2 || '';
+ my $amt = "$one$two"+0;
&calc($rsr, $yr, $mr, $dr, $rdr, $now, $3,
- "$one$two", %options);
+ $amt, %options);
printf "matched at %d.\n", __LINE__ if $debug;
return 1;
} elsif ($$tr =~ s#^(?xi)
@@ -979,6 +1035,19 @@ sub parse_date_offset
printf "matched at %d.\n", __LINE__ if $debug;
return 1;
} elsif ($$tr =~ s#^(?xi)
+ (Mon|Tue|Wed|Thu|Fri|Sat|Sun|Monday|Tuesday
+ |Wednesday|Thursday|Friday|Saturday|Sunday)
+ \s+
+ before
+ \s+
+ last
+ (?: \s+ | $ )
+ ##) {
+ # Dow "before last"
+ $$rdr = $wdays{"\L$1"} - $wday - ( $wdays{"\L$1"} < $wday ? 7 : 14);
+ printf "matched at %d.\n", __LINE__ if $debug;
+ return 1;
+ } elsif ($$tr =~ s#^(?xi)
next\s+
(Mon|Tue|Wed|Thu|Fri|Sat|Sun|Monday|Tuesday
|Wednesday|Thursday|Friday|Saturday|Sunday)
@@ -1046,9 +1115,31 @@ sub parse_date_offset
return 0;
}
+sub debug_display
+{
+ my ($tz, $tzo, $H, $M, $S, $m, $d, $y, $rs, $rd, $rel, $passes, $parse, $t) = @_;
+ print "---------<<\n";
+ print defined($tz) ? "tz: $tz.\n" : "no tz\n";
+ print defined($tzo) ? "tzo: $tzo.\n" : "no tzo\n";
+ print "HMS: ";
+ print defined($H) ? "$H, " : "no H, ";
+ print defined($M) ? "$M, " : "no M, ";
+ print defined($S) ? "$S\n" : "no S.\n";
+ print "mdy: ";
+ print defined($m) ? "$m, " : "no m, ";
+ print defined($d) ? "$d, " : "no d, ";
+ print defined($y) ? "$y\n" : "no y.\n";
+ print defined($rs) ? "rs: $rs.\n" : "no rs\n";
+ print defined($rd) ? "rd: $rd.\n" : "no rd\n";
+ print $rel ? "relative\n" : "not relative\n";
+ print "passes: $passes\n";
+ print "parse:$parse\n";
+ print "t: $t.\n";
+ print "--------->>\n";
+}
1;
-__DATA__
+__END__
=head1 NAME
@@ -1093,6 +1184,7 @@ Date parsing can also use options. The options are as follows:
Month day{st,nd,rd,th}
Mon dd yyyy
yyyy/mm/dd
+ yyyy-mm-dd (usually the best date specification syntax)
yyyy/mm
mm/dd/yy
mm/dd/yyyy
@@ -1110,6 +1202,7 @@ Date parsing can also use options. The options are as follows:
count "months"
count "years"
Dow "after next"
+ Dow "before last"
Dow (requires PREFER_PAST or PREFER_FUTURE)
"next" Dow
"tomorrow"
@@ -1120,8 +1213,9 @@ Date parsing can also use options. The options are as follows:
"now"
"now" "+" count units
"now" "-" count units
- "+" count units
+ "+" count units
"-" count units
+ count units "ago"
=head2 Absolute time formats:
@@ -1135,13 +1229,14 @@ Date parsing can also use options. The options are as follows:
=head2 Relative time formats:
- count "minuts"
+ count "minutes" (count can be franctional "1.5" or "1 1/2")
count "seconds"
count "hours"
"+" count units
"+" count
"-" count units
"-" count
+ count units "ago"
=head2 Timezone formats:
@@ -1167,7 +1262,7 @@ or undef if it was unable to parse the time.
If a timezone is specified it must be after the time. Year specifications
can be tacked onto the end of absolute times.
-If C<parsedate()> is called from array contect, then it will return two
+If C<parsedate()> is called from array context, then it will return two
elements. On sucessful parses, it will return the seconds and what
remains of its input string. On unsucessful parses, it will return
C<undef> and an error string.
@@ -1182,13 +1277,16 @@ C<undef> and an error string.
$seconds = parsedate("+3 secs", NOW => 796978800);
$seconds = parsedate("2 months", NOW => 796720932);
$seconds = parsedate("last Tuesday");
+ $seconds = parsedate("Sunday before last");
($seconds, $remaining) = parsedate("today is the day");
($seconds, $error) = parsedate("today is", WHOLE=>1);
-=head1 AUTHOR
+=head1 LICENSE
-David Muir Sharnoff <muir@idiom.com>. Copyright (C) 1996-1999 All
-Rights Reserved. Use and redistribution allowed at user's own
-risk.
+Copyright (C) 1996-2010 David Muir Sharnoff.
+Copyright (C) 2011 Google, Inc.
+License hereby
+granted for anyone to use, modify or redistribute this module at
+their own risk. Please feed useful changes back to cpan@dave.sharnoff.org.
diff --git a/cpan/lib/Time/Timezone.pm b/cpan/lib/Time/Timezone.pm
index 9a013fd0..d5af6111 100644
--- a/cpan/lib/Time/Timezone.pm
+++ b/cpan/lib/Time/Timezone.pm
@@ -15,7 +15,7 @@ use strict;
use vars qw($VERSION);
-$VERSION = 99.062401;
+$VERSION = 2006.0814;
sub tz2zone
{
@@ -64,14 +64,16 @@ sub tz_local_offset
$time = time() unless $time;
my (@l) = localtime($time);
my $isdst = $l[8] || 0;
+ my $tzenv = defined($ENV{TZ}) ? $ENV{TZ} : "__notz";
- if (@Timezone::tz_local && defined($Timezone::tz_local[$isdst])) {
- return $Timezone::tz_local[$isdst];
+ if ($Timezone::tz_local{$tzenv} &&
+ defined($Timezone::tz_local{$tzenv}[$isdst])) {
+ return $Timezone::tz_local{$tzenv}[$isdst];
}
- $Timezone::tz_local[$isdst] = &calc_off($time);
+ $Timezone::tz_local{$tzenv}[$isdst] = &calc_off($time);
- return $Timezone::tz_local[$isdst];
+ return $Timezone::tz_local{$tzenv}[$isdst];
}
sub calc_off
@@ -83,7 +85,7 @@ sub calc_off
my $off;
- $off = $l[0] - $g[0]
+ $off = $l[0] - $g[0]
+ ($l[1] - $g[1]) * 60
+ ($l[2] - $g[2]) * 3600;
@@ -108,77 +110,136 @@ sub calc_off
}
# constants
-# The rest of the file comes from Graham Barr <bodg@tiuk.ti.com>
+# The rest of the file originally comes from Graham Barr <bodg@tiuk.ti.com>
+#
+# Some references:
+# http://www.weltzeituhr.com/laender/zeitzonen_e.shtml
+# http://www.worldtimezone.com/wtz-names/timezonenames.html
+# http://www.timegenie.com/timezones.php
CONFIG: {
use vars qw(%dstZone %zoneOff %dstZoneOff %Zone);
%dstZone = (
- # "ndt" => -2*3600-1800, # Newfoundland 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
- "ydt" => -8*3600, # Yukon Daylight
- "hdt" => -9*3600, # Hawaii Daylight
- "bst" => +1*3600, # British Summer
- "mest" => +2*3600, # Middle European Summer
- "sst" => +2*3600, # Swedish Summer
- "fst" => +2*3600, # French Summer
- "wadt" => +8*3600, # West Australian 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
+ "ydt" => -8*3600, # Yukon Daylight
+ "hdt" => -9*3600, # Hawaii Daylight
+ "bst" => +1*3600, # British Summer
+ "mest" => +2*3600, # Middle European Summer
+ "met dst" => +2*3600, # Middle European Summer
+ "sst" => +2*3600, # Swedish Summer
+ "fst" => +2*3600, # French Summer
+ "eest" => +3*3600, # Eastern European Summer
+ "cest" => +2*3600, # Central European Daylight
+ "wadt" => +8*3600, # West Australian Daylight
+ "kdt" => +10*3600, # Korean Daylight
# "cadt" => +10*3600+1800, # Central Australian Daylight
- "eadt" => +11*3600, # Eastern Australian Daylight
- "nzdt" => +13*3600, # New Zealand Daylight
+ "eadt" => +11*3600, # Eastern Australian Daylight
+ "nzdt" => +13*3600, # New Zealand Daylight
);
+ # not included due to ambiguity:
+ # IST Indian Standard Time +5.5
+ # Ireland Standard Time 0
+ # Israel Standard Time +2
+ # IDT Ireland Daylight Time +1
+ # Israel Daylight Time +3
+ # AMST Amazon Standard Time / -3
+ # Armenia Standard Time +8
+ # BST Brazil Standard -3
+
%Zone = (
- "gmt" => 0, # Greenwich Mean
- "ut" => 0, # Universal (Coordinated)
- "utc" => 0,
- "wet" => 0, # Western European
- "wat" => -1*3600, # West Africa
- "at" => -2*3600, # Azores
+ "gmt" => 0, # Greenwich Mean
+ "ut" => 0, # Universal (Coordinated)
+ "utc" => 0,
+ "wet" => 0, # Western European
+ "wat" => -1*3600, # West Africa
+ "azost" => -1*3600, # Azores Standard Time
+ "cvt" => -1*3600, # Cape Verde Time
+ "at" => -2*3600, # Azores
+ "fnt" => -2*3600, # Brazil Time (Extreme East - Fernando Noronha)
+ "ndt" => -2*3600-1800,# Newfoundland Daylight
+ "art" => -3*3600, # Argentina Time
# 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
- "ast" => -4*3600, # Atlantic Standard
- "est" => -5*3600, # Eastern Standard
- "cst" => -6*3600, # Central Standard
- "mst" => -7*3600, # Mountain Standard
- "pst" => -8*3600, # Pacific 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
+ "bot" => -4*3600, # Bolivia Time
+ "vet" => -4*3600, # Venezuela Time
+ "est" => -5*3600, # Eastern Standard
+ "cot" => -5*3600, # Colombia Time
+ "act" => -5*3600, # Brazil Time (Extreme West - Acre)
+ "pet" => -5*3600, # Peru Time
+ "cst" => -6*3600, # Central Standard
+ "cest" => +2*3600, # Central European Summer
+ "mst" => -7*3600, # Mountain Standard
+ "pst" => -8*3600, # Pacific Standard
"yst" => -9*3600, # Yukon Standard
"hst" => -10*3600, # Hawaii Standard
"cat" => -10*3600, # Central Alaska
"ahst" => -10*3600, # Alaska-Hawaii Standard
+ "taht" => -10*3600, # Tahiti Time
"nt" => -11*3600, # Nome
"idlw" => -12*3600, # International Date Line West
- "cet" => +1*3600, # Central European
- "met" => +1*3600, # Middle European
- "mewt" => +1*3600, # Middle European Winter
- "swt" => +1*3600, # Swedish Winter
- "fwt" => +1*3600, # French Winter
- "eet" => +2*3600, # Eastern Europe, USSR Zone 1
- "bt" => +3*3600, # Baghdad, USSR Zone 2
+ "cet" => +1*3600, # Central European
+ "mez" => +1*3600, # Central European (German)
+ "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
+ "west" => +1*3600, # Western Europe Summer Time
+ "eet" => +2*3600, # Eastern Europe, USSR Zone 1
+ "ukr" => +2*3600, # Ukraine
+ "sast" => +2*3600, # South Africa Standard Time
+ "bt" => +3*3600, # Baghdad, USSR Zone 2
+ "eat" => +3*3600, # East Africa Time
# "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
+ "irst" => +3*3600+1800,# Iran Standard Time
+ "zp4" => +4*3600, # USSR Zone 3
+ "msd" => +4*3600, # Moscow Daylight Time
+ "sct" => +4*3600, # Seychelles Time
+ "zp5" => +5*3600, # USSR Zone 4
+ "azst" => +5*3600, # Azerbaijan Summer Time
+ "mvt" => +5*3600, # Maldives Time
+ "uzt" => +5*3600, # Uzbekistan Time
+ "ist" => +5*3600+1800,# Indian Standard
+ "zp6" => +6*3600, # USSR Zone 5
+ "lkt" => +6*3600, # Sri Lanka Time
+ "pkst" => +6*3600, # Pakistan Summer Time
+ "yekst" => +6*3600, # Yekaterinburg Summer Time
# 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
- "wast" => +7*3600, # West Australian Standard
+ # "sst" => +7*3600, # South Sumatra, USSR Zone 6
+ "wast" => +7*3600, # West Australian Standard
+ "ict" => +7*3600, # Indochina Time
+ "wit" => +7*3600, # Western Indonesia Time
# "jt" => +7*3600+1800,# Java (3pm in Cronusland!)
- "cct" => +8*3600, # China Coast, USSR Zone 7
+ "cct" => +8*3600, # China Coast, USSR Zone 7
+ "wst" => +8*3600, # West Australian Standard
+ "hkt" => +8*3600, # Hong Kong
+ "bnt" => +8*3600, # Brunei Darussalam Time
+ "cit" => +8*3600, # Central Indonesia Time
+ "myt" => +8*3600, # Malaysia Time
+ "pht" => +8*3600, # Philippines Time
+ "sgt" => +8*3600, # Singapore Time
"jst" => +9*3600, # Japan Standard, USSR Zone 8
+ "kst" => +9*3600, # Korean Standard
# "cast" => +9*3600+1800,# Central Australian Standard
"east" => +10*3600, # Eastern Australian Standard
"gst" => +10*3600, # Guam Standard, USSR Zone 9
+ "nct" => +11*3600, # New Caledonia Time
"nzt" => +12*3600, # New Zealand
"nzst" => +12*3600, # New Zealand Standard
+ "fjt" => +12*3600, # Fiji Time
"idle" => +12*3600, # International Date Line East
);
@@ -187,7 +248,7 @@ CONFIG: {
# Preferences
- $zoneOff{0} = 'gmt';
+ $zoneOff{0} = 'gmt';
$dstZoneOff{3600} = 'bst';
}
@@ -205,8 +266,9 @@ sub tz_offset
$zone = lc $zone;
if ($zone =~ /^([\-\+]\d{3,4})$/) {
- my $v = 0 + $1;
- return int($v / 100) * 60 + ($v % 100);
+ my $sign = $1 < 0 ? -1 : 1 ;
+ my $v = abs(0 + $1);
+ return $sign * 60 * (int($v / 100) * 60 + ($v % 100));
} elsif (exists $dstZone{$zone} && ($dst || !exists $Zone{$zone})) {
return $dstZone{$zone};
} elsif(exists $Zone{$zone}) {
@@ -233,7 +295,7 @@ sub tz_name
1;
-__DATA__
+__END__
=head1 NAME
@@ -268,5 +330,11 @@ C<tz_name()> determines the name of the timezone based on its offset
=head1 AUTHORS
Graham Barr <bodg@tiuk.ti.com>
-David Muir Sharnoff <muir@idiom.com>
+David Muir Sharnoff <muir@idiom.org>
Paul Foley <paul@ascent.com>
+
+=head1 LICENSE
+
+David Muir Sharnoff disclaims any copyright and puts his contribution
+to this module in the public domain.
+