r70456 - in /trunk/libdatetime-format-w3cdtf-perl: ./ debian/ debian/source/ examples/ inc/ lib/DateTime/Format/ t/
ansgar at users.alioth.debian.org
ansgar at users.alioth.debian.org
Sat Mar 5 14:46:48 UTC 2011
Author: ansgar
Date: Sat Mar 5 14:46:39 2011
New Revision: 70456
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=70456
Log:
* Team upload.
* New upstream release.
* Add (build-)dep on libdatetime-timezone-perl.
* Use source format 3.0 (quilt).
* debian/copyright: Formatting changes; refer to GPL-1; refer to "Debian
systems" instead of "Debian GNU/Linux systems".
Added:
trunk/libdatetime-format-w3cdtf-perl/debian/source/
trunk/libdatetime-format-w3cdtf-perl/debian/source/format
trunk/libdatetime-format-w3cdtf-perl/debian/source/local-options
trunk/libdatetime-format-w3cdtf-perl/examples/
- copied from r70455, branches/upstream/libdatetime-format-w3cdtf-perl/current/examples/
trunk/libdatetime-format-w3cdtf-perl/inc/
- copied from r70455, branches/upstream/libdatetime-format-w3cdtf-perl/current/inc/
trunk/libdatetime-format-w3cdtf-perl/t/pod.t
- copied unchanged from r70455, branches/upstream/libdatetime-format-w3cdtf-perl/current/t/pod.t
trunk/libdatetime-format-w3cdtf-perl/t/pod_coverage.t
- copied unchanged from r70455, branches/upstream/libdatetime-format-w3cdtf-perl/current/t/pod_coverage.t
Removed:
trunk/libdatetime-format-w3cdtf-perl/Build.PL
Modified:
trunk/libdatetime-format-w3cdtf-perl/Changes
trunk/libdatetime-format-w3cdtf-perl/MANIFEST
trunk/libdatetime-format-w3cdtf-perl/META.yml
trunk/libdatetime-format-w3cdtf-perl/Makefile.PL
trunk/libdatetime-format-w3cdtf-perl/README
trunk/libdatetime-format-w3cdtf-perl/SIGNATURE
trunk/libdatetime-format-w3cdtf-perl/debian/changelog
trunk/libdatetime-format-w3cdtf-perl/debian/control
trunk/libdatetime-format-w3cdtf-perl/debian/copyright
trunk/libdatetime-format-w3cdtf-perl/lib/DateTime/Format/W3CDTF.pm
trunk/libdatetime-format-w3cdtf-perl/t/01parse.t
Modified: trunk/libdatetime-format-w3cdtf-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-w3cdtf-perl/Changes?rev=70456&op=diff
==============================================================================
--- trunk/libdatetime-format-w3cdtf-perl/Changes (original)
+++ trunk/libdatetime-format-w3cdtf-perl/Changes Sat Mar 5 14:46:39 2011
@@ -1,9 +1,13 @@
+0.06 2011-02-06
+
+- Fixed parsing of datetimes with sub-second precision (RT #14179, patch from
+ Andrew Turner).
+
0.05 2009-11-01
- Fixed a long-standing bug where a time zone other than UTC that had an
offset of 0 caused the format_datetime method to return the string "0". RT
#22802.
-
0.04 2003-11-23
Modified: trunk/libdatetime-format-w3cdtf-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-w3cdtf-perl/MANIFEST?rev=70456&op=diff
==============================================================================
--- trunk/libdatetime-format-w3cdtf-perl/MANIFEST (original)
+++ trunk/libdatetime-format-w3cdtf-perl/MANIFEST Sat Mar 5 14:46:39 2011
@@ -1,12 +1,23 @@
-Build.PL
+inc/Module/Install.pm
+inc/Module/Install/Base.pm
+inc/Module/Install/Can.pm
+inc/Module/Install/Fetch.pm
+inc/Module/Install/Makefile.pm
+inc/Module/Install/Metadata.pm
+inc/Module/Install/Win32.pm
+inc/Module/Install/WriteAll.pm
Changes
lib/DateTime/Format/W3CDTF.pm
LICENSE
Makefile.PL
MANIFEST This list of files
-META.yml
-README
t/00load.t
t/01parse.t
t/02bugs.t
-SIGNATURE Added here by Module::Build
+t/pod.t
+t/pod_coverage.t
+Makefile.PL
+README
+META.yml
+examples/now.pl
+SIGNATURE Public-key signature (added by MakeMaker)
Modified: trunk/libdatetime-format-w3cdtf-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-w3cdtf-perl/META.yml?rev=70456&op=diff
==============================================================================
--- trunk/libdatetime-format-w3cdtf-perl/META.yml (original)
+++ trunk/libdatetime-format-w3cdtf-perl/META.yml Sat Mar 5 14:46:39 2011
@@ -1,26 +1,30 @@
---
-name: DateTime-Format-W3CDTF
-version: 0.05
+abstract: 'Parse and format W3CDTF datetime strings'
author:
- - 'Dave Rolsky E<lt>autarch at urth.orgE<gt>'
-abstract: Parse and format W3CDTF datetime strings
+ - 'Dave Rolsky <autarch at urth.org>'
+ - 'Gregory Todd Williams <gwilliams at cpan.org>'
+build_requires:
+ ExtUtils::MakeMaker: 6.42
+ Test::More: 0.61
+configure_requires:
+ ExtUtils::MakeMaker: 6.42
+distribution_type: module
+generated_by: 'Module::Install version 0.99'
license: perl
-resources:
- bugtracker: http://rt.cpan.org/NoAuth/Bugs.html?Dist=DateTime-Format-W3CDTF
- homepage: http://datetime.perl.org/
- license: http://dev.perl.org/licenses/
- repository: https://perl-date-time.svn.sourceforge.net/svnroot/perl-date-time
-build_requires:
- Test::More: 0
-requires:
- DateTime: 0
-configure_requires:
- Module::Build: 0.35
-provides:
- DateTime::Format::W3CDTF:
- file: lib/DateTime/Format/W3CDTF.pm
- version: 0.05
-generated_by: Module::Build version 0.35
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
+name: DateTime-Format-W3CDTF
+no_index:
+ directory:
+ - examples
+ - inc
+ - t
+requires:
+ DateTime: 0
+resources:
+ bugtracker: http://rt.cpan.org/NoAuth/Bugs.html?Dist=DateTime-Format-W3CDTF
+ homepage: http://search.cpan.org/dist/DateTime-Format-W3CDTF/
+ license: http://dev.perl.org/licenses/
+ repository: http://github.com/kasei/datetime-format-w3cdtf
+version: 0.06
Modified: trunk/libdatetime-format-w3cdtf-perl/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-w3cdtf-perl/Makefile.PL?rev=70456&op=diff
==============================================================================
--- trunk/libdatetime-format-w3cdtf-perl/Makefile.PL (original)
+++ trunk/libdatetime-format-w3cdtf-perl/Makefile.PL Sat Mar 5 14:46:39 2011
@@ -1,15 +1,23 @@
-# Note: this file was auto-generated by Module::Build::Compat version 0.35
-use ExtUtils::MakeMaker;
-WriteMakefile
-(
- 'NAME' => 'DateTime::Format::W3CDTF',
- 'VERSION_FROM' => 'lib/DateTime/Format/W3CDTF.pm',
- 'PREREQ_PM' => {
- 'DateTime' => '0',
- 'Test::More' => '0'
- },
- 'INSTALLDIRS' => 'site',
- 'EXE_FILES' => [],
- 'PL_FILES' => {}
- )
-;
+use strict;
+use warnings;
+
+use inc::Module::Install;
+
+name 'DateTime-Format-W3CDTF';
+all_from 'lib/DateTime/Format/W3CDTF.pm';
+author 'Gregory Todd Williams <gwilliams at cpan.org>';
+license 'perl';
+
+build_requires 'Test::More' => 0.61;
+
+requires 'DateTime' => 0;
+
+resources(
+ 'homepage' => "http://search.cpan.org/dist/DateTime-Format-W3CDTF/",
+ 'repository' => "http://github.com/kasei/datetime-format-w3cdtf",
+ 'bugtracker' => "http://rt.cpan.org/NoAuth/Bugs.html?Dist=DateTime-Format-W3CDTF",
+);
+
+sign;
+
+WriteAll;
Modified: trunk/libdatetime-format-w3cdtf-perl/README
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-w3cdtf-perl/README?rev=70456&op=diff
==============================================================================
--- trunk/libdatetime-format-w3cdtf-perl/README (original)
+++ trunk/libdatetime-format-w3cdtf-perl/README Sat Mar 5 14:46:39 2011
@@ -21,23 +21,26 @@
METHODS
This API is currently experimental and may change in the future.
- * parse_datetime($string)
+ * parse_datetime($string)
+
Given a W3CDTF datetime string, this method will return a new
- `DateTime' object.
+ "DateTime" object.
If given an improperly formatted string, this method may die.
- * format_datetime($datetime)
- Given a `DateTime' object, this methods returns a W3CDTF datetime
+ * format_datetime($datetime)
+
+ Given a "DateTime" object, this methods returns a W3CDTF datetime
string.
NOTE: As of version 0.4, format_datetime no longer attempts to
truncate datetimes without a time component. This is due to the fact
- that `DateTime' doesn't distinguish between a date with no time
+ that "DateTime" doesn't distinguish between a date with no time
component, and midnight.
- * format_date($datetime)
- Given a `DateTime' object, return a W3CDTF datetime string without
+ * format_date($datetime)
+
+ Given a "DateTime" object, return a W3CDTF datetime string without
the time component.
SUPPORT
@@ -52,8 +55,8 @@
Dave Rolsky <autarch at urth.org>
CREDITS
- This module was originally created by Kellan Elliott-McCrea
- <kellan at protest.net>.
+ This module is maintained by Gregory Todd Williams <gwilliams at cpan.org>.
+ It was originally created by Kellan Elliott-McCrea <kellan at protest.net>.
This module was inspired by DateTime::Format::ICal
Modified: trunk/libdatetime-format-w3cdtf-perl/SIGNATURE
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-w3cdtf-perl/SIGNATURE?rev=70456&op=diff
==============================================================================
--- trunk/libdatetime-format-w3cdtf-perl/SIGNATURE (original)
+++ trunk/libdatetime-format-w3cdtf-perl/SIGNATURE Sat Mar 5 14:46:39 2011
@@ -1,5 +1,5 @@
This file contains message digests of all files listed in MANIFEST,
-signed via the Module::Signature module, version 0.55.
+signed via the Module::Signature module, version 0.61.
To verify the content in this distribution, first make sure you have
Module::Signature installed, then type:
@@ -14,21 +14,31 @@
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
-SHA1 ae4198042de9996dba6444776228388228e91eca Build.PL
-SHA1 702e98902eb6fe7224b9ece349f16f1629e0bd04 Changes
+SHA1 fe08fc077e7d5bfa2cc68a2cb4b06fe0a26b8c6c Changes
SHA1 f235ba4160673bcb7c9d58c2f09dbc7fc0efadea LICENSE
-SHA1 b3c9f84f87eb0fb17c512fc07aef3f5936b02a75 MANIFEST
-SHA1 1369094d003ae4ccfb769c0a9aedfdcbc516e1b1 META.yml
-SHA1 bec7021434f2cd45163007cd51448891c13ff308 Makefile.PL
-SHA1 93db7b819544a166ed7f2e6b2ee21ad6236c644d README
-SHA1 045cbdf1dc0f15f863dae26f8a2961a146a46fe3 lib/DateTime/Format/W3CDTF.pm
+SHA1 c50534da6f72a6983bb3cd253afcf4c6e5f71dd9 MANIFEST
+SHA1 b0a8815cc87f77331e8bbee40f6fbb1067c1c26a META.yml
+SHA1 236f91cd1eed26d8d60047986510e01010e84788 Makefile.PL
+SHA1 bee25dfc8c7b9823a45ebc7cd4efade3bdbe39b0 README
+SHA1 8f033b8d00052585fd49221934f9df392981d798 examples/now.pl
+SHA1 53b08a2e448ac8751374a8eed725dfc09aa5fb63 inc/Module/Install.pm
+SHA1 150c0cf35e6b96a0d8eea62194c8abc0da182c86 inc/Module/Install/Base.pm
+SHA1 70c3500a28a1e5d255599ce3f44e9a7b80759109 inc/Module/Install/Can.pm
+SHA1 5f0d6d859fb1cf84cd9bbb1e263d18f581c7e537 inc/Module/Install/Fetch.pm
+SHA1 75f901a4b514a772b03223e1b08e3b5cc78b1667 inc/Module/Install/Makefile.pm
+SHA1 29044991152cb220fcd2a5ccc3512139d2f5f577 inc/Module/Install/Metadata.pm
+SHA1 896bba60ebe29b3b60fce8414f923fec97bf53e1 inc/Module/Install/Win32.pm
+SHA1 e5c82926a05f844765964b013b31c48eefbb208c inc/Module/Install/WriteAll.pm
+SHA1 a81c54f293edc92f66cc2417aac16d58d0f7c49a lib/DateTime/Format/W3CDTF.pm
SHA1 71cbf0df8c25a43c7baf65877c60c852fae1f1c0 t/00load.t
-SHA1 78102b8a839dda3387e63cb7ed939ba696e1b42f t/01parse.t
+SHA1 3fb45f4dda907dbe20f9854ce6f4c9a8f5bafad0 t/01parse.t
SHA1 374b4554a0a5ab940154dcfe9afc889e555ac4f3 t/02bugs.t
+SHA1 6387af7a5fde0747be5bc9ad2ec15ca9759bd95a t/pod.t
+SHA1 9115f7ffe1933ad736dc292f3c89595b36ed6aa2 t/pod_coverage.t
-----BEGIN PGP SIGNATURE-----
-Version: GnuPG v1.4.9 (GNU/Linux)
+Version: GnuPG v1.4.10 (Darwin)
-iEYEARECAAYFAkruBegACgkQIgMCsV8qvRKGYQCdHvu+G43YT6jrbYyP29YpKM5d
-lJgAniSETJm6dvjNuSX5gAb8BsC/NIk1
-=hlX4
+iEYEARECAAYFAk1OuEoACgkQhPK6VMqoyC1tQwCeMSMicin0ncOd2zUwoD3m2hrb
+mLgAn2ydzSB5O9cpe02lCCUUGZLPaKE3
+=Nnlp
-----END PGP SIGNATURE-----
Modified: trunk/libdatetime-format-w3cdtf-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-w3cdtf-perl/debian/changelog?rev=70456&op=diff
==============================================================================
--- trunk/libdatetime-format-w3cdtf-perl/debian/changelog (original)
+++ trunk/libdatetime-format-w3cdtf-perl/debian/changelog Sat Mar 5 14:46:39 2011
@@ -1,3 +1,14 @@
+libdatetime-format-w3cdtf-perl (0.06-1) unstable; urgency=low
+
+ * Team upload.
+ * New upstream release.
+ * Add (build-)dep on libdatetime-timezone-perl.
+ * Use source format 3.0 (quilt).
+ * debian/copyright: Formatting changes; refer to GPL-1; refer to "Debian
+ systems" instead of "Debian GNU/Linux systems".
+
+ -- Ansgar Burchardt <ansgar at debian.org> Sat, 05 Mar 2011 15:46:32 +0100
+
libdatetime-format-w3cdtf-perl (0.05-1) unstable; urgency=low
[ Jonathan Yu ]
Modified: trunk/libdatetime-format-w3cdtf-perl/debian/control
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-w3cdtf-perl/debian/control?rev=70456&op=diff
==============================================================================
--- trunk/libdatetime-format-w3cdtf-perl/debian/control (original)
+++ trunk/libdatetime-format-w3cdtf-perl/debian/control Sat Mar 5 14:46:39 2011
@@ -2,18 +2,18 @@
Section: perl
Priority: optional
Build-Depends: debhelper (>= 7)
-Build-Depends-Indep: perl, libdatetime-perl
+Build-Depends-Indep: perl, libdatetime-perl, libdatetime-timezone-perl
Maintainer: Debian Perl Group <pkg-perl-maintainers at lists.alioth.debian.org>
Uploaders: Jaldhar H. Vyas <jaldhar at debian.org>, gregor herrmann <gregoa at debian.org>,
Jonathan Yu <jawnsy at cpan.org>
-Standards-Version: 3.8.3
+Standards-Version: 3.9.1
Homepage: http://search.cpan.org/dist/DateTime-Format-W3CDTF/
Vcs-Svn: svn://svn.debian.org/pkg-perl/trunk/libdatetime-format-w3cdtf-perl/
Vcs-Browser: http://svn.debian.org/viewsvn/pkg-perl/trunk/libdatetime-format-w3cdtf-perl/
Package: libdatetime-format-w3cdtf-perl
Architecture: all
-Depends: ${perl:Depends}, ${misc:Depends}, libdatetime-perl
+Depends: ${perl:Depends}, ${misc:Depends}, libdatetime-perl, libdatetime-timezone-perl
Description: module to parse and format W3CDTF datetime strings
DateTime::Format::W3CDTF is a Perl module that understands the W3CDTF date
and time format, an ISO 8601 profile. It has a full specification online at:
Modified: trunk/libdatetime-format-w3cdtf-perl/debian/copyright
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-w3cdtf-perl/debian/copyright?rev=70456&op=diff
==============================================================================
--- trunk/libdatetime-format-w3cdtf-perl/debian/copyright (original)
+++ trunk/libdatetime-format-w3cdtf-perl/debian/copyright Sat Mar 5 14:46:39 2011
@@ -1,31 +1,33 @@
-Format-Specification:
- http://wiki.debian.org/Proposals/CopyrightFormat?action=recall&rev=196
-Upstream-Maintainer: Dave Rolsky <autarch at urth.org>
-Upstream-Source: http://search.cpan.org/dist/DateTime-Format-W3CDTF/
-Upstream-Name: DateTime-Format-W3CDTF
+Format-Specification: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?op=file&rev=135
+Maintainer: Dave Rolsky <autarch at urth.org>
+Source: http://search.cpan.org/dist/DateTime-Format-W3CDTF/
+Name: DateTime-Format-W3CDTF
Files: *
-Copyright: 2009, Dave Rolsky <autarch at urth.org>
+Copyright:
+ 2009, Dave Rolsky <autarch at urth.org>
2003, Kellan Elliott-McCrea <kellan at protest.net>
-License-Alias: Perl
-License: Artistic | GPL-1+
+License: Artistic or GPL-1+
Files: debian/*
-Copyright: 2009, Jonathan Yu <jawnsy at cpan.org>
+Copyright:
+ 2009, Jonathan Yu <jawnsy at cpan.org>
2006-2008, gregor herrmann <gregoa at debian.org>
2006, Jaldhar H. Vyas <jaldhar at debian.org>
-License: Artistic | GPL-1+
+License: Artistic or GPL-1+
License: Artistic
- This program is free software; you can redistribute it and/or modify
- it under the terms of the Artistic License, which comes with Perl.
- On Debian GNU/Linux systems, the complete text of the Artistic License
- can be found in `/usr/share/common-licenses/Artistic'
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the Artistic License, which comes with Perl.
+ .
+ On Debian systems, the complete text of the Artistic License can be
+ found in `/usr/share/common-licenses/Artistic'.
License: GPL-1+
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
- any later version.
- On Debian GNU/Linux systems, the complete text of the GNU General
- Public License can be found in `/usr/share/common-licenses/GPL'
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 1, or (at your option)
+ any later version.
+ .
+ On Debian systems, the complete text of version 1 of the GNU General
+ Public License can be found in `/usr/share/common-licenses/GPL-1'.
Added: trunk/libdatetime-format-w3cdtf-perl/debian/source/format
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-w3cdtf-perl/debian/source/format?rev=70456&op=file
==============================================================================
--- trunk/libdatetime-format-w3cdtf-perl/debian/source/format (added)
+++ trunk/libdatetime-format-w3cdtf-perl/debian/source/format Sat Mar 5 14:46:39 2011
@@ -1,0 +1,1 @@
+3.0 (quilt)
Added: trunk/libdatetime-format-w3cdtf-perl/debian/source/local-options
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-w3cdtf-perl/debian/source/local-options?rev=70456&op=file
==============================================================================
--- trunk/libdatetime-format-w3cdtf-perl/debian/source/local-options (added)
+++ trunk/libdatetime-format-w3cdtf-perl/debian/source/local-options Sat Mar 5 14:46:39 2011
@@ -1,0 +1,2 @@
+abort-on-upstream-changes
+unapply-patches
Modified: trunk/libdatetime-format-w3cdtf-perl/lib/DateTime/Format/W3CDTF.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-w3cdtf-perl/lib/DateTime/Format/W3CDTF.pm?rev=70456&op=diff
==============================================================================
--- trunk/libdatetime-format-w3cdtf-perl/lib/DateTime/Format/W3CDTF.pm (original)
+++ trunk/libdatetime-format-w3cdtf-perl/lib/DateTime/Format/W3CDTF.pm Sat Mar 5 14:46:39 2011
@@ -1,12 +1,14 @@
package DateTime::Format::W3CDTF;
use strict;
+use warnings;
use vars qw ($VERSION);
-$VERSION = '0.05';
+$VERSION = '0.06';
use DateTime;
+use DateTime::TimeZone;
sub new {
my $class = shift;
@@ -14,73 +16,65 @@
return bless {}, $class;
}
-# key is string length
-my %valid_formats = (
- 19 => {
- params => [qw( year month day hour minute second)],
- regex => qr/^(\d{4})-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)$/,
- zero => {},
- },
- 16 => {
- params => [qw( year month day hour minute)],
- regex => qr/^(\d{4})-(\d\d)-(\d\d)T(\d\d):(\d\d)$/,
- zero => { second => 0 },
- },
- 10 => {
- params => [qw( year month day )],
- regex => qr/^(\d{4})-(\d\d)-(\d\d)$/,
- zero => { hour => 0, minute => 0, second => 0 },
- },
- 7 => {
- params => [qw( year month )],
- regex => qr/^(\d{4})-(\d\d)$/,
- zero => { day => 1, hour => 0, minute => 0, second => 0 },
- },
- 4 => {
- params => [qw( year )],
- regex => qr/^(\d\d\d\d)$/,
- zero => { month => 1, day => 1, hour => 0, minute => 0, second => 0 }
- }
-);
-
sub parse_datetime {
my ( $self, $date ) = @_;
- # save for error messages
- my $original = $date;
-
+ my @fields = qw/ year month day hour minute second fraction time_zone /;
+ my @values =
+ ( $date =~ /^(\d\d\d\d) # Year
+ (?:-(\d\d) # -Month
+ (?:-(\d\d) # -Day
+ (?:T
+ (\d\d):(\d\d) # Hour:Minute
+ (?:
+ :(\d\d) # :Second
+ (\.\d+)? # .Fractional_Second
+ )?
+ ( Z # UTC
+ | [+-]\d\d:\d\d # Hour:Minute TZ offset
+ (?::\d\d)? # :Second TZ offset
+ )?)?)?)?$/x )
+ or die "Invalid W3CDTF datetime string ($date)";
my %p;
- if ( $date =~ s/([+-]\d\d:\d\d)$// ) {
- $p{time_zone} = $1;
- }
-
- # Z at end means UTC
- elsif ( $date =~ s/Z$// ) {
+ for ( my $i=0; $i < @values; $i++ ) { # Oh how I wish Perl had zip
+ next unless defined $values[$i];
+ $p{$fields[$i]} = $values[$i];
+ }
+
+### support for YYYY-MM-DDT24:00:00 as a syntactic form for 00:00:00 on the day following YYYY-MM-DD
+### this is allowed in xsd dateTime syntactic forms, but not W3CDTF.
+# my $next_day = 0;
+# if (defined($p{hour}) and defined($p{minute}) and defined($p{second})) {
+# if ($p{hour} eq '24') {
+# if ($p{second} eq '00' and $p{minute} eq '00') {
+# $p{hour} = '00';
+# $next_day++;
+# } else {
+# die "Cannot use hour value '24' with non-zero minutes and seconds\n";
+# }
+# }
+# }
+
+ if ( !$p{time_zone} ) {
+ $p{time_zone} = 'floating';
+ } elsif ( $p{time_zone} eq 'Z' ) {
$p{time_zone} = 'UTC';
}
- else {
- $p{time_zone} = 'floating';
- }
-
- my $format = $valid_formats{ length $date }
- or die "Invalid W3CDTF datetime string ($original)";
-
- @p{ @{ $format->{params} } } = $date =~ /$format->{regex}/;
-
- return DateTime->new( %p, %{ $format->{zero} } );
+
+ if ( $p{fraction} ) {
+ $p{nanosecond} = $p{fraction} * 1_000_000_000;
+ delete $p{fraction}
+ }
+
+ my $dt = DateTime->new( %p );
+# if ($next_day) {
+# $dt->add( day => 1 );
+# }
+ return $dt;
}
sub format_datetime {
my ( $self, $dt ) = @_;
-
- # removed in 0.4 as it behaved improperly at midnight - kellan 2003/11/23
- #my $base =
- # ( $dt->hour || $dt->min || $dt->sec ?
- # sprintf( '%04d-%02d-%02dT%02d:%02d:%02d',
- # $dt->year, $dt->month, $dt->day,
- # $dt->hour, $dt->minute, $dt->second ) :
- # sprintf( '%04d-%02d-%02d', $dt->year, $dt->month, $dt->day )
- # );
my $base = sprintf(
'%04d-%02d-%02dT%02d:%02d:%02d',
@@ -88,6 +82,12 @@
$dt->hour, $dt->minute, $dt->second
);
+ if ( $dt->nanosecond ) {
+ my $secs = sprintf "%f", $dt->nanosecond / 1_000_000_000;
+ $secs =~ s/^0//;
+ $base .= $secs;
+ }
+
my $tz = $dt->time_zone;
return $base if $tz->is_floating;
@@ -98,7 +98,7 @@
return $base unless defined $offset;
- return $base . offset_as_string($offset)
+ return $base . _offset_as_string($offset)
}
sub format_date {
@@ -110,7 +110,7 @@
# minor offset_as_string variant w/ :
#
-sub offset_as_string {
+sub _offset_as_string {
my $offset = shift;
return undef unless defined $offset;
@@ -164,6 +164,10 @@
=over 4
+=item * new()
+
+Returns a new W3CDTF parser object.
+
=item * parse_datetime($string)
Given a W3CDTF datetime string, this method will return a new
@@ -201,8 +205,8 @@
=head1 CREDITS
-This module was originally created by Kellan Elliott-McCrea
-E<lt>kellan at protest.netE<gt>.
+This module is maintained by Gregory Todd Williams E<lt>gwilliams at cpan.orgE<gt>.
+It was originally created by Kellan Elliott-McCrea E<lt>kellan at protest.netE<gt>.
This module was inspired by L<DateTime::Format::ICal>
Modified: trunk/libdatetime-format-w3cdtf-perl/t/01parse.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-w3cdtf-perl/t/01parse.t?rev=70456&op=diff
==============================================================================
--- trunk/libdatetime-format-w3cdtf-perl/t/01parse.t (original)
+++ trunk/libdatetime-format-w3cdtf-perl/t/01parse.t Sat Mar 5 14:46:39 2011
@@ -1,5 +1,5 @@
#!/usr/bin/perl -w
-use Test::More tests => 17;
+use Test::More tests => 18;
use strict;
use vars qw( $class );
@@ -17,6 +17,7 @@
'2005-03-10T20:14:34+09:30' => '2005-03-10T10:44:34',
'2000-06-12T14:12:33Z' => '2000-06-12T14:12:33',
'1994-11-05T08:15:30-05:00' => '1994-11-05T13:15:30',
+ '2004-07-01T15:00:13.17-05:00' => '2004-07-01T20:00:13',
);
while (@tests) {
More information about the Pkg-perl-cvs-commits
mailing list