DateTime-Format-RFC3339-v1.0.5/0000700"f13457160000000000011544257633015246 5ustar ikegamipg1404028DateTime-Format-RFC3339-v1.0.5/lib/0000700"f13457160000000000011544257633016014 5ustar ikegamipg1404028DateTime-Format-RFC3339-v1.0.5/lib/DateTime/0000700"f13457160000000000011544257633017510 5ustar ikegamipg1404028DateTime-Format-RFC3339-v1.0.5/lib/DateTime/Format/0000700"f13457160000000000011544257633020740 5ustar ikegamipg1404028DateTime-Format-RFC3339-v1.0.5/lib/DateTime/Format/RFC3339.pm0000644"f13457160000001104011544257542022237 0ustar ikegamipg1404028 package DateTime::Format::RFC3339; use strict; use warnings; use version; our $VERSION = qv('v1.0.5'); use Carp qw( croak ); use DateTime qw( ); use constant FIRST_IDX => 0; use constant IDX_UC_ONLY => FIRST_IDX + 0; use constant NEXT_IDX => FIRST_IDX + 1; sub new { my ($class, %opts) = @_; my $uc_only = delete( $opts{uc_only} ); return bless([ $uc_only, # IDX_UC_ONLY ], $class); } sub parse_datetime { my ($self, $str) = @_; $self = $self->new() if !ref($self); $str = uc($str) if !$self->[IDX_UC_ONLY]; my ($Y,$M,$D) = $str =~ s/^(\d{4})-(\d{2})-(\d{2})// && (0+$1,0+$2,0+$3) or croak("Incorrectly formatted date"); $str =~ s/^T// or croak("Incorrectly formatted datetime"); my ($h,$m,$s) = $str =~ s/^(\d{2}):(\d{2}):(\d{2})// && (0+$1,0+$2,0+$3) or croak("Incorrectly formatted time"); my $ns = $str =~ s/^\.(\d{1,9})\d*// ? 0+substr($1.('0'x8),0,9) : 0; my $tz; if ( $str =~ s/^Z// ) { $tz = 'UTC'; } elsif ( $str =~ s/^([+-])(\d{2}):(\d{2})// ) { $tz = "$1$2$3"; } else { croak("Missing time zone"); } $str =~ /^\z/ or croak("Incorrectly formatted datetime"); return DateTime->new( year => $Y, month => $M, day => $D, hour => $h, minute => $m, second => $s, nanosecond => $ns, time_zone => $tz, formatter => $self, ); } sub format_datetime { my ($self, $dt) = @_; my $tz; if ($dt->time_zone()->is_utc()) { $tz = 'Z'; } else { my $secs = $dt->offset(); my $sign = $secs < 0 ? '-' : '+'; $secs = abs($secs); my $mins = int($secs / 60); $secs %= 60; my $hours = int($mins / 60); $mins %= 60; if ($secs) { ( $dt = $dt->clone() ) ->set_time_zone('UTC'); $tz = 'Z'; } else { $tz = sprintf('%s%02d:%02d', $sign, $hours, $mins); } } return $dt->strftime( ($dt->nanosecond() ? '%Y-%m-%dT%H:%M:%S.%9N' : '%Y-%m-%dT%H:%M:%S' ) ).$tz; } 1; __END__ =head1 NAME DateTime::Format::RFC3339 - Parse and format RFC3339 datetime strings =head1 VERSION Version 1.0.5 =head1 SYNOPSIS use DateTime::Format::RFC3339; my $f = DateTime::Format::RFC3339->new(); my $dt = $f->parse_datetime( '2002-07-01T13:50:05Z' ); # 2002-07-01T13:50:05Z print $f->format_datetime($dt); =head1 DESCRIPTION This module understands the RFC3339 date/time format, an ISO 8601 profile, defined at L. It can be used to parse these formats in order to create the appropriate objects. =head1 METHODS =over =item C Given a RFC3339 datetime string, this method will return a new L object. If given an improperly formatted string, this method will croak. For a more flexible parser, see L. =item C Given a L object, this methods returns a RFC3339 datetime string. =back =head1 SEE ALSO =over 4 =item * L =item * L =item * L, "Date and Time on the Internet: Timestamps" =back =head1 BUGS Please report any bugs or feature requests to C, or through the web interface at L. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. =head1 SUPPORT You can find documentation for this module with the perldoc command. perldoc DateTime::Format::RFC3339 You can also look for information at: =over 4 =item * Search CPAN L =item * RT: CPAN's request tracker L =item * AnnoCPAN: Annotated CPAN documentation L =item * CPAN Ratings L =back =head1 AUTHOR Eric Brine, C<< >> =head1 COPYRIGHT & LICENSE No rights reserved. The author has dedicated the work to the Commons by waiving all of his or her rights to the work worldwide under copyright law and all related or neighboring legal rights he or she had in the work, to the extent allowable by law. Works under CC0 do not require attribution. When citing the work, you should not imply endorsement by the author. =cut DateTime-Format-RFC3339-v1.0.5/Makefile.PL0000644"f13457160000000114111544257545017231 0ustar ikegamipg1404028use strict; use warnings; use ExtUtils::MakeMaker qw( WriteMakefile ); WriteMakefile( NAME => 'DateTime::Format::RFC3339', AUTHOR => 'Eric Brine ', VERSION_FROM => 'lib/DateTime/Format/RFC3339.pm', ABSTRACT_FROM => 'lib/DateTime/Format/RFC3339.pm', LICENSE => 'CC0_1_0', PREREQ_PM => { 'DateTime' => 0, 'Test::More' => 0, 'version' => 0, }, dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz' }, clean => { FILES => 'DateTime-Format-RFC3339-*' }, ); DateTime-Format-RFC3339-v1.0.5/t/0000700"f13457160000000000011544257633015511 5ustar ikegamipg1404028DateTime-Format-RFC3339-v1.0.5/t/01_parsing.t0000644"f13457160000000175111544257541017655 0ustar ikegamipg1404028#!perl -T use strict; use warnings; use DateTime qw( ); use DateTime::Format::RFC3339 qw( ); my @pos_tests; my @neg_tests; BEGIN { @pos_tests = ( [ '2002-07-01T13:50:05Z', DateTime->new( year => 2002, month => 7, day => 1, hour => 13, minute => 50, second => 5, time_zone => 'UTC' ), ], [ '2002-07-01T13:50:05.123Z', DateTime->new( year => 2002, month => 7, day => 1, hour => 13, minute => 50, second => 5, nanosecond => 123000000, time_zone => 'UTC' ), ], ); @neg_tests = ( ); } use Test::More tests => @pos_tests + @neg_tests; for (@pos_tests) { my ($str, $expected_dt) = @$_; my $actual_dt = eval { DateTime::Format::RFC3339->parse_datetime($str) }; ok( defined($actual_dt) && $actual_dt eq $expected_dt, $str ); } for (@neg_tests) { my ($str, $expected_e) = @$_; eval { DateTime::Format::RFC3339->parse_datetime($str) }; my $actual_e = $@; like( $actual_e, $expected_e, $str ); } DateTime-Format-RFC3339-v1.0.5/t/02_formatting.t0000644"f13457160000000252411544257543020366 0ustar ikegamipg1404028#!perl -T use strict; use warnings; use DateTime qw( ); use DateTime::Format::RFC3339 qw( ); my @tests; BEGIN { @tests = ( [ # UTC DateTime->new( year => 2002, month => 7, day => 1, hour => 13, minute => 50, second => 5, time_zone => 'UTC' ), '2002-07-01T13:50:05Z', ], [ # Positive offset DateTime->new( year => 2002, month => 7, day => 1, hour => 13, minute => 50, second => 5, time_zone => 'Europe/London' ), '2002-07-01T13:50:05+01:00', ], [ # Zero offset DateTime->new( year => 2002, month => 1, day => 1, hour => 13, minute => 50, second => 5, time_zone => 'Europe/London' ), '2002-01-01T13:50:05+00:00', ], [ # Negative offset. DateTime->new( year => 2002, month => 1, day => 1, hour => 13, minute => 50, second => 5, time_zone => 'America/New_York' ), '2002-01-01T13:50:05-05:00', ], [ # Offset with non-integral minutes. DateTime->new( year => 1880, month => 1, day => 1, hour => 0, minute => 0, second => 0, time_zone => 'America/New_York' ), '1880-01-01T04:56:02Z', ], ); } use Test::More tests => 0+@tests; for (@tests) { my ($dt, $expected_str) = @$_; $dt->set_formatter('DateTime::Format::RFC3339'); my $actual_str = "$dt"; is( $actual_str, $expected_str ); } DateTime-Format-RFC3339-v1.0.5/t/00_load.t0000644"f13457160000000032211544257536017125 0ustar ikegamipg1404028#!perl -T use strict; use warnings; use Test::More tests => 1; BEGIN { require_ok( 'DateTime::Format::RFC3339' ); } diag( "Testing DateTime::Format::RFC3339 $DateTime::Format::RFC3339::VERSION, Perl $]" ); DateTime-Format-RFC3339-v1.0.5/Changes.txt0000644"f13457160000000072711544257544017400 0ustar ikegamipg1404028Revision history for DateTime-Format-RFC3339 1.0.5 2011/03/28 Specified license more explicitly. 1.0.4 2010-10-10 Switch to UTC rather than rounding when dealing with timezone offsets of non-integral minutes. 1.0.3 2010-10-07 Leave timezone unchanged when formatting. 1.0.2 2009-10-13 Fixed handling of fractional seconds. 1.0.1 2009-01-07 Documentation formatting fixes. 1.0.0 2009-01-05 Initial version DateTime-Format-RFC3339-v1.0.5/LICENSE.txt0000644"f13457160000001564311544257550017112 0ustar ikegamipg1404028Creative Commons Legal Code CC0 1.0 Universal CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED HEREUNDER. Statement of Purpose The laws of most jurisdictions throughout the world automatically confer exclusive Copyright and Related Rights (defined below) upon the creator and subsequent owner(s) (each and all, an "owner") of an original work of authorship and/or a database (each, a "Work"). Certain owners wish to permanently relinquish those rights to a Work for the purpose of contributing to a commons of creative, cultural and scientific works ("Commons") that the public can reliably and without fear of later claims of infringement build upon, modify, incorporate in other works, reuse and redistribute as freely as possible in any form whatsoever and for any purposes, including without limitation commercial purposes. These owners may contribute to the Commons to promote the ideal of a free culture and the further production of creative, cultural and scientific works, or to gain reputation or greater distribution for their Work in part through the use and efforts of others. For these and/or other purposes and motivations, and without any expectation of additional consideration or compensation, the person associating CC0 with a Work (the "Affirmer"), to the extent that he or she is an owner of Copyright and Related Rights in the Work, voluntarily elects to apply CC0 to the Work and publicly distribute the Work under its terms, with knowledge of his or her Copyright and Related Rights in the Work and the meaning and intended legal effect of CC0 on those rights. 1. Copyright and Related Rights. A Work made available under CC0 may be protected by copyright and related or neighboring rights ("Copyright and Related Rights"). Copyright and Related Rights include, but are not limited to, the following: i. the right to reproduce, adapt, distribute, perform, display, communicate, and translate a Work; ii. moral rights retained by the original author(s) and/or performer(s); iii. publicity and privacy rights pertaining to a person's image or likeness depicted in a Work; iv. rights protecting against unfair competition in regards to a Work, subject to the limitations in paragraph 4(a), below; v. rights protecting the extraction, dissemination, use and reuse of data in a Work; vi. database rights (such as those arising under Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, and under any national implementation thereof, including any amended or successor version of such directive); vii. and other similar, equivalent or corresponding rights throughout the world based on applicable law or treaty, and any national implementations thereof. 2. Waiver. To the greatest extent permitted by, but not in contravention of, applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and unconditionally waives, abandons, and surrenders all of Affirmer's Copyright and Related Rights and associated claims and causes of action, whether now known or unknown (including existing as well as future claims and causes of action), in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each member of the public at large and to the detriment of Affirmer's heirs and successors, fully intending that such Waiver shall not be subject to revocation, rescission, cancellation, termination, or any other legal or equitable action to disrupt the quiet enjoyment of the Work by the public as contemplated by Affirmer's express Statement of Purpose. 3. Public License Fallback. Should any part of the Waiver for any reason be judged legally invalid or ineffective under applicable law, then the Waiver shall be preserved to the maximum extent permitted taking into account Affirmer's express Statement of Purpose. In addition, to the extent the Waiver is so judged Affirmer hereby grants to each affected person a royalty-free, non transferable, non sublicensable, non exclusive, irrevocable and unconditional license to exercise Affirmer's Copyright and Related Rights in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "License"). The License shall be deemed effective as of the date CC0 was applied by Affirmer to the Work. Should any part of the License for any reason be judged legally invalid or ineffective under applicable law, such partial invalidity or ineffectiveness shall not invalidate the remainder of the License, and in such case Affirmer hereby affirms that he or she will not (i) exercise any of his or her remaining Copyright and Related Rights in the Work or (ii) assert any associated claims and causes of action with respect to the Work, in either case contrary to Affirmer's express Statement of Purpose. 4. Limitations and Disclaimers. a. No trademark or patent rights held by Affirmer are waived, abandoned, surrendered, licensed or otherwise affected by this document. b. Affirmer offers the Work as-is and makes no representations or warranties of any kind concerning the Work, express, implied, statutory or otherwise, including without limitation warranties of title, merchantability, fitness for a particular purpose, non infringement, or the absence of latent or other defects, accuracy, or the present or absence of errors, whether or not discoverable, all to the greatest extent permissible under applicable law. c. Affirmer disclaims responsibility for clearing rights of other persons that may apply to the Work or any use thereof, including without limitation any person's Copyright and Related Rights in the Work. Further, Affirmer disclaims responsibility for obtaining any necessary consents, permissions or other rights required for any use of the Work. d. Affirmer understands and acknowledges that Creative Commons is not a party to this document and has no duty or obligation with respect to this CC0 or use of the Work. DateTime-Format-RFC3339-v1.0.5/README.txt0000644"f13457160000000240711544257546016764 0ustar ikegamipg1404028DateTime-Format-RFC3339 DateTime::Format::RFC3339 parses and formats RFC3339 datetime strings. INSTALLATION To install this module, run the following commands: perl Makefile.PL make make test make install DEPENDENCIES This module requires these other modules and libraries: DateTime Test::More version SUPPORT AND DOCUMENTATION After installing, you can find documentation for this module with the perldoc command. perldoc DateTime::Format::RFC3339 You can also look for information at: RT, CPAN's request tracker http://rt.cpan.org/NoAuth/Bugs.html?Dist=DateTime-Format-RFC3339 AnnoCPAN, Annotated CPAN documentation http://annocpan.org/dist/DateTime-Format-RFC3339 CPAN Ratings http://cpanratings.perl.org/d/DateTime-Format-RFC3339 Search CPAN http://search.cpan.org/dist/DateTime-Format-RFC3339 COPYRIGHT AND LICENCE No rights reserved. The author has dedicated the work to the Commons by waiving all of his or her rights to the work worldwide under copyright law and all related or neighboring legal rights he or she had in the work, to the extent allowable by law. Works under CC0 do not require attribution. When citing the work, you should not imply endorsement by the author. DateTime-Format-RFC3339-v1.0.5/META.yml0000600"f13457160000000114311544257633016520 0ustar ikegamipg1404028--- #YAML:1.0 name: DateTime-Format-RFC3339 version: v1.0.5 abstract: Parse and format RFC3339 datetime strings author: - Eric Brine license: CC0_1_0 distribution_type: module configure_requires: ExtUtils::MakeMaker: 0 build_requires: ExtUtils::MakeMaker: 0 requires: DateTime: 0 Test::More: 0 version: 0 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 DateTime-Format-RFC3339-v1.0.5/MANIFEST0000644"f13457160000000032311544257633016407 0ustar ikegamipg1404028Changes.txt LICENSE.txt MANIFEST Makefile.PL README.txt lib/DateTime/Format/RFC3339.pm t/00_load.t t/01_parsing.t t/02_formatting.t META.yml Module meta-data (added by MakeMaker)