DateTime-Format-RFC3339-v1.2.0/0000700000175100010010000000000012606046216014622 5ustar ikegamiNoneDateTime-Format-RFC3339-v1.2.0/.gitignore0000644000175100010010000000024312606044555016627 0ustar ikegamiNoneMakefile Makefile.old pm_to_blib blib/ DateTime-Format-RFC3339-* DateTime-Format-RFC3339-*/ .releaserc cover_db MYMETA.* META.* pod2htmd.tmp pod2htmi.tmp *~ *.bak DateTime-Format-RFC3339-v1.2.0/Changes0000644000175100010010000000120712606045764016136 0ustar ikegamiNoneRevision history for DateTime-Format-RFC3339 1.2.0 2015/10/09 No functional changes. Updated to adopt the conventions used by my other modules. A few tests were added, and a repository information was added. 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.2.0/lib/0000700000175100010010000000000012606046154015371 5ustar ikegamiNoneDateTime-Format-RFC3339-v1.2.0/lib/DateTime/0000700000175100010010000000000012606046154017065 5ustar ikegamiNoneDateTime-Format-RFC3339-v1.2.0/lib/DateTime/Format/0000700000175100010010000000000012606046154020315 5ustar ikegamiNoneDateTime-Format-RFC3339-v1.2.0/lib/DateTime/Format/RFC3339.pm0000644000175100010010000001103412606046001021607 0ustar ikegamiNone package DateTime::Format::RFC3339; use strict; use warnings; use version; our $VERSION = qv('v1.2.0'); 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.2.0 =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.2.0/LICENSE.txt0000644000175100010010000001564312606045177016475 0ustar ikegamiNoneCreative 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.2.0/Makefile.PL0000755000175100010010000000372112606045177016621 0ustar ikegamiNone#!/usr/bin/env perl use 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', dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz' }, clean => { FILES => 'DateTime-Format-Atom-*' }, BUILD_REQUIRES => {}, META_MERGE => { 'meta-spec' => { version => 2 }, license => [ 'unrestricted' ], prereqs => { configure => { requires => { 'ExtUtils::MakeMaker' => 6.52, }, }, runtime => { requires => { 'strict' => 0, 'version' => 0, 'warnings' => 0, 'DateTime' => 0, }, }, test => { requires => { 'Test::More' => 0, }, recommends => { 'Test::Pod' => 1.22, }, }, develop => { requires => { 'FindBin' => 0, 'Pod::Coverage' => 0.18, 'Test::Pod::Coverage' => 1.08, }, }, }, resources => { homepage => 'http://search.cpan.org/dist/DateTime-Format-RFC3339/', license => [ 'http://creativecommons.org/publicdomain/zero/1.0/' ], bugtracker => { web => 'http://rt.cpan.org/NoAuth/ReportBug.html?Queue=DateTime-Format-RFC3339', mailto => 'bug-DateTime-Format-RFC3339@rt.cpan.org', }, repository => { type => 'git', url => 'https://github.com/ikegami/perl-DateTime-Format-RFC3339.git', web => 'https://github.com/ikegami/perl-DateTime-Format-RFC3339', }, }, }, ); DateTime-Format-RFC3339-v1.2.0/MANIFEST0000644000175100010010000000072612606046220015765 0ustar ikegamiNone.gitignore Makefile.PL Changes lib/DateTime/Format/RFC3339.pm LICENSE.txt Makefile.PL MANIFEST MANIFEST.SKIP README.txt t/00_load.t t/01_devel_mark_check.t t/02_devel_version_check.t t/03_devel_whitespace.t t/04_devel_permissions.t t/05_pod.t t/06_devel_pod_coverage.t t/07_parsing.t t/08_formatting.t META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) DateTime-Format-RFC3339-v1.2.0/MANIFEST.SKIP0000644000175100010010000000022112606045177016532 0ustar ikegamiNone^.git/ ^.gitignore$ ^Makefile.old$ ^pm_to_blib$ ^blib/ ^DateTime-Format-RFC3339- .releaserc cover_db MYMETA.* pod2htmd.tmp pod2htmi.tmp ~$ .bak$ DateTime-Format-RFC3339-v1.2.0/META.json0000600000175100010010000000351512606046216016251 0ustar ikegamiNone{ "abstract" : "Parse and format RFC3339 datetime strings", "author" : [ "Eric Brine " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 6.72, CPAN::Meta::Converter version 2.120351", "license" : [ "unrestricted" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "DateTime-Format-RFC3339", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : {} }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "6.52" } }, "develop" : { "requires" : { "FindBin" : "0", "Pod::Coverage" : "0.18", "Test::Pod::Coverage" : "1.08" } }, "runtime" : { "requires" : { "DateTime" : "0", "strict" : "0", "version" : "0", "warnings" : "0" } }, "test" : { "recommends" : { "Test::Pod" : "1.22" }, "requires" : { "Test::More" : "0" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "mailto" : "bug-DateTime-Format-RFC3339@rt.cpan.org", "web" : "http://rt.cpan.org/NoAuth/ReportBug.html?Queue=DateTime-Format-RFC3339" }, "homepage" : "http://search.cpan.org/dist/DateTime-Format-RFC3339/", "license" : [ "http://creativecommons.org/publicdomain/zero/1.0/" ], "repository" : { "type" : "git", "url" : "https://github.com/ikegami/perl-DateTime-Format-RFC3339.git", "web" : "https://github.com/ikegami/perl-DateTime-Format-RFC3339" } }, "version" : "v1.2.0" } DateTime-Format-RFC3339-v1.2.0/META.yml0000600000175100010010000000152112606046166016100 0ustar ikegamiNone--- abstract: 'Parse and format RFC3339 datetime strings' author: - 'Eric Brine ' build_requires: Test::More: 0 configure_requires: ExtUtils::MakeMaker: 6.52 dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 6.72, CPAN::Meta::Converter version 2.120351' license: unrestricted meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: DateTime-Format-RFC3339 no_index: directory: - t - inc requires: DateTime: 0 strict: 0 version: 0 warnings: 0 resources: bugtracker: http://rt.cpan.org/NoAuth/ReportBug.html?Queue=DateTime-Format-RFC3339 homepage: http://search.cpan.org/dist/DateTime-Format-RFC3339/ license: http://creativecommons.org/publicdomain/zero/1.0/ repository: https://github.com/ikegami/perl-DateTime-Format-RFC3339.git version: v1.2.0 DateTime-Format-RFC3339-v1.2.0/README.txt0000644000175100010010000000243412606045360016334 0ustar ikegamiNoneDateTime-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 strict version warnings 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.2.0/t/0000700000175100010010000000000012606046154015066 5ustar ikegamiNoneDateTime-Format-RFC3339-v1.2.0/t/00_load.t0000755000175100010010000000055112606045204016502 0ustar ikegamiNone#!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" ); diag( "Using Perl $]" ); for (sort grep /\.pm\z/, keys %INC) { s{\.pm\z}{}; s{/}{::}g; eval { diag(join(' ', $_, $_->VERSION || '')) }; } DateTime-Format-RFC3339-v1.2.0/t/01_devel_mark_check.t0000755000175100010010000000134112606045204021030 0ustar ikegamiNone#!perl use strict; use warnings; use FindBin qw( $RealBin ); use Test::More; BEGIN { $ENV{DEVEL_TESTS} or plan skip_all => "Mark checks are only performed when DEVEL_TESTS=1"; } sub slurp_file { my ($qfn) = @_; open(my $fh, '<', $qfn) or die("Can't open \"$qfn\": $!\n"); local $/; return <$fh>; } sub read_manifest { open(my $fh, '<', 'MANIFEST') or die("Can't open \"MANIFEST\": $!\n"); my @manifest = <$fh>; chomp @manifest; return @manifest; } { chdir("$RealBin/..") or die $!; my @qfns = read_manifest(); plan tests => 0+@qfns; for my $qfn (@qfns) { my $file = slurp_file($qfn); ok( $file !~ /~{3}|&{3}/, "$qfn - Has no developer bookmarks" ); } } DateTime-Format-RFC3339-v1.2.0/t/02_devel_version_check.t0000755000175100010010000000210112606045204021557 0ustar ikegamiNone#!perl use strict; use warnings; use FindBin qw( $RealBin ); use Test::More; BEGIN { if ($ENV{DEVEL_TESTS}) { plan tests => 3; } else { plan skip_all => "Version checks are only performed when DEVEL_TESTS=1"; } } sub slurp_file { my ($qfn) = @_; open(my $fh, '<', $qfn) or die("Can't open \"$qfn\": $!\n"); local $/; return <$fh>; } { chdir("$RealBin/..") or die $!; my $base_file = slurp_file('lib/DateTime/Format/RFC3339.pm'); my $changes_file = slurp_file('Changes'); my ($version) = $base_file =~ /\bqv\('v([^']*)'\)/ or die("Can't find version\n"); my @parts = split(/\./, $version); my ($pod_version) = $base_file =~ /^Version (\S+)/m or die("Can't find version in POD\n"); my ($changes_version) = $changes_file =~ /^([0-9]\S*)/m or die("Can't find version in POD\n"); is($pod_version, $version, "Version in POD matches actual version"); ok($parts[1] % 2 == 0, "Version is a release version"); is($changes_version, $version, "Version in Changes file matches actual version"); } DateTime-Format-RFC3339-v1.2.0/t/03_devel_whitespace.t0000755000175100010010000000175312606045204021106 0ustar ikegamiNone#!perl use strict; use warnings; use FindBin qw( $RealBin ); use Test::More; BEGIN { $ENV{DEVEL_TESTS} or plan skip_all => "Whitespace checks are only performed when DEVEL_TESTS=1"; } sub slurp_file { my ($qfn) = @_; open(my $fh, '<', $qfn) or die("Can't open \"$qfn\": $!\n"); local $/; return <$fh>; } sub read_manifest { open(my $fh, '<', 'MANIFEST') or die("Can't open \"MANIFEST\": $!\n"); my @manifest = <$fh>; chomp @manifest; return @manifest; } { chdir("$RealBin/..") or die $!; my @qfns = read_manifest(); plan tests => 2*@qfns; for my $qfn (@qfns) { my $file = slurp_file($qfn); my $rev_file = reverse($file); if ($^O eq 'MSWin32') { ok( $file !~ /\r(?!\n)/ && $rev_file !~ /\n(?!\r)/, "$qfn - Windows line endings" ); } else { ok( $file !~ /\r/, "$qfn - Unix line endings" ); } ok( $rev_file !~ /\n(?:\r[^\S\n]|[^\S\r\n])/, "$qfn - No trailing whitespace" ); } } DateTime-Format-RFC3339-v1.2.0/t/04_devel_permissions.t0000755000175100010010000000203312606045204021316 0ustar ikegamiNone#!perl use strict; use warnings; use FindBin qw( $RealBin ); use Test::More; BEGIN { $ENV{DEVEL_TESTS} or plan skip_all => "Permission checks are only performed when DEVEL_TESTS=1"; $^O ne 'Win32' or plan skip_all => "Permission checks can't be performed on Win32"; } sub read_manifest { open(my $fh, '<', 'MANIFEST') or die("Can't open \"MANIFEST\": $!\n"); my @manifest = <$fh>; chomp @manifest; return @manifest; } { chdir("$RealBin/..") or die $!; my @qfns = read_manifest(); plan tests => 3*@qfns; for my $qfn (@qfns) { my @stat = stat($qfn) or die("Can't stat \"$qfn\": $!\n"); my $mode = $stat[2]; is(sprintf("%04o", $mode & 0400), '0400', "$qfn is readable"); is(sprintf("%04o", $mode & 0002), '0000', "$qfn isn't world writable"); if ($qfn =~ /\.(t|pl|PL)\z/) { is(sprintf("%04o", $mode & 0100), '0100', "$qfn is executable"); } else { is(sprintf("%04o", $mode & 0111), '0000', "$qfn isn't executable"); } } } DateTime-Format-RFC3339-v1.2.0/t/05_pod.t0000755000175100010010000000037712606045204016360 0ustar ikegamiNone#!perl use strict; use warnings; use Test::More; BEGIN { # Ensure a recent version of Test::Pod my $min_tp = 1.22; eval("use Test::Pod $min_tp; 1") or plan skip_all => "Test::Pod $min_tp required for testing POD"; } all_pod_files_ok(); DateTime-Format-RFC3339-v1.2.0/t/06_devel_pod_coverage.t0000755000175100010010000000135512606045204021410 0ustar ikegamiNone#!perl use strict; use warnings; use FindBin qw( $RealBin ); use Test::More; BEGIN { $ENV{DEVEL_TESTS} or plan skip_all => "Pod coverage is only tested when DEVEL_TESTS=1"; # Ensure a recent version of Test::Pod::Coverage my $min_tpc = 1.08; eval("use Test::Pod::Coverage $min_tpc; 1") or plan skip_all => "Test::Pod::Coverage $min_tpc required for testing POD coverage"; # Test::Pod::Coverage doesn't require a minimum Pod::Coverage version, # but older versions don't recognize some common documentation styles my $min_pc = 0.18; eval("use Pod::Coverage $min_pc; 1") or plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage"; } chdir($RealBin) or die $!; all_pod_coverage_ok(); DateTime-Format-RFC3339-v1.2.0/t/07_parsing.t0000755000175100010010000000170512606045204017237 0ustar ikegamiNone#!perl use strict; use warnings; use Test::More; use DateTime qw( ); use DateTime::Format::RFC3339 qw( ); { my @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' ) ], ); my @neg_tests = ( ); plan 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.2.0/t/08_formatting.t0000755000175100010010000000252412606045204017747 0ustar ikegamiNone#!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 ); }