DateTime-Format-Strptime-1.63/0000775000175000017500000000000012645520607016043 5ustar autarchautarchDateTime-Format-Strptime-1.63/dist.ini0000644000175000017500000000115512645520607017507 0ustar autarchautarchname = DateTime-Format-Strptime author = Dave Rolsky author = Rick Measham copyright_holder = Dave Rolsky [@DROLSKY] dist = DateTime-Format-Strptime coverage_trustme = DateTime::Format::Strptime => qr/^(?:format_duration|parse_duration|local_carp|local_croak)$/ stopwords = Measham stopwords = POSIX stopwords = Rolsky stopwords = STRPTIME stopwords = errmsg stopwords = formatter stopwords = strf stopwords = strp stopwords = strptime -remove = Test::CPAN::Changes -remove = Test::Pod::No404s -remove = Test::Synopsis [Prereqs / DevelopRequires] Test::Fatal = 0 Test::More = 0.96 DateTime-Format-Strptime-1.63/perltidyrc0000644000175000017500000000045512645520607020151 0ustar autarchautarch-l=78 -i=4 -ci=4 -se -b -bar -boc -vt=0 -vtc=0 -cti=0 -pt=1 -bt=1 -sbt=1 -bbt=1 -nolq -npro -nsfs --blank-lines-before-packages=0 --opening-hash-brace-right --no-outdent-long-comments --iterations=2 -wbb="% + - * / x != == >= <= =~ !~ < > | & >= < = **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x=" DateTime-Format-Strptime-1.63/cpanfile0000644000175000017500000000274112645520607017551 0ustar autarchautarchrequires "Carp" => "0"; requires "DateTime" => "1.00"; requires "DateTime::Locale" => "0.45"; requires "DateTime::TimeZone" => "0.79"; requires "Exporter" => "0"; requires "JSON::PP" => "2.27300"; requires "Package::DeprecationManager" => "0.15"; requires "Params::Validate" => "1.20"; requires "Try::Tiny" => "0"; requires "constant" => "0"; requires "strict" => "0"; requires "warnings" => "0"; on 'test' => sub { requires "ExtUtils::MakeMaker" => "0"; requires "File::Spec" => "0"; requires "Test::Builder" => "0"; requires "Test::Fatal" => "0"; requires "Test::More" => "0.96"; requires "Test::Warnings" => "0"; requires "lib" => "0"; requires "utf8" => "0"; }; on 'test' => sub { recommends "CPAN::Meta" => "2.120900"; }; on 'configure' => sub { requires "ExtUtils::MakeMaker" => "0"; }; on 'develop' => sub { requires "Code::TidyAll" => "0.24"; requires "File::Spec" => "0"; requires "IO::Handle" => "0"; requires "IPC::Open3" => "0"; requires "Perl::Critic" => "1.123"; requires "Perl::Tidy" => "20140711"; requires "Pod::Coverage::TrustPod" => "0"; requires "Test::Code::TidyAll" => "0.24"; requires "Test::EOL" => "0"; requires "Test::Fatal" => "0"; requires "Test::Mojibake" => "0"; requires "Test::More" => "0.96"; requires "Test::NoTabs" => "0"; requires "Test::Pod" => "1.41"; requires "Test::Pod::Coverage" => "1.08"; requires "Test::Pod::LinkCheck" => "0"; requires "Test::Spelling" => "0.12"; requires "Test::Version" => "1"; }; DateTime-Format-Strptime-1.63/bench0000644000175000017500000002241512645520607017047 0ustar autarchautarchpackage main; use strict; use warnings; use utf8; use Benchmark qw( timethese ); use DateTime::Format::Strptime; use Try::Tiny; use Test::More; use Test::Fatal; timethese( 100, { test => \&test } ); sub test { for my $test ( _tests_from_data() ) { subtest( qq{$test->{name}}, sub { _utf8_output(); my $parser; is( exception { $parser = DateTime::Format::Strptime->new( pattern => $test->{pattern}, ( $test->{locale} ? ( locale => $test->{locale} ) : () ), on_error => 'croak', ); }, undef, "no exception building parser for $test->{pattern}" ) or return; # Thursday changed from "Thu" to "Thu." and December went from # "Dec" to "Dec." between CLDR versions. $test->{input} =~ s/AU_THU/DateTime::Locale->load('en-AU')->day_format_abbreviated->[3]/e; $test->{input} =~ s/AU_DEC/DateTime::Locale->load('en-AU')->month_format_abbreviated->[11]/e; ( my $real_input = $test->{input} ) =~ s/\\n/\n/g; my $dt; is( exception { $dt = $parser->parse_datetime( $real_input ) }, undef, "no exception parsing $test->{input}" ) or return; _test_dt_methods( $dt, $test->{expect} ); unless ( $test->{skip_round_trip} ) { is( $parser->format_datetime($dt), $real_input, 'round trip via strftime produces original input' ); } } ); } subtest( 'parsing whitespace', sub { my $parser = DateTime::Format::Strptime->new( pattern => '%n%Y%t%m%n', on_error => 'croak', ); my $dt = $parser->parse_datetime(<<"EOF"); \t 2015 12 EOF my %expect = ( year => 2015, month => 12, ); _test_dt_methods( $dt, \%expect ); } ); subtest( 'parser time zone is set on returned object', sub { my $parser = DateTime::Format::Strptime->new( pattern => '%Y %H:%M:%S %Z', time_zone => 'America/New_York', on_error => 'croak', ); my $dt = $parser->parse_datetime('2003 23:45:56 MDT'); my %expect = ( year => 2003, hour => 0, minute => 45, second => 56, time_zone_long_name => 'America/New_York', ); _test_dt_methods( $dt, \%expect ); } ); } my $d; sub _tests_from_data { my @tests; $d ||= do { local $/; }; my $test_re = qr/ \[(.+?)\]\n # test name (.+?)\n # pattern (.+?)\n # input (?:locale\ =\ (.+?)\n)? # optional locale (skip\ round\ trip\n)? # skip a round trip? (.+?)\n # k-v pairs for expected values (?:\n|\z) # end of test /xs; while ( $d =~ /$test_re/g ) { push @tests, { name => $1, pattern => $2, input => $3, locale => $4, skip_round_trip => $5, expect => { map { split /\s+=>\s+/ } split /\n/, $6, }, }; } return @tests; } sub _utf8_output { binmode $_, ':encoding(UTF-8)' for map { Test::Builder->new->$_ } qw( output failure_output todo_output ); } sub _test_dt_methods { my $dt = shift; my $expect = shift; for my $meth ( sort keys %{$expect} ) { is( $dt->$meth, $expect->{$meth}, "$meth is $expect->{$meth}" ); } } __DATA__ [ISO8601] %Y-%m-%dT%H:%M:%S 2015-10-08T15:39:44 year => 2015 month => 10 day => 8 hour => 15 minute => 39 second => 44 [date with 4-digit year] %Y-%m-%d 1998-12-31 year => 1998 month => 12 day => 31 [date with 2-digit year] %y-%m-%d 98-12-31 year => 1998 month => 12 day => 31 [date with leading space on month] %e-%b-%Y 3-Jun-2010 year => 2010 month => 6 day => 3 [year and day of year] %Y years %j days 1998 years 312 days year => 1998 month => 11 day => 8 [date with abbreviated month] %b %d %Y Jan 24 2003 year => 2003 month => 1 day => 24 [date with abbreviated month is case-insensitive] %b %d %Y jAN 24 2003 skip round trip year => 2003 month => 1 day => 24 [date with full month] %B %d %Y January 24 2003 year => 2003 month => 1 day => 24 [date with full month is case-insensitive] %B %d %Y jAnUAry 24 2003 skip round trip year => 2003 month => 1 day => 24 [24 hour time] %H:%M:%S 23:45:56 year => 1 month => 1 day => 1 hour => 23 minute => 45 second => 56 [12 hour time (PM)] %l:%M:%S %p 11:45:56 PM year => 1 month => 1 day => 1 hour => 23 minute => 45 second => 56 [12 hour time (am) and am/pm is case-insensitive] %l:%M:%S %p 11:45:56 am skip round trip year => 1 month => 1 day => 1 hour => 11 minute => 45 second => 56 [24-hour time] %T 23:34:45 hour => 23 minute => 34 second => 45 [12-hour time] %r 11:34:45 PM hour => 23 minute => 34 second => 45 [24-hour time without second] %R 23:34 hour => 23 minute => 34 second => 0 [US style date] %D 11/30/03 year => 2003 month => 11 day => 30 [ISO style date] %F 2003-11-30 year => 2003 month => 11 day => 30 [nanosecond with no length] %H:%M:%S.%N 23:45:56.123456789 hour => 23 minute => 45 second => 56 nanosecond => 123456789 [nanosecond with length of 6] %H:%M:%S.%6N 23:45:56.123456 hour => 23 minute => 45 second => 56 nanosecond => 123456000 [nanosecond with length of 3] %H:%M:%S.%3N 23:45:56.123 hour => 23 minute => 45 second => 56 nanosecond => 123000000 [nanosecond with no length but < 9 digits] %H:%M:%S.%N 23:45:56.543 skip round trip hour => 23 minute => 45 second => 56 nanosecond => 543000000 [time zone as numeric offset] %H:%M:%S %z 23:45:56 +1000 hour => 23 minute => 45 second => 56 offset => 36000 [time zone as abbreviation] %H:%M:%S %Z 23:45:56 AEST skip round trip hour => 23 minute => 45 second => 56 offset => 36000 [time zone as Olson name] %H:%M:%S %O 23:45:56 America/Chicago hour => 23 minute => 45 second => 56 time_zone_long_name => America/Chicago [escaped percent] %Y%%%m%%%d 2015%05%14 year => 2015 month => 5 day => 14 [escaped percent followed by letter token] %Y%%%m%%%d%%H 2015%05%14%H year => 2015 month => 5 day => 14 [every pattern] %a %b %B %C %d %e %h %H %I %j %k %l %m %M %n %N %O %p %P %S %U %u %w %W %y %Y %s %G %g %z %Z %%Y %% Wed Nov November 20 05 5 Nov 21 09 309 21 9 11 34 \n 123456789 America/Denver PM pm 45 44 3 3 44 03 2003 1068093285 2003 03 -0700 MST %Y % year => 2003 month => 11 day => 5 hour => 21 minute => 34 second => 45 nanosecond => 123456789 time_zone_long_name => America/Denver [Australian date] %x 31/12/98 locale = en-AU skip round trip year => 1998 month => 12 day => 31 [Australian time] %X 13:34:56 locale = en-AU skip round trip hour => 13 minute => 34 second => 56 [Australian date/time] %c AU_THU 31 AU_DEC 1998 13:34:56 AEDT locale = en-AU skip round trip year => 1998 month => 12 day => 31 hour => 13 minute => 34 second => 56 offset => 39600 [US date] %x 12/31/1998 locale = en-US skip round trip year => 1998 month => 12 day => 31 [US time] %X 01:34:56 PM locale = en-US skip round trip hour => 13 minute => 34 second => 56 [US date/time] %c Thu 31 Dec 1998 01:34:56 PM MST locale = en-US skip round trip year => 1998 month => 12 day => 31 hour => 13 minute => 34 second => 56 offset => -25200 [UK date] %x 31/12/98 locale = en-GB skip round trip year => 1998 month => 12 day => 31 [UK time] %X 13:34:56 locale = en-GB skip round trip hour => 13 minute => 34 second => 56 [UK date/time] %c Thu 31 Dec 1998 13:34:56 GMT locale = en-GB skip round trip year => 1998 month => 12 day => 31 hour => 13 minute => 34 second => 56 offset => 0 [French (France) date] %x 31/12/1998 locale = fr-FR skip round trip year => 1998 month => 12 day => 31 [French (France) time] %X 13:34:56 locale = fr-FR skip round trip hour => 13 minute => 34 second => 56 [French (France) date/time] %c jeu. 31 Déc. 1998 13:34:56 CEST locale = fr-FR skip round trip year => 1998 month => 12 day => 31 hour => 13 minute => 34 second => 56 offset => 7200 [French (Generic) date] %x 12/31/98 locale = fr skip round trip year => 1998 month => 12 day => 31 [French (Generic) time] %X 13:34:56 locale = fr skip round trip hour => 13 minute => 34 second => 56 [French (Generic) date/time] %c jeu. Déc. 31 13:34:56 1998 locale = fr skip round trip year => 1998 month => 12 day => 31 hour => 13 minute => 34 second => 56 [epoch without time zone] %s 42 epoch => 42 time_zone_long_name => floating [epoch with time zone] %s %Z 42 UTC epoch => 42 offset => 0 [epoch with nanosecond] %s %N 42 000000034 epoch => 42 nanosecond => 34 DateTime-Format-Strptime-1.63/t/0000775000175000017500000000000012645520607016306 5ustar autarchautarchDateTime-Format-Strptime-1.63/t/author-test-version.t0000644000175000017500000000107112645520607022432 0ustar autarchautarch BEGIN { unless ($ENV{AUTHOR_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for testing by the author'); } } use strict; use warnings; use Test::More; # generated by Dist::Zilla::Plugin::Test::Version 1.05 use Test::Version; my @imports = qw( version_all_ok ); my $params = { is_strict => 1, has_version => 1, multiple => 0, }; push @imports, $params if version->parse( $Test::Version::VERSION ) >= version->parse('1.002'); Test::Version->import(@imports); version_all_ok; done_testing; DateTime-Format-Strptime-1.63/t/00-report-prereqs.t0000644000175000017500000001273112645520607021704 0ustar autarchautarch#!perl use strict; use warnings; # This test was generated by Dist::Zilla::Plugin::Test::ReportPrereqs 0.021 use Test::More tests => 1; use ExtUtils::MakeMaker; use File::Spec; # from $version::LAX my $lax_version_re = qr/(?: undef | (?: (?:[0-9]+) (?: \. | (?:\.[0-9]+) (?:_[0-9]+)? )? | (?:\.[0-9]+) (?:_[0-9]+)? ) | (?: v (?:[0-9]+) (?: (?:\.[0-9]+)+ (?:_[0-9]+)? )? | (?:[0-9]+)? (?:\.[0-9]+){2,} (?:_[0-9]+)? ) )/x; # hide optional CPAN::Meta modules from prereq scanner # and check if they are available my $cpan_meta = "CPAN::Meta"; my $cpan_meta_pre = "CPAN::Meta::Prereqs"; my $HAS_CPAN_META = eval "require $cpan_meta; $cpan_meta->VERSION('2.120900')" && eval "require $cpan_meta_pre"; ## no critic # Verify requirements? my $DO_VERIFY_PREREQS = 1; sub _max { my $max = shift; $max = ( $_ > $max ) ? $_ : $max for @_; return $max; } sub _merge_prereqs { my ($collector, $prereqs) = @_; # CPAN::Meta::Prereqs object if (ref $collector eq $cpan_meta_pre) { return $collector->with_merged_prereqs( CPAN::Meta::Prereqs->new( $prereqs ) ); } # Raw hashrefs for my $phase ( keys %$prereqs ) { for my $type ( keys %{ $prereqs->{$phase} } ) { for my $module ( keys %{ $prereqs->{$phase}{$type} } ) { $collector->{$phase}{$type}{$module} = $prereqs->{$phase}{$type}{$module}; } } } return $collector; } my @include = qw( ); my @exclude = qw( ); # Add static prereqs to the included modules list my $static_prereqs = do 't/00-report-prereqs.dd'; # Merge all prereqs (either with ::Prereqs or a hashref) my $full_prereqs = _merge_prereqs( ( $HAS_CPAN_META ? $cpan_meta_pre->new : {} ), $static_prereqs ); # Add dynamic prereqs to the included modules list (if we can) my ($source) = grep { -f } 'MYMETA.json', 'MYMETA.yml'; if ( $source && $HAS_CPAN_META ) { if ( my $meta = eval { CPAN::Meta->load_file($source) } ) { $full_prereqs = _merge_prereqs($full_prereqs, $meta->prereqs); } } else { $source = 'static metadata'; } my @full_reports; my @dep_errors; my $req_hash = $HAS_CPAN_META ? $full_prereqs->as_string_hash : $full_prereqs; # Add static includes into a fake section for my $mod (@include) { $req_hash->{other}{modules}{$mod} = 0; } for my $phase ( qw(configure build test runtime develop other) ) { next unless $req_hash->{$phase}; next if ($phase eq 'develop' and not $ENV{AUTHOR_TESTING}); for my $type ( qw(requires recommends suggests conflicts modules) ) { next unless $req_hash->{$phase}{$type}; my $title = ucfirst($phase).' '.ucfirst($type); my @reports = [qw/Module Want Have/]; for my $mod ( sort keys %{ $req_hash->{$phase}{$type} } ) { next if $mod eq 'perl'; next if grep { $_ eq $mod } @exclude; my $file = $mod; $file =~ s{::}{/}g; $file .= ".pm"; my ($prefix) = grep { -e File::Spec->catfile($_, $file) } @INC; my $want = $req_hash->{$phase}{$type}{$mod}; $want = "undef" unless defined $want; $want = "any" if !$want && $want == 0; my $req_string = $want eq 'any' ? 'any version required' : "version '$want' required"; if ($prefix) { my $have = MM->parse_version( File::Spec->catfile($prefix, $file) ); $have = "undef" unless defined $have; push @reports, [$mod, $want, $have]; if ( $DO_VERIFY_PREREQS && $HAS_CPAN_META && $type eq 'requires' ) { if ( $have !~ /\A$lax_version_re\z/ ) { push @dep_errors, "$mod version '$have' cannot be parsed ($req_string)"; } elsif ( ! $full_prereqs->requirements_for( $phase, $type )->accepts_module( $mod => $have ) ) { push @dep_errors, "$mod version '$have' is not in required range '$want'"; } } } else { push @reports, [$mod, $want, "missing"]; if ( $DO_VERIFY_PREREQS && $type eq 'requires' ) { push @dep_errors, "$mod is not installed ($req_string)"; } } } if ( @reports ) { push @full_reports, "=== $title ===\n\n"; my $ml = _max( map { length $_->[0] } @reports ); my $wl = _max( map { length $_->[1] } @reports ); my $hl = _max( map { length $_->[2] } @reports ); if ($type eq 'modules') { splice @reports, 1, 0, ["-" x $ml, "", "-" x $hl]; push @full_reports, map { sprintf(" %*s %*s\n", -$ml, $_->[0], $hl, $_->[2]) } @reports; } else { splice @reports, 1, 0, ["-" x $ml, "-" x $wl, "-" x $hl]; push @full_reports, map { sprintf(" %*s %*s %*s\n", -$ml, $_->[0], $wl, $_->[1], $hl, $_->[2]) } @reports; } push @full_reports, "\n"; } } } if ( @full_reports ) { diag "\nVersions for all modules listed in $source (including optional ones):\n\n", @full_reports; } if ( @dep_errors ) { diag join("\n", "\n*** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING ***\n", "The following REQUIRED prerequisites were not satisfied:\n", @dep_errors, "\n" ); } pass; # vim: ts=4 sts=4 sw=4 et: DateTime-Format-Strptime-1.63/t/release-portability.t0000644000175000017500000000053512645520607022454 0ustar autarchautarch#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use strict; use warnings; use Test::More; eval 'use Test::Portability::Files'; plan skip_all => 'Test::Portability::Files required for testing portability' if $@; run_tests(); DateTime-Format-Strptime-1.63/t/author-mojibake.t0000644000175000017500000000040212645520607021546 0ustar autarchautarch#!perl BEGIN { unless ($ENV{AUTHOR_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for testing by the author'); } } use strict; use warnings qw(all); use Test::More; use Test::Mojibake; all_files_encoding_ok(); DateTime-Format-Strptime-1.63/t/release-pod-coverage.t0000644000175000017500000000215112645520607022461 0ustar autarchautarch#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } # This file was automatically generated by Dist::Zilla::Plugin::Test::Pod::Coverage::Configurable. use Test::Pod::Coverage 1.08; use Test::More 0.88; BEGIN { if ( $] <= 5.008008 ) { plan skip_all => 'These tests require Pod::Coverage::TrustPod, which only works with Perl 5.8.9+'; } } use Pod::Coverage::TrustPod; my %skip = map { $_ => 1 } qw( ); my @modules; for my $module ( all_modules() ) { next if $skip{$module}; push @modules, $module; } plan skip_all => 'All the modules we found were excluded from POD coverage test.' unless @modules; plan tests => scalar @modules; my %trustme = (); my @also_private; for my $module ( sort @modules ) { pod_coverage_ok( $module, { coverage_class => 'Pod::Coverage::TrustPod', also_private => \@also_private, trustme => $trustme{$module} || [], }, "pod coverage for $module" ); } done_testing(); DateTime-Format-Strptime-1.63/t/locales.t0000644000175000017500000001270712645520607020122 0ustar autarchautarchuse strict; use warnings; use Test::More 0.96; use Test::Fatal; use DateTime::Format::Strptime; use DateTime::Locale; use DateTime; my @locales = $ENV{AUTHOR_TESTING} ? ( sort DateTime::Locale->ids ) : qw( en de ga pt zh ); my $code_meth = DateTime::Locale->load('en')->can('code') ? 'code' : 'id'; foreach my $locale (@locales) { subtest( $locale, sub { test_days($locale); test_months($locale); test_am_pm($locale); test_locale($locale); } ); } subtest( 'format_datetime with locale', sub { my $strptime = DateTime::Format::Strptime->new( pattern => '%B %Y', locale => 'pt', on_error => 'croak', ); my $dt = DateTime->new( year => 2015, month => 8, locale => 'en', ); is( $strptime->format_datetime($dt), 'agosto 2015', 'formatted output is in locale of formatter (Portugese)' ); is( $dt->locale->$code_meth, 'en', q{formatter leaves DateTime object's locale unchanged} ); } ); done_testing(); sub test_days { my $locale = shift; subtest( 'days', sub { foreach my $day ( 1 .. 7 ) { subtest( "Day $day", sub { _test_one_day( $locale, $day ); }, ); } } ); } sub _test_one_day { my $locale = shift; my $day = shift; _utf8_output(); my $pattern = '%Y-%m-%d %A'; my $dt = DateTime->now( locale => $locale )->set( day => $day ); my $input = $dt->strftime($pattern); my $strptime; is( exception { $strptime = DateTime::Format::Strptime->new( pattern => $pattern, locale => $locale, on_error => 'croak', ); }, undef, 'constructor with day name in pattern (%A)' ) or return; my $parsed_dt; is( exception { $parsed_dt = $strptime->parse_datetime($input) }, undef, "parsed $input" ) or return; is( $parsed_dt->strftime($pattern), $input, 'strftime output matches input' ); } sub test_months { my $locale = shift; subtest( 'months', sub { foreach my $month ( 1 .. 12 ) { subtest( "Month $month", sub { _test_one_month( $locale, $month ) }, ); } } ); } sub _test_one_month { my $locale = shift; my $month = shift; _utf8_output(); my $pattern = '%Y-%m-%d %B'; my $dt = DateTime->now( locale => $locale )->truncate( to => 'month' ) ->set( month => $month ); my $input = $dt->strftime($pattern); my $strptime; is( exception { $strptime = DateTime::Format::Strptime->new( pattern => $pattern, locale => $locale, on_error => 'croak', ); }, undef, 'constructor with month name (%B)' ) or return; my $parsed_dt; is( exception { $parsed_dt = $strptime->parse_datetime($input) }, undef, "parsed $input" ) or return; is( $parsed_dt->strftime($pattern), $input, 'strftime output matches input' ); } sub test_am_pm { my $locale = shift; subtest( 'am/pm', sub { foreach my $hour ( 0, 11, 12, 23 ) { subtest( "Hour $hour", sub { _test_one_hour( $locale, $hour ); }, ); } } ); } sub _test_one_hour { my $locale = shift; my $hour = shift; my $pattern = '%Y-%m-%d %H:%M %p'; _utf8_output(); my $dt = DateTime->now( locale => $locale )->set( hour => $hour ); my $input = $dt->strftime($pattern); my $strptime; is( exception { $strptime = DateTime::Format::Strptime->new( pattern => $pattern, locale => $locale, on_error => 'croak', ); }, undef, 'constructor with meridian (%p)' ) or return; my $parsed_dt; is( exception { $parsed_dt = $strptime->parse_datetime($input) }, undef, "parsed $input", ) or return; is( $parsed_dt->strftime($pattern), $input, 'strftime output matches input' ); } sub test_locale { my $locale = shift; my $strptime; is( exception { $strptime = DateTime::Format::Strptime->new( pattern => '%Y-%m-%d', locale => $locale, on_error => 'croak', ); }, undef, 'constructor with locale' ) or return; my $input = '2015-01-30'; my $parsed_dt; is( exception { $parsed_dt = $strptime->parse_datetime($input) }, undef, "parsed $input", ) or return; is( $parsed_dt->locale->$code_meth, $locale, "code of locale for DateTime returned by parser is $locale" ); } sub _utf8_output { binmode $_, ':encoding(UTF-8)' for map { Test::Builder->new->$_ } qw( output failure_output todo_output ); } DateTime-Format-Strptime-1.63/t/release-tidyall.t0000644000175000017500000000050712645520607021553 0ustar autarchautarch#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } # This file was automatically generated by Dist::Zilla::Plugin::Test::TidyAll use Test::Code::TidyAll 0.24; use Test::More 0.88; tidyall_ok(); done_testing(); DateTime-Format-Strptime-1.63/t/author-pod-syntax.t0000644000175000017500000000050312645520607022075 0ustar autarchautarch#!perl BEGIN { unless ($ENV{AUTHOR_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for testing by the author'); } } # This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. use strict; use warnings; use Test::More; use Test::Pod 1.41; all_pod_files_ok(); DateTime-Format-Strptime-1.63/t/release-pod-linkcheck.t0000644000175000017500000000077512645520607022633 0ustar autarchautarch#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use strict; use warnings; use Test::More; foreach my $env_skip ( qw( SKIP_POD_LINKCHECK ) ){ plan skip_all => "\$ENV{$env_skip} is set, skipping" if $ENV{$env_skip}; } eval "use Test::Pod::LinkCheck"; if ( $@ ) { plan skip_all => 'Test::Pod::LinkCheck required for testing POD'; } else { Test::Pod::LinkCheck->new->all_pod_ok; } DateTime-Format-Strptime-1.63/t/author-00-compile.t0000644000175000017500000000250512645520607021640 0ustar autarchautarch BEGIN { unless ($ENV{AUTHOR_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for testing by the author'); } } use 5.006; use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.054 use Test::More; plan tests => 2; my @module_files = ( 'DateTime/Format/Strptime.pm' ); # no fake home requested my $inc_switch = -d 'blib' ? '-Mblib' : '-Ilib'; use File::Spec; use IPC::Open3; use IO::Handle; open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!"; my @warnings; for my $lib (@module_files) { # see L my $stderr = IO::Handle->new; my $pid = open3($stdin, '>&STDERR', $stderr, $^X, $inc_switch, '-e', "require q[$lib]"); binmode $stderr, ':crlf' if $^O eq 'MSWin32'; my @_warnings = <$stderr>; waitpid($pid, 0); is($?, 0, "$lib loaded ok"); shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/ and not eval { require blib; blib->VERSION('1.01') }; if (@_warnings) { warn @_warnings; push @warnings, @_warnings; } } is(scalar(@warnings), 0, 'no warnings found') or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) ); DateTime-Format-Strptime-1.63/t/author-eol.t0000644000175000017500000000164412645520607020555 0ustar autarchautarch BEGIN { unless ($ENV{AUTHOR_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for testing by the author'); } } use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::EOL 0.18 use Test::More 0.88; use Test::EOL; my @files = ( 'lib/DateTime/Format/Strptime.pm', 't/00-report-prereqs.dd', 't/00-report-prereqs.t', 't/author-00-compile.t', 't/author-eol.t', 't/author-mojibake.t', 't/author-no-tabs.t', 't/author-pod-spell.t', 't/author-pod-syntax.t', 't/author-test-all-my-deps.t', 't/author-test-version.t', 't/basic.t', 't/edge.t', 't/errors.t', 't/import.t', 't/lib/T.pm', 't/locales.t', 't/release-pod-coverage.t', 't/release-pod-linkcheck.t', 't/release-portability.t', 't/release-tidyall.t' ); eol_unix_ok($_, { trailing_whitespace => 1 }) foreach @files; done_testing; DateTime-Format-Strptime-1.63/t/author-no-tabs.t0000644000175000017500000000161212645520607021334 0ustar autarchautarch BEGIN { unless ($ENV{AUTHOR_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for testing by the author'); } } use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::NoTabs 0.15 use Test::More 0.88; use Test::NoTabs; my @files = ( 'lib/DateTime/Format/Strptime.pm', 't/00-report-prereqs.dd', 't/00-report-prereqs.t', 't/author-00-compile.t', 't/author-eol.t', 't/author-mojibake.t', 't/author-no-tabs.t', 't/author-pod-spell.t', 't/author-pod-syntax.t', 't/author-test-all-my-deps.t', 't/author-test-version.t', 't/basic.t', 't/edge.t', 't/errors.t', 't/import.t', 't/lib/T.pm', 't/locales.t', 't/release-pod-coverage.t', 't/release-pod-linkcheck.t', 't/release-portability.t', 't/release-tidyall.t' ); notabs_ok($_) foreach @files; done_testing; DateTime-Format-Strptime-1.63/t/import.t0000644000175000017500000000143212645520607020003 0ustar autarchautarchuse strict; use warnings; # We need this to be set to catch warning from inside other packages. BEGIN { $^W = 1; } use Test::More; use Test::Warnings qw( warnings ); use DateTime::Format::Strptime qw( strftime strptime ), -api_version => '1.55'; is_deeply( [ warnings { my $parser = DateTime::Format::Strptime->new( pattern => '%Y' ); $parser->pattern('%y'); $parser->locale('fr'); $parser->time_zone('UTC'); } ], [], 'no warnings when calling accessors on constructed object' ); is( strptime( '%Y', '2005' )->year, 2005, 'export strptime works as expected' ); is( strftime( '%Y', DateTime->new( year => 2005 ) ), 2005, 'export strftime works as expected' ); done_testing(); DateTime-Format-Strptime-1.63/t/edge.t0000644000175000017500000000170312645520607017376 0ustar autarchautarchuse strict; use warnings; use strict; use warnings; use utf8; use lib 't/lib'; use T qw( run_tests_from_data test_datetime_object ); use Test::More 0.96; use Test::Fatal; use DateTime::Format::Strptime; run_tests_from_data( \*DATA ); done_testing(); __DATA__ [Leading and trailing space] %Y%m%d 20151222 skip round trip year => 2015 month => 12 day => 22 [Olson time zone in upper case] %Y %O 2015 AMERICA/NEW_YORK skip round trip year => 2015 time_zone_long_name => America/New_York [Olson time zone in lower case] %Y %O 2015 america/new_york skip round trip year => 2015 time_zone_long_name => America/New_York [Olson time zone in random case] %Y %O 2015 amERicA/new_YORK skip round trip year => 2015 time_zone_long_name => America/New_York [Month name match is not too greedy] %d%b%y 15Aug07 year => 2007 month => 8 day => 15 [Trailing text after match] %Y-%m-%d 2016-01-13 in the afternoon skip round trip year => 2016 month => 1 day => 13 DateTime-Format-Strptime-1.63/t/lib/0000775000175000017500000000000012645520607017054 5ustar autarchautarchDateTime-Format-Strptime-1.63/t/lib/T.pm0000644000175000017500000000655312645520607017624 0ustar autarchautarchpackage # hide from PAUSE T; use strict; use warnings; use Test::Builder; use Test::More 0.96; use Test::Fatal; use DateTime::Format::Strptime; use Exporter qw( import ); our @EXPORT_OK = qw( run_tests_from_data test_datetime_object utf8_output ); sub run_tests_from_data { my $fh = shift; for my $test ( _tests_from_fh($fh) ) { subtest( qq{$test->{name}}, sub { utf8_output(); my $parser; is( exception { $parser = DateTime::Format::Strptime->new( pattern => $test->{pattern}, ( $test->{locale} ? ( locale => $test->{locale} ) : () ), on_error => 'croak', ); }, undef, "no exception building parser for $test->{pattern}" ) or return; # Thursday changed from "Thu" to "Thu." and December went from # "Dec" to "Dec." between CLDR versions. $test->{input} =~ s/AU_THU/DateTime::Locale->load('en-AU')->day_format_abbreviated->[3]/e; $test->{input} =~ s/AU_DEC/DateTime::Locale->load('en-AU')->month_format_abbreviated->[11]/e; ( my $real_input = $test->{input} ) =~ s/\\n/\n/g; my $dt; is( exception { $dt = $parser->parse_datetime($real_input) }, undef, "no exception parsing $test->{input}" ) or return; test_datetime_object( $dt, $test->{expect} ); unless ( $test->{skip_round_trip} ) { is( $parser->format_datetime($dt), $real_input, 'round trip via strftime produces original input' ); } } ); } } sub utf8_output { binmode $_, ':encoding(UTF-8)' for map { Test::Builder->new->$_ } qw( output failure_output todo_output ); } sub test_datetime_object { my $dt = shift; my $expect = shift; for my $meth ( sort keys %{$expect} ) { is( $dt->$meth, $expect->{$meth}, "$meth is $expect->{$meth}" ); } } sub _tests_from_fh { my $fh = shift; my @tests; my $d = do { local $/; <$fh> }; my $test_re = qr/ \[(.+?)\]\n # test name (.+?)\n # pattern (.+?)\n # input (?:locale\ =\ (.+?)\n)? # optional locale (skip\ round\ trip\n)? # skip a round trip? (.+?)\n # k-v pairs for expected values (?:\n|\z) # end of test /xs; while ( $d =~ /$test_re/g ) { push @tests, { name => $1, pattern => $2, input => $3, locale => $4, skip_round_trip => $5, expect => { map { split /\s+=>\s+/ } split /\n/, $6, }, }; } return @tests; } 1; DateTime-Format-Strptime-1.63/t/00-report-prereqs.dd0000644000175000017500000000577012645520607022035 0ustar autarchautarchdo { my $x = { 'configure' => { 'requires' => { 'ExtUtils::MakeMaker' => '0' } }, 'develop' => { 'requires' => { 'Code::TidyAll' => '0.24', 'File::Spec' => '0', 'IO::Handle' => '0', 'IPC::Open3' => '0', 'Perl::Critic' => '1.123', 'Perl::Tidy' => '20140711', 'Pod::Coverage::TrustPod' => '0', 'Test::Code::TidyAll' => '0.24', 'Test::EOL' => '0', 'Test::Fatal' => '0', 'Test::Mojibake' => '0', 'Test::More' => '0.96', 'Test::NoTabs' => '0', 'Test::Pod' => '1.41', 'Test::Pod::Coverage' => '1.08', 'Test::Pod::LinkCheck' => '0', 'Test::Spelling' => '0.12', 'Test::Version' => '1' } }, 'runtime' => { 'requires' => { 'Carp' => '0', 'DateTime' => '1.00', 'DateTime::Locale' => '0.45', 'DateTime::TimeZone' => '0.79', 'Exporter' => '0', 'JSON::PP' => '2.27300', 'Package::DeprecationManager' => '0.15', 'Params::Validate' => '1.20', 'Try::Tiny' => '0', 'constant' => '0', 'strict' => '0', 'warnings' => '0' } }, 'test' => { 'recommends' => { 'CPAN::Meta' => '2.120900' }, 'requires' => { 'ExtUtils::MakeMaker' => '0', 'File::Spec' => '0', 'Test::Builder' => '0', 'Test::Fatal' => '0', 'Test::More' => '0.96', 'Test::Warnings' => '0', 'lib' => '0', 'utf8' => '0' } } }; $x; }DateTime-Format-Strptime-1.63/t/errors.t0000644000175000017500000002342412645520607020012 0ustar autarchautarchuse strict; use warnings; use Test::More 0.96; use Test::Fatal; use DateTime::Format::Strptime; subtest( 'valid constructor', sub { my $parser; is( exception { $parser = DateTime::Format::Strptime->new( pattern => '%Y' ) }, undef, 'no exception when constructing object with valid pattern' ); isa_ok( $parser, 'DateTime::Format::Strptime', ); } ); subtest( 'constructor error', sub { my $parser; like( exception { $parser = DateTime::Format::Strptime->new( pattern => '%Y %Q' ) }, qr/\QPattern contained an unrecognized strptime token, "%Q"/, 'no exception when constructing object with valid pattern' ); is( $parser, undef, 'constructor does not return object on invalid pattern' ); } ); { my @tests = ( { name => '12-hour time without meridian', pattern => '%Y-%m-%d %I:%M', input => '2015-01-02 11:15', error => qr{\QParsed a 12-hour based hour, "11", but the pattern does not include an AM/PM specifier}, }, { name => 'uncrecognized time zone abbreviation', pattern => '%Y-%m-%d %Z', input => '2015-01-02 FOO', error => qr{\QParsed an unrecognized time zone abbreviation, "FOO"}, }, { name => 'ambiguous time zone abbreviation', pattern => '%Y-%m-%d %Z', input => '2015-01-02 NST', error => qr{\QThe time zone abbreviation that was parsed is ambiguous, "NST"}, }, { name => '24-hour vs 12-hour', pattern => '%Y-%m-%d %H %I %P', input => '2015-01-02 13 2 AM', error => qr{\QParsed an input with 24-hour and 12-hour time values that do not match - "13" versus "2"}, }, { name => '24-hour vs AM/PM (13AM)', pattern => '%Y-%m-%d %H %P', input => '2015-01-02 13 AM', error => qr{\QParsed an input with 24-hour and AM/PM values that do not match - "13" versus "AM"}, }, { name => '24-hour vs AM/PM (4AM)', pattern => '%Y-%m-%d %H %P', input => '2015-01-02 4 PM', error => qr{\QParsed an input with 24-hour and AM/PM values that do not match - "4" versus "PM"}, }, { name => 'year vs century', pattern => '%Y-%m-%d %C', input => '2015-01-02 19', error => qr{\QParsed an input with year and century values that do not match - "2015" versus "19"}, }, { name => 'year vs year-within-century', pattern => '%Y-%m-%d %y', input => '2015-01-02 14', error => qr{\QParsed an input with year and year-within-century values that do not match - "2015" versus "14"}, }, { name => 'time zone offset vs time zone abbreviation', pattern => '%Y %z %Z', input => '2015 -0500 AEST', error => qr{\QParsed an input with time zone abbreviation and time zone offset values that do not match - "AEST" versus "-0500"}, }, { name => 'epoch vs year', pattern => '%s %Y', input => '42 2015', error => qr{\QParsed an input with epoch and year values that do not match - "42" versus "2015"}, }, { name => 'epoch vs month', pattern => '%s %m', input => '42 12', error => qr{\QParsed an input with epoch and month values that do not match - "42" versus "12"}, }, { name => 'epoch vs day', pattern => '%s %d', input => '42 13', error => qr{\QParsed an input with epoch and day values that do not match - "42" versus "13"}, }, { name => 'epoch vs day', pattern => '%s %H', input => '42 14', error => qr{\QParsed an input with epoch and hour values that do not match - "42" versus "14"}, }, { name => 'epoch vs minute', pattern => '%s %M', input => '42 15', error => qr{\QParsed an input with epoch and minute values that do not match - "42" versus "15"}, }, { name => 'epoch vs minute', pattern => '%s %S', input => '42 16', error => qr{\QParsed an input with epoch and second values that do not match - "42" versus "16"}, }, { name => 'epoch vs hour (1-12)', pattern => '%s %I %P', input => '42 4 PM', error => qr{\QParsed an input with epoch and hour (1-12) values that do not match - "42" versus "4"}, }, { name => 'epoch vs day of year', pattern => '%s %j', input => '42 17', error => qr{\QParsed an input with epoch and day of year values that do not match - "42" versus "17"}, }, { name => 'month vs day of year', pattern => '%Y %m %j', input => '2015 8 17', error => qr{\QParsed an input with month and day of year values that do not match - "8" versus "17"}, }, { name => 'day name vs date', pattern => '%Y %m %d %a', input => '2015 8 17 Tuesday', error => qr{\QParsed an input where the day name does not match the date - "Tuesday" versus "2015-08-17"}, }, { name => 'day of week vs date', pattern => '%Y %m %d %u', input => '2015 8 17 2', error => qr{\QParsed an input where the day of week does not match the date - "2" versus "2015-08-17"}, }, { name => 'day of week (Sunday as 0) vs date', pattern => '%Y %m %d %w', input => '2015 8 17 2', error => qr{\QParsed an input where the day of week (Sunday as 0) does not match the date - "2" versus "2015-08-17"}, }, { name => 'iso week year vs date', pattern => '%Y %m %d %G', input => '2015 8 17 2013', error => qr{\QParsed an input where the ISO week year does not match the date - "2013" versus "2015-08-17"}, }, { name => 'iso week year (without century) vs date', pattern => '%Y %m %d %g', input => '2015 8 17 13', error => qr{\QParsed an input where the ISO week year (without century) does not match the date - "13" versus "2015-08-17"}, }, { name => 'iso week number vs date', pattern => '%Y %m %d %W', input => '2015 8 17 15', error => qr{\QParsed an input where the ISO week number (Monday starts week) does not match the date - "15" versus "2015-08-17"}, }, { name => 'iso week number vs date', pattern => '%Y %m %d %U', input => '2015 8 17 15', error => qr{\QParsed an input where the ISO week number (Sunday starts week) does not match the date - "15" versus "2015-08-17"}, }, { name => 'invalid time zone name', pattern => '%Y %O', input => '2015 Dev/Null', error => qr{\QThe Olson time zone name that was parsed does not appear to be valid, "Dev/Null"}, }, { name => 'illegal date', pattern => '%Y-%m-%d', input => '0000-00-00', error => qr{\QParsed values did not produce a valid date}, }, { name => 'illegal time', pattern => '%Y-%m-%d %H:%M', input => '0000-00-00 26:99', error => qr{\QParsed values did not produce a valid date}, }, { name => 'February 29, 2013 - RT #110247', pattern => '%a %b %d %T %Y', input => 'Wed Feb 29 12:02:28 2013', error => qr{\QParsed values did not produce a valid date}, }, ); for my $test (@tests) { subtest( $test->{name}, sub { _test_error_handling($test) } ); } } done_testing(); sub _test_error_handling { my $test = shift; my $parser = DateTime::Format::Strptime->new( pattern => $test->{pattern}, on_error => 'croak', ); like( exception { $parser->parse_datetime( $test->{input} ) }, $test->{error}, 'croak error' ); $parser = DateTime::Format::Strptime->new( pattern => $test->{pattern}, on_error => 'undef', ); my $dt = $parser->parse_datetime( $test->{input} ); like( $parser->errmsg, $test->{error}, 'errmsg error ' ); is( $dt, undef, 'no datetime object is returned when there is a parse error' ); $parser = DateTime::Format::Strptime->new( pattern => $test->{pattern}, on_error => sub { die { e => $_[1] } }, ); my $e = exception { $parser->parse_datetime( $test->{input} ) }; like( $e->{e}, $test->{error}, 'custom on_error' ); } DateTime-Format-Strptime-1.63/t/author-pod-spell.t0000644000175000017500000000106012645520607021665 0ustar autarchautarch BEGIN { unless ($ENV{AUTHOR_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for testing by the author'); } } use strict; use warnings; use Test::More; # generated by Dist::Zilla::Plugin::Test::PodSpelling 2.007000 use Test::Spelling 0.12; use Pod::Wordlist; add_stopwords(); all_pod_files_spelling_ok( qw( bin lib ) ); __DATA__ DROLSKY DROLSKY's PayPal Rolsky Rolsky's Measham POSIX STRPTIME errmsg formatter strf strp strptime Dave autarch Rick rickm Ilmari Mannsåker ilmari lib DateTime Format Strptime DateTime-Format-Strptime-1.63/t/basic.t0000644000175000017500000001466612645520607017567 0ustar autarchautarchuse strict; use warnings; use utf8; use lib 't/lib'; use T qw( run_tests_from_data test_datetime_object ); use Test::More 0.96; use Test::Fatal; use DateTime::Format::Strptime; run_tests_from_data( \*DATA ); subtest( 'parsing whitespace', sub { my $parser = DateTime::Format::Strptime->new( pattern => '%n%Y%t%m%n', on_error => 'croak', ); my $dt = $parser->parse_datetime(<<"EOF"); \t 2015 12 EOF my %expect = ( year => 2015, month => 12, ); test_datetime_object( $dt, \%expect ); } ); subtest( 'parser time zone is set on returned object', sub { my $parser = DateTime::Format::Strptime->new( pattern => '%Y %H:%M:%S %Z', time_zone => 'America/New_York', on_error => 'croak', ); my $dt = $parser->parse_datetime('2003 23:45:56 MDT'); my %expect = ( year => 2003, hour => 0, minute => 45, second => 56, time_zone_long_name => 'America/New_York', ); test_datetime_object( $dt, \%expect ); } ); done_testing(); __DATA__ [ISO8601] %Y-%m-%dT%H:%M:%S 2015-10-08T15:39:44 year => 2015 month => 10 day => 8 hour => 15 minute => 39 second => 44 [date with 4-digit year] %Y-%m-%d 1998-12-31 year => 1998 month => 12 day => 31 [date with 2-digit year] %y-%m-%d 98-12-31 year => 1998 month => 12 day => 31 [date with leading space on month] %e-%b-%Y 3-Jun-2010 year => 2010 month => 6 day => 3 [year and day of year] %Y years %j days 1998 years 312 days year => 1998 month => 11 day => 8 [date with abbreviated month] %b %d %Y Jan 24 2003 year => 2003 month => 1 day => 24 [date with abbreviated month is case-insensitive] %b %d %Y jAN 24 2003 skip round trip year => 2003 month => 1 day => 24 [date with full month] %B %d %Y January 24 2003 year => 2003 month => 1 day => 24 [date with full month is case-insensitive] %B %d %Y jAnUAry 24 2003 skip round trip year => 2003 month => 1 day => 24 [24 hour time] %H:%M:%S 23:45:56 year => 1 month => 1 day => 1 hour => 23 minute => 45 second => 56 [12 hour time (PM)] %l:%M:%S %p 11:45:56 PM year => 1 month => 1 day => 1 hour => 23 minute => 45 second => 56 [12 hour time (am) and am/pm is case-insensitive] %l:%M:%S %p 11:45:56 am skip round trip year => 1 month => 1 day => 1 hour => 11 minute => 45 second => 56 [24-hour time] %T 23:34:45 hour => 23 minute => 34 second => 45 [12-hour time] %r 11:34:45 PM hour => 23 minute => 34 second => 45 [24-hour time without second] %R 23:34 hour => 23 minute => 34 second => 0 [US style date] %D 11/30/03 year => 2003 month => 11 day => 30 [ISO style date] %F 2003-11-30 year => 2003 month => 11 day => 30 [nanosecond with no length] %H:%M:%S.%N 23:45:56.123456789 hour => 23 minute => 45 second => 56 nanosecond => 123456789 [nanosecond with length of 6] %H:%M:%S.%6N 23:45:56.123456 hour => 23 minute => 45 second => 56 nanosecond => 123456000 [nanosecond with length of 3] %H:%M:%S.%3N 23:45:56.123 hour => 23 minute => 45 second => 56 nanosecond => 123000000 [nanosecond with no length but < 9 digits] %H:%M:%S.%N 23:45:56.543 skip round trip hour => 23 minute => 45 second => 56 nanosecond => 543000000 [time zone as numeric offset] %H:%M:%S %z 23:45:56 +1000 hour => 23 minute => 45 second => 56 offset => 36000 [time zone as abbreviation] %H:%M:%S %Z 23:45:56 AEST skip round trip hour => 23 minute => 45 second => 56 offset => 36000 [time zone as Olson name] %H:%M:%S %O 23:45:56 America/Chicago hour => 23 minute => 45 second => 56 time_zone_long_name => America/Chicago [escaped percent] %Y%%%m%%%d 2015%05%14 year => 2015 month => 5 day => 14 [escaped percent followed by letter token] %Y%%%m%%%d%%H 2015%05%14%H year => 2015 month => 5 day => 14 [every pattern] %a %b %B %C %d %e %h %H %I %j %k %l %m %M %n %N %O %p %P %S %U %u %w %W %y %Y %s %G %g %z %Z %%Y %% Wed Nov November 20 05 5 Nov 21 09 309 21 9 11 34 \n 123456789 America/Denver PM pm 45 44 3 3 44 03 2003 1068093285 2003 03 -0700 MST %Y % year => 2003 month => 11 day => 5 hour => 21 minute => 34 second => 45 nanosecond => 123456789 time_zone_long_name => America/Denver [Australian date] %x 31/12/98 locale = en-AU skip round trip year => 1998 month => 12 day => 31 [Australian time] %X 13:34:56 locale = en-AU skip round trip hour => 13 minute => 34 second => 56 [Australian date/time] %c AU_THU 31 AU_DEC 1998 13:34:56 AEDT locale = en-AU skip round trip year => 1998 month => 12 day => 31 hour => 13 minute => 34 second => 56 offset => 39600 [US date] %x 12/31/1998 locale = en-US skip round trip year => 1998 month => 12 day => 31 [US time] %X 01:34:56 PM locale = en-US skip round trip hour => 13 minute => 34 second => 56 [US date/time] %c Thu 31 Dec 1998 01:34:56 PM MST locale = en-US skip round trip year => 1998 month => 12 day => 31 hour => 13 minute => 34 second => 56 offset => -25200 [UK date] %x 31/12/98 locale = en-GB skip round trip year => 1998 month => 12 day => 31 [UK time] %X 13:34:56 locale = en-GB skip round trip hour => 13 minute => 34 second => 56 [UK date/time] %c Thu 31 Dec 1998 13:34:56 GMT locale = en-GB skip round trip year => 1998 month => 12 day => 31 hour => 13 minute => 34 second => 56 offset => 0 [French (France) date] %x 31/12/1998 locale = fr-FR skip round trip year => 1998 month => 12 day => 31 [French (France) time] %X 13:34:56 locale = fr-FR skip round trip hour => 13 minute => 34 second => 56 [French (France) date/time] %c jeu. 31 Déc. 1998 13:34:56 CEST locale = fr-FR skip round trip year => 1998 month => 12 day => 31 hour => 13 minute => 34 second => 56 offset => 7200 [French (Generic) date] %x 12/31/98 locale = fr skip round trip year => 1998 month => 12 day => 31 [French (Generic) time] %X 13:34:56 locale = fr skip round trip hour => 13 minute => 34 second => 56 [French (Generic) date/time] %c jeu. Déc. 31 13:34:56 1998 locale = fr skip round trip year => 1998 month => 12 day => 31 hour => 13 minute => 34 second => 56 [epoch without time zone] %s 42 epoch => 42 time_zone_long_name => floating [epoch with time zone] %s %Z 42 UTC epoch => 42 offset => 0 [epoch with nanosecond] %s %N 42 000000034 epoch => 42 nanosecond => 34 DateTime-Format-Strptime-1.63/t/author-test-all-my-deps.t0000644000175000017500000000643212645520607023077 0ustar autarchautarch BEGIN { unless ($ENV{AUTHOR_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for testing by the author'); } } use strict; use warnings; use Cwd qw( abs_path ); use Test::More; BEGIN { plan skip_all => 'Must set DATETIME_FORMAT_STRPTIME_TEST_DEPS to true in order to run these tests' unless $ENV{DATETIME_FORMAT_STRPTIME_TEST_DEPS}; } use Test::DependentModules qw( test_all_dependents ); ## no critic (Variables::RequireLocalizedPunctuationVars) $ENV{PERL_TEST_DM_LOG_DIR} = abs_path('.'); ## use critic test_all_dependents( 'DateTime::Format::Strptime', { filter => sub { return 0 if $_[0] =~ /^Mac-/; return 0 if $_[0] eq 'App-dateseq'; return 0 if $_[0] eq 'App-financeta'; # Failing deps return 0 if $_[0] eq 'App-Twimap'; # Fails regardless of Strptime return 0 if $_[0] eq 'Business-RO-CNP'; # Fails regardless of Strptime return 0 if $_[0] eq 'Catmandu-Fix-Date'; # Requires Coro return 0 if $_[0] eq 'Cikl'; # Fails regardless of Strptime return 0 if $_[0] eq 'Data-Apache-mod_status'; # Requires a module which doesn't exist on CPAN return 0 if $_[0] eq 'DPKG-Log'; # Fails regardless of Strptime return 0 if $_[0] eq 'Finance-TW-TAIFEX'; # Requires gtk return 0 if $_[0] eq 'Gtk2-Ex-DbLinker'; # Fails regardless of Strptime return 0 if $_[0] eq 'HTML-FormatData'; # Fails regardless of Strptime return 0 if $_[0] eq 'HTML-Tested'; # Fails regardless of Strptime return 0 if $_[0] eq 'meon-Web'; # prompts for keys to use in testing return 0 if $_[0] eq 'Net-Amazon-AWIS'; # Fails regardless of Strptime return 0 if $_[0] eq 'Net-DRI'; # Fails regardless of Strptime return 0 if $_[0] eq 'Net-Plurk'; # Requires Coro return 0 if $_[0] eq 'Net-IMAP-Server'; # Fails regardless of Strptime return 0 if $_[0] eq 'OpenERP-OOM'; # hangs installing prereqs (probably SOAP::Lite) return 0 if $_[0] eq 'Plagger'; # Fails regardless of Strptime return 0 if $_[0] eq 'SmokeRunner-Multi'; # Fails on installing some prereqs return 0 if $_[0] eq 'OpenResty'; # Fails regardless of Strptime return 0 if $_[0] eq 'Smolder'; # Is either hanging or installing all of CPAN return 0 if $_[0] eq 'Strehler'; # Fails regardless of Strptime return 0 if $_[0] eq 'Video-PlaybackMachine'; # Fails regardless of Strptime return 0 if $_[0] eq 'WebService-IMDB'; # Fails regardless of Strptime return 0 if $_[0] eq 'W3C-SOAP'; # Fails regardless of Strptime return 0 if $_[0] eq 'WWW-DataWiki'; # Requires Wx return 0 if $_[0] eq 'Wx-Perl-DbLinker'; # Fails on installing some prereqs return 0 if $_[0] eq 'XAS'; return 1; }, }, ); done_testing(); DateTime-Format-Strptime-1.63/Makefile.PL0000644000175000017500000000366312645520607020023 0ustar autarchautarch# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v5.043. use strict; use warnings; use ExtUtils::MakeMaker; my %WriteMakefileArgs = ( "ABSTRACT" => "Parse and format strp and strf time patterns", "AUTHOR" => "Dave Rolsky , Rick Measham ", "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => 0 }, "DISTNAME" => "DateTime-Format-Strptime", "LICENSE" => "artistic_2", "NAME" => "DateTime::Format::Strptime", "PREREQ_PM" => { "Carp" => 0, "DateTime" => "1.00", "DateTime::Locale" => "0.45", "DateTime::TimeZone" => "0.79", "Exporter" => 0, "JSON::PP" => "2.27300", "Package::DeprecationManager" => "0.15", "Params::Validate" => "1.20", "Try::Tiny" => 0, "constant" => 0, "strict" => 0, "warnings" => 0 }, "TEST_REQUIRES" => { "ExtUtils::MakeMaker" => 0, "File::Spec" => 0, "Test::Builder" => 0, "Test::Fatal" => 0, "Test::More" => "0.96", "Test::Warnings" => 0, "lib" => 0, "utf8" => 0 }, "VERSION" => "1.63", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "Carp" => 0, "DateTime" => "1.00", "DateTime::Locale" => "0.45", "DateTime::TimeZone" => "0.79", "Exporter" => 0, "ExtUtils::MakeMaker" => 0, "File::Spec" => 0, "JSON::PP" => "2.27300", "Package::DeprecationManager" => "0.15", "Params::Validate" => "1.20", "Test::Builder" => 0, "Test::Fatal" => 0, "Test::More" => "0.96", "Test::Warnings" => 0, "Try::Tiny" => 0, "constant" => 0, "lib" => 0, "strict" => 0, "utf8" => 0, "warnings" => 0 ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); DateTime-Format-Strptime-1.63/META.yml0000644000175000017500000004143212645520607017316 0ustar autarchautarch--- abstract: 'Parse and format strp and strf time patterns' author: - 'Dave Rolsky ' - 'Rick Measham ' build_requires: ExtUtils::MakeMaker: '0' File::Spec: '0' Test::Builder: '0' Test::Fatal: '0' Test::More: '0.96' Test::Warnings: '0' lib: '0' utf8: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 0 generated_by: 'Dist::Zilla version 5.043, CPAN::Meta::Converter version 2.150005' license: artistic_2 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: DateTime-Format-Strptime provides: DateTime::Format::Strptime: file: lib/DateTime/Format/Strptime.pm version: '1.63' requires: Carp: '0' DateTime: '1.00' DateTime::Locale: '0.45' DateTime::TimeZone: '0.79' Exporter: '0' JSON::PP: '2.27300' Package::DeprecationManager: '0.15' Params::Validate: '1.20' Try::Tiny: '0' constant: '0' strict: '0' warnings: '0' resources: bugtracker: http://rt.cpan.org/Public/Dist/Display.html?Name=DateTime-Format-Strptime homepage: http://metacpan.org/release/DateTime-Format-Strptime repository: git://github.com/autarch/DateTime-Format-Strptime.git version: '1.63' x_Dist_Zilla: perl: version: '5.022001' plugins: - class: Dist::Zilla::Plugin::MakeMaker config: Dist::Zilla::Role::TestRunner: default_jobs: 1 name: '@DROLSKY/MakeMaker' version: '5.043' - class: Dist::Zilla::Plugin::Authority name: '@DROLSKY/Authority' version: '1.009' - class: Dist::Zilla::Plugin::AutoPrereqs name: '@DROLSKY/AutoPrereqs' version: '5.043' - class: Dist::Zilla::Plugin::CopyFilesFromBuild name: '@DROLSKY/CopyFilesFromBuild' version: '0.151680' - class: Dist::Zilla::Plugin::Git::GatherDir config: Dist::Zilla::Plugin::GatherDir: exclude_filename: - Build.PL - LICENSE - Makefile.PL - README.md - cpanfile exclude_match: [] follow_symlinks: 0 include_dotfiles: 0 prefix: '' prune_directory: [] root: . Dist::Zilla::Plugin::Git::GatherDir: include_untracked: 0 name: '@DROLSKY/Git::GatherDir' version: '2.036' - class: Dist::Zilla::Plugin::GitHub::Meta name: '@DROLSKY/GitHub::Meta' version: '0.41' - class: Dist::Zilla::Plugin::GitHub::Update config: Dist::Zilla::Plugin::GitHub::Update: metacpan: 1 name: '@DROLSKY/GitHub::Update' version: '0.41' - class: Dist::Zilla::Plugin::MetaResources name: '@DROLSKY/MetaResources' version: '5.043' - class: Dist::Zilla::Plugin::MetaProvides::Package config: Dist::Zilla::Plugin::MetaProvides::Package: finder_objects: - class: Dist::Zilla::Plugin::FinderCode name: '@DROLSKY/MetaProvides::Package/AUTOVIV/:InstallModulesPM' version: '5.043' Dist::Zilla::Role::MetaProvider::Provider: inherit_missing: '1' inherit_version: '1' meta_noindex: '1' name: '@DROLSKY/MetaProvides::Package' version: '2.003001' - class: Dist::Zilla::Plugin::NextRelease name: '@DROLSKY/NextRelease' version: '5.043' - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: test type: requires name: '@DROLSKY/Test::More with subtest' version: '5.043' - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: develop type: requires name: '@DROLSKY/Modules for use with tidyall' version: '5.043' - class: Dist::Zilla::Plugin::PromptIfStale config: Dist::Zilla::Plugin::PromptIfStale: check_all_plugins: 1 check_all_prereqs: 1 modules: [] phase: release skip: - Dist::Zilla::Plugin::DROLSKY::Contributors - Dist::Zilla::Plugin::DROLSKY::License - Dist::Zilla::Plugin::DROLSKY::TidyAll - Dist::Zilla::Plugin::DROLSKY::VersionProvider name: '@DROLSKY/PromptIfStale' version: '0.047' - class: Dist::Zilla::Plugin::ReadmeAnyFromPod config: Dist::Zilla::Role::FileWatcher: version: '0.006' name: '@DROLSKY/README.md in build' version: '0.150250' - class: Dist::Zilla::Plugin::ReadmeAnyFromPod config: Dist::Zilla::Role::FileWatcher: version: '0.006' name: '@DROLSKY/README.md in root' version: '0.150250' - class: Dist::Zilla::Plugin::Test::Pod::Coverage::Configurable name: '@DROLSKY/Test::Pod::Coverage::Configurable' version: '0.05' - class: Dist::Zilla::Plugin::Test::PodSpelling config: Dist::Zilla::Plugin::Test::PodSpelling: directories: [] spell_cmd: '' stopwords: - DROLSKY - "DROLSKY's" - Measham - POSIX - PayPal - Rolsky - Rolsky - "Rolsky's" - STRPTIME - errmsg - formatter - strf - strp - strptime wordlist: Pod::Wordlist name: '@DROLSKY/Test::PodSpelling' version: '2.007000' - class: Dist::Zilla::Plugin::Test::ReportPrereqs name: '@DROLSKY/Test::ReportPrereqs' version: '0.021' - class: Dist::Zilla::Plugin::Test::Version name: '@DROLSKY/Test::Version' version: '1.05' - class: Dist::Zilla::Plugin::ManifestSkip name: '@DROLSKY/ManifestSkip' version: '5.043' - class: Dist::Zilla::Plugin::MetaYAML name: '@DROLSKY/MetaYAML' version: '5.043' - class: Dist::Zilla::Plugin::License name: '@DROLSKY/License' version: '5.043' - class: Dist::Zilla::Plugin::ExtraTests name: '@DROLSKY/ExtraTests' version: '5.043' - class: Dist::Zilla::Plugin::ExecDir name: '@DROLSKY/ExecDir' version: '5.043' - class: Dist::Zilla::Plugin::ShareDir name: '@DROLSKY/ShareDir' version: '5.043' - class: Dist::Zilla::Plugin::Manifest name: '@DROLSKY/Manifest' version: '5.043' - class: Dist::Zilla::Plugin::CheckVersionIncrement name: '@DROLSKY/CheckVersionIncrement' version: '0.121750' - class: Dist::Zilla::Plugin::TestRelease name: '@DROLSKY/TestRelease' version: '5.043' - class: Dist::Zilla::Plugin::ConfirmRelease name: '@DROLSKY/ConfirmRelease' version: '5.043' - class: Dist::Zilla::Plugin::UploadToCPAN name: '@DROLSKY/UploadToCPAN' version: '5.043' - class: Dist::Zilla::Plugin::CheckPrereqsIndexed name: '@DROLSKY/CheckPrereqsIndexed' version: '0.017' - class: Dist::Zilla::Plugin::CPANFile name: '@DROLSKY/CPANFile' version: '5.043' - class: Dist::Zilla::Plugin::DROLSKY::Contributors name: '@DROLSKY/DROLSKY::Contributors' version: '0.40' - class: Dist::Zilla::Plugin::DROLSKY::License name: '@DROLSKY/DROLSKY::License' version: '0.40' - class: Dist::Zilla::Plugin::DROLSKY::TidyAll name: '@DROLSKY/DROLSKY::TidyAll' version: '0.40' - class: Dist::Zilla::Plugin::DROLSKY::VersionProvider name: '@DROLSKY/DROLSKY::VersionProvider' version: '0.40' - class: Dist::Zilla::Plugin::DROLSKY::Git::CheckFor::CorrectBranch config: Dist::Zilla::Role::Git::Repo: repo_root: . name: '@DROLSKY/DROLSKY::Git::CheckFor::CorrectBranch' version: '0.40' - class: Dist::Zilla::Plugin::Git::CheckFor::MergeConflicts config: Dist::Zilla::Role::Git::Repo: repo_root: . name: '@DROLSKY/Git::CheckFor::MergeConflicts' version: '0.013' - class: Dist::Zilla::Plugin::Git::Contributors config: Dist::Zilla::Plugin::Git::Contributors: include_authors: 0 include_releaser: 1 order_by: name paths: - . name: '@DROLSKY/Git::Contributors' version: '0.017' - class: Dist::Zilla::Plugin::InstallGuide name: '@DROLSKY/InstallGuide' version: '1.200006' - class: Dist::Zilla::Plugin::Meta::Contributors name: '@DROLSKY/Meta::Contributors' version: '0.002' - class: Dist::Zilla::Plugin::MetaConfig name: '@DROLSKY/MetaConfig' version: '5.043' - class: Dist::Zilla::Plugin::MetaJSON name: '@DROLSKY/MetaJSON' version: '5.043' - class: Dist::Zilla::Plugin::SurgicalPodWeaver config: Dist::Zilla::Plugin::PodWeaver: finder: - ':InstallModules' - ':ExecFiles' plugins: - class: Pod::Weaver::Plugin::EnsurePod5 name: '@CorePrep/EnsurePod5' version: '4.012' - class: Pod::Weaver::Plugin::H1Nester name: '@CorePrep/H1Nester' version: '4.012' - class: Pod::Weaver::Section::Name name: Name version: '4.012' - class: Pod::Weaver::Section::Version name: Version version: '4.012' - class: Pod::Weaver::Section::Region name: prelude version: '4.012' - class: Pod::Weaver::Section::Generic name: SYNOPSIS version: '4.012' - class: Pod::Weaver::Section::Generic name: DESCRIPTION version: '4.012' - class: Pod::Weaver::Section::Leftovers name: Leftovers version: '4.012' - class: Pod::Weaver::Section::Region name: postlude version: '4.012' - class: Pod::Weaver::Section::Authors name: Authors version: '4.012' - class: Pod::Weaver::Section::Contributors name: Contributors version: '0.009' - class: Pod::Weaver::Section::Legal name: Legal version: '4.012' name: '@DROLSKY/SurgicalPodWeaver' version: '0.0023' - class: Dist::Zilla::Plugin::MojibakeTests name: '@DROLSKY/MojibakeTests' version: '0.8' - class: Dist::Zilla::Plugin::PodSyntaxTests name: '@DROLSKY/PodSyntaxTests' version: '5.043' - class: Dist::Zilla::Plugin::Test::EOL config: Dist::Zilla::Plugin::Test::EOL: filename: xt/author/eol.t finder: - ':InstallModules' - ':ExecFiles' - ':TestFiles' trailing_whitespace: '1' name: '@DROLSKY/Test::EOL' version: '0.18' - class: Dist::Zilla::Plugin::Test::NoTabs config: Dist::Zilla::Plugin::Test::NoTabs: filename: xt/author/no-tabs.t finder: - ':InstallModules' - ':ExecFiles' - ':TestFiles' name: '@DROLSKY/Test::NoTabs' version: '0.15' - class: Dist::Zilla::Plugin::Test::Portability name: '@DROLSKY/Test::Portability' version: '2.000006' - class: Dist::Zilla::Plugin::Test::TidyAll name: '@DROLSKY/Test::TidyAll' version: '0.01' - class: Dist::Zilla::Plugin::Test::Compile config: Dist::Zilla::Plugin::Test::Compile: bail_out_on_fail: '0' fail_on_warning: author fake_home: 0 filename: xt/author/00-compile.t module_finder: - ':InstallModules' needs_display: 0 phase: develop script_finder: - ':PerlExecFiles' skips: [] name: '@DROLSKY/Test::Compile' version: '2.054' - class: Dist::Zilla::Plugin::Git::Check config: Dist::Zilla::Plugin::Git::Check: untracked_files: die Dist::Zilla::Role::Git::DirtyFiles: allow_dirty: - Build.PL - CONTRIBUTING.md - Changes - LICENSE - Makefile.PL - README.md - cpanfile allow_dirty_match: [] changelog: Changes Dist::Zilla::Role::Git::Repo: repo_root: . name: '@DROLSKY/Git::Check' version: '2.036' - class: Dist::Zilla::Plugin::Git::Commit config: Dist::Zilla::Plugin::Git::Commit: add_files_in: [] commit_msg: v%v%n%n%c Dist::Zilla::Role::Git::DirtyFiles: allow_dirty: - Build.PL - CONTRIBUTING.md - Changes - LICENSE - Makefile.PL - README.md - cpanfile allow_dirty_match: [] changelog: Changes Dist::Zilla::Role::Git::Repo: repo_root: . Dist::Zilla::Role::Git::StringFormatter: time_zone: local name: '@DROLSKY/commit generated files' version: '2.036' - class: Dist::Zilla::Plugin::Git::Tag config: Dist::Zilla::Plugin::Git::Tag: branch: ~ changelog: Changes signed: 0 tag: v1.63 tag_format: v%v tag_message: v%v Dist::Zilla::Role::Git::Repo: repo_root: . Dist::Zilla::Role::Git::StringFormatter: time_zone: local name: '@DROLSKY/Git::Tag' version: '2.036' - class: Dist::Zilla::Plugin::Git::Push config: Dist::Zilla::Plugin::Git::Push: push_to: - origin remotes_must_exist: 1 Dist::Zilla::Role::Git::Repo: repo_root: . name: '@DROLSKY/Git::Push' version: '2.036' - class: Dist::Zilla::Plugin::BumpVersionAfterRelease config: Dist::Zilla::Plugin::BumpVersionAfterRelease: finders: - ':ExecFiles' - ':InstallModules' global: 0 munge_makefile_pl: 1 name: '@DROLSKY/BumpVersionAfterRelease' version: '0.012' - class: Dist::Zilla::Plugin::Git::Commit config: Dist::Zilla::Plugin::Git::Commit: add_files_in: [] commit_msg: 'Bump version after release' Dist::Zilla::Role::Git::DirtyFiles: allow_dirty: - Changes - dist.ini allow_dirty_match: - (?^:.+) changelog: Changes Dist::Zilla::Role::Git::Repo: repo_root: . Dist::Zilla::Role::Git::StringFormatter: time_zone: local name: '@DROLSKY/commit version bump' version: '2.036' - class: Dist::Zilla::Plugin::Git::Push config: Dist::Zilla::Plugin::Git::Push: push_to: - origin remotes_must_exist: 1 Dist::Zilla::Role::Git::Repo: repo_root: . name: '@DROLSKY/push version bump' version: '2.036' - class: Dist::Zilla::Plugin::Test::Pod::LinkCheck name: '@DROLSKY/Test::Pod::LinkCheck' version: '1.002' - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: develop type: requires name: DevelopRequires version: '5.043' - class: Dist::Zilla::Plugin::FinderCode name: ':InstallModules' version: '5.043' - class: Dist::Zilla::Plugin::FinderCode name: ':IncModules' version: '5.043' - class: Dist::Zilla::Plugin::FinderCode name: ':TestFiles' version: '5.043' - class: Dist::Zilla::Plugin::FinderCode name: ':ExtraTestFiles' version: '5.043' - class: Dist::Zilla::Plugin::FinderCode name: ':ExecFiles' version: '5.043' - class: Dist::Zilla::Plugin::FinderCode name: ':PerlExecFiles' version: '5.043' - class: Dist::Zilla::Plugin::FinderCode name: ':ShareFiles' version: '5.043' - class: Dist::Zilla::Plugin::FinderCode name: ':MainModule' version: '5.043' - class: Dist::Zilla::Plugin::FinderCode name: ':AllFiles' version: '5.043' - class: Dist::Zilla::Plugin::FinderCode name: ':NoFiles' version: '5.043' - class: Dist::Zilla::Plugin::FinderCode name: '@DROLSKY/MetaProvides::Package/AUTOVIV/:InstallModulesPM' version: '5.043' zilla: class: Dist::Zilla::Dist::Builder config: is_trial: '0' version: '5.043' x_authority: cpan:DROLSKY x_contributors: - 'D. Ilmari Mannsåker ' DateTime-Format-Strptime-1.63/LICENSE0000644000175000017500000002152012645520607017046 0ustar autarchautarchThis software is Copyright (c) 2016 by Dave Rolsky. This is free software, licensed under: The Artistic License 2.0 (GPL Compatible) The Artistic License 2.0 Copyright (c) 2000-2006, The Perl Foundation. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble This license establishes the terms under which a given free software Package may be copied, modified, distributed, and/or redistributed. The intent is that the Copyright Holder maintains some artistic control over the development of that Package while still keeping the Package available as open source and free software. You are always permitted to make arrangements wholly outside of this license directly with the Copyright Holder of a given Package. If the terms of this license do not permit the full use that you propose to make of the Package, you should contact the Copyright Holder and seek a different licensing arrangement. Definitions "Copyright Holder" means the individual(s) or organization(s) named in the copyright notice for the entire Package. "Contributor" means any party that has contributed code or other material to the Package, in accordance with the Copyright Holder's procedures. "You" and "your" means any person who would like to copy, distribute, or modify the Package. "Package" means the collection of files distributed by the Copyright Holder, and derivatives of that collection and/or of those files. A given Package may consist of either the Standard Version, or a Modified Version. "Distribute" means providing a copy of the Package or making it accessible to anyone else, or in the case of a company or organization, to others outside of your company or organization. "Distributor Fee" means any fee that you charge for Distributing this Package or providing support for this Package to another party. It does not mean licensing fees. "Standard Version" refers to the Package if it has not been modified, or has been modified only in ways explicitly requested by the Copyright Holder. "Modified Version" means the Package, if it has been changed, and such changes were not explicitly requested by the Copyright Holder. "Original License" means this Artistic License as Distributed with the Standard Version of the Package, in its current version or as it may be modified by The Perl Foundation in the future. "Source" form means the source code, documentation source, and configuration files for the Package. "Compiled" form means the compiled bytecode, object code, binary, or any other form resulting from mechanical transformation or translation of the Source form. Permission for Use and Modification Without Distribution (1) You are permitted to use the Standard Version and create and use Modified Versions for any purpose without restriction, provided that you do not Distribute the Modified Version. Permissions for Redistribution of the Standard Version (2) You may Distribute verbatim copies of the Source form of the Standard Version of this Package in any medium without restriction, either gratis or for a Distributor Fee, provided that you duplicate all of the original copyright notices and associated disclaimers. At your discretion, such verbatim copies may or may not include a Compiled form of the Package. (3) You may apply any bug fixes, portability changes, and other modifications made available from the Copyright Holder. The resulting Package will still be considered the Standard Version, and as such will be subject to the Original License. Distribution of Modified Versions of the Package as Source (4) You may Distribute your Modified Version as Source (either gratis or for a Distributor Fee, and with or without a Compiled form of the Modified Version) provided that you clearly document how it differs from the Standard Version, including, but not limited to, documenting any non-standard features, executables, or modules, and provided that you do at least ONE of the following: (a) make the Modified Version available to the Copyright Holder of the Standard Version, under the Original License, so that the Copyright Holder may include your modifications in the Standard Version. (b) ensure that installation of your Modified Version does not prevent the user installing or running the Standard Version. In addition, the Modified Version must bear a name that is different from the name of the Standard Version. (c) allow anyone who receives a copy of the Modified Version to make the Source form of the Modified Version available to others under (i) the Original License or (ii) a license that permits the licensee to freely copy, modify and redistribute the Modified Version using the same licensing terms that apply to the copy that the licensee received, and requires that the Source form of the Modified Version, and of any works derived from it, be made freely available in that license fees are prohibited but Distributor Fees are allowed. Distribution of Compiled Forms of the Standard Version or Modified Versions without the Source (5) You may Distribute Compiled forms of the Standard Version without the Source, provided that you include complete instructions on how to get the Source of the Standard Version. Such instructions must be valid at the time of your distribution. If these instructions, at any time while you are carrying out such distribution, become invalid, you must provide new instructions on demand or cease further distribution. If you provide valid instructions or cease distribution within thirty days after you become aware that the instructions are invalid, then you do not forfeit any of your rights under this license. (6) You may Distribute a Modified Version in Compiled form without the Source, provided that you comply with Section 4 with respect to the Source of the Modified Version. Aggregating or Linking the Package (7) You may aggregate the Package (either the Standard Version or Modified Version) with other packages and Distribute the resulting aggregation provided that you do not charge a licensing fee for the Package. Distributor Fees are permitted, and licensing fees for other components in the aggregation are permitted. The terms of this license apply to the use and Distribution of the Standard or Modified Versions as included in the aggregation. (8) You are permitted to link Modified and Standard Versions with other works, to embed the Package in a larger work of your own, or to build stand-alone binary or bytecode versions of applications that include the Package, and Distribute the result without restriction, provided the result does not expose a direct interface to the Package. Items That are Not Considered Part of a Modified Version (9) Works (including, but not limited to, modules and scripts) that merely extend or make use of the Package, do not, by themselves, cause the Package to be a Modified Version. In addition, such works are not considered parts of the Package itself, and are not subject to the terms of this license. General Provisions (10) Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license. (11) If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license. (12) This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder. (13) This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed. (14) Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. DateTime-Format-Strptime-1.63/weaver.ini0000644000175000017500000000024612645520607020035 0ustar autarchautarch[@CorePrep] [Name] [Version] [Region / prelude] [Generic / SYNOPSIS] [Generic / DESCRIPTION] [Leftovers] [Region / postlude] [Authors] [Contributors] [Legal] DateTime-Format-Strptime-1.63/lib/0000775000175000017500000000000012645520607016611 5ustar autarchautarchDateTime-Format-Strptime-1.63/lib/DateTime/0000775000175000017500000000000012645520607020305 5ustar autarchautarchDateTime-Format-Strptime-1.63/lib/DateTime/Format/0000775000175000017500000000000012645520607021535 5ustar autarchautarchDateTime-Format-Strptime-1.63/lib/DateTime/Format/Strptime.pm0000644000175000017500000011713412645520607023707 0ustar autarchautarchpackage DateTime::Format::Strptime; use strict; use warnings; our $VERSION = '1.63'; use Carp qw( carp croak ); use DateTime 1.00; use DateTime::Locale 0.45; use DateTime::TimeZone 0.79; use Params::Validate 1.20 qw( validate SCALAR BOOLEAN OBJECT CODEREF ); use Try::Tiny; use Exporter qw( import ); use Package::DeprecationManager 0.15 -deprecations => { 'accessor writers' => '1.58', }; our @EXPORT_OK = qw( strftime strptime ); use constant PERL_58 => $] < 5.010; { my $spec = { pattern => { type => SCALAR }, time_zone => { type => SCALAR | OBJECT, optional => 1, }, locale => { type => SCALAR | OBJECT, default => DateTime::Locale->load('en'), }, on_error => { type => SCALAR | CODEREF, default => 'undef', callbacks => { 'valid on_error' => sub { return 1 if $_[0] && ( ref $_[0] eq 'CODE' || $_[0] =~ /\A(?:croak|undef)\z/ ); die q{The value supplied to on_error must be either 'croak', 'undef' or a code reference.}; }, }, }, debug => { type => BOOLEAN, default => $ENV{DATETIME_FORMAT_STRPTIME_DEBUG}, }, }; sub new { my $class = shift; my %args = validate( @_, $spec ); if ( $args{locale} && !ref $args{locale} ) { $args{locale} = DateTime::Locale->load( $args{locale} ) or croak "Could not create locale from $args{locale}"; } if ( $args{time_zone} && !ref $args{time_zone} ) { $args{time_zone} = DateTime::TimeZone->new( name => $args{time_zone} ) or croak "Could not create time zone from $args{time_zone}"; } my $self = bless { %args, zone_map => $class->_build_zone_map, }, $class; # Forces a check that the pattern is valid $self->_parser; binmode STDERR, ':encoding(UTF-8)' if $self->{debug}; return $self; } } { my %zone_map = ( 'A' => '+0100', 'ACDT' => '+1030', 'ACST' => '+0930', 'ADT' => undef, 'AEDT' => '+1100', 'AES' => '+1000', 'AEST' => '+1000', 'AFT' => '+0430', 'AHDT' => '-0900', 'AHST' => '-1000', 'AKDT' => '-0800', 'AKST' => '-0900', 'AMST' => '+0400', 'AMT' => '+0400', 'ANAST' => '+1300', 'ANAT' => '+1200', 'ART' => '-0300', 'AST' => undef, 'AT' => '-0100', 'AWST' => '+0800', 'AZOST' => '+0000', 'AZOT' => '-0100', 'AZST' => '+0500', 'AZT' => '+0400', 'B' => '+0200', 'BADT' => '+0400', 'BAT' => '+0600', 'BDST' => '+0200', 'BDT' => '+0600', 'BET' => '-1100', 'BNT' => '+0800', 'BORT' => '+0800', 'BOT' => '-0400', 'BRA' => '-0300', 'BST' => undef, 'BT' => undef, 'BTT' => '+0600', 'C' => '+0300', 'CAST' => '+0930', 'CAT' => undef, 'CCT' => undef, 'CDT' => undef, 'CEST' => '+0200', 'CET' => '+0100', 'CETDST' => '+0200', 'CHADT' => '+1345', 'CHAST' => '+1245', 'CKT' => '-1000', 'CLST' => '-0300', 'CLT' => '-0400', 'COT' => '-0500', 'CST' => undef, 'CSuT' => '+1030', 'CUT' => '+0000', 'CVT' => '-0100', 'CXT' => '+0700', 'ChST' => '+1000', 'D' => '+0400', 'DAVT' => '+0700', 'DDUT' => '+1000', 'DNT' => '+0100', 'DST' => '+0200', 'E' => '+0500', 'EASST' => '-0500', 'EAST' => undef, 'EAT' => '+0300', 'ECT' => undef, 'EDT' => undef, 'EEST' => '+0300', 'EET' => '+0200', 'EETDST' => '+0300', 'EGST' => '+0000', 'EGT' => '-0100', 'EMT' => '+0100', 'EST' => undef, 'ESuT' => '+1100', 'F' => '+0600', 'FDT' => undef, 'FJST' => '+1300', 'FJT' => '+1200', 'FKST' => '-0300', 'FKT' => '-0400', 'FST' => undef, 'FWT' => '+0100', 'G' => '+0700', 'GALT' => '-0600', 'GAMT' => '-0900', 'GEST' => '+0500', 'GET' => '+0400', 'GFT' => '-0300', 'GILT' => '+1200', 'GMT' => '+0000', 'GST' => undef, 'GT' => '+0000', 'GYT' => '-0400', 'GZ' => '+0000', 'H' => '+0800', 'HAA' => '-0300', 'HAC' => '-0500', 'HAE' => '-0400', 'HAP' => '-0700', 'HAR' => '-0600', 'HAT' => '-0230', 'HAY' => '-0800', 'HDT' => '-0930', 'HFE' => '+0200', 'HFH' => '+0100', 'HG' => '+0000', 'HKT' => '+0800', 'HL' => 'local', 'HNA' => '-0400', 'HNC' => '-0600', 'HNE' => '-0500', 'HNP' => '-0800', 'HNR' => '-0700', 'HNT' => '-0330', 'HNY' => '-0900', 'HOE' => '+0100', 'HST' => '-1000', 'I' => '+0900', 'ICT' => '+0700', 'IDLE' => '+1200', 'IDLW' => '-1200', 'IDT' => undef, 'IOT' => '+0500', 'IRDT' => '+0430', 'IRKST' => '+0900', 'IRKT' => '+0800', 'IRST' => '+0430', 'IRT' => '+0330', 'IST' => undef, 'IT' => '+0330', 'ITA' => '+0100', 'JAVT' => '+0700', 'JAYT' => '+0900', 'JST' => '+0900', 'JT' => '+0700', 'K' => '+1000', 'KDT' => '+1000', 'KGST' => '+0600', 'KGT' => '+0500', 'KOST' => '+1200', 'KRAST' => '+0800', 'KRAT' => '+0700', 'KST' => '+0900', 'L' => '+1100', 'LHDT' => '+1100', 'LHST' => '+1030', 'LIGT' => '+1000', 'LINT' => '+1400', 'LKT' => '+0600', 'LST' => 'local', 'LT' => 'local', 'M' => '+1200', 'MAGST' => '+1200', 'MAGT' => '+1100', 'MAL' => '+0800', 'MART' => '-0930', 'MAT' => '+0300', 'MAWT' => '+0600', 'MDT' => '-0600', 'MED' => '+0200', 'MEDST' => '+0200', 'MEST' => '+0200', 'MESZ' => '+0200', 'MET' => undef, 'MEWT' => '+0100', 'MEX' => '-0600', 'MEZ' => '+0100', 'MHT' => '+1200', 'MMT' => '+0630', 'MPT' => '+1000', 'MSD' => '+0400', 'MSK' => '+0300', 'MSKS' => '+0400', 'MST' => '-0700', 'MT' => '+0830', 'MUT' => '+0400', 'MVT' => '+0500', 'MYT' => '+0800', 'N' => '-0100', 'NCT' => '+1100', 'NDT' => '-0230', 'NFT' => undef, 'NOR' => '+0100', 'NOVST' => '+0700', 'NOVT' => '+0600', 'NPT' => '+0545', 'NRT' => '+1200', 'NST' => undef, 'NSUT' => '+0630', 'NT' => '-1100', 'NUT' => '-1100', 'NZDT' => '+1300', 'NZST' => '+1200', 'NZT' => '+1200', 'O' => '-0200', 'OESZ' => '+0300', 'OEZ' => '+0200', 'OMSST' => '+0700', 'OMST' => '+0600', 'OZ' => 'local', 'P' => '-0300', 'PDT' => '-0700', 'PET' => '-0500', 'PETST' => '+1300', 'PETT' => '+1200', 'PGT' => '+1000', 'PHOT' => '+1300', 'PHT' => '+0800', 'PKT' => '+0500', 'PMDT' => '-0200', 'PMT' => '-0300', 'PNT' => '-0830', 'PONT' => '+1100', 'PST' => undef, 'PWT' => '+0900', 'PYST' => '-0300', 'PYT' => '-0400', 'Q' => '-0400', 'R' => '-0500', 'R1T' => '+0200', 'R2T' => '+0300', 'RET' => '+0400', 'ROK' => '+0900', 'S' => '-0600', 'SADT' => '+1030', 'SAST' => undef, 'SBT' => '+1100', 'SCT' => '+0400', 'SET' => '+0100', 'SGT' => '+0800', 'SRT' => '-0300', 'SST' => undef, 'SWT' => '+0100', 'T' => '-0700', 'TFT' => '+0500', 'THA' => '+0700', 'THAT' => '-1000', 'TJT' => '+0500', 'TKT' => '-1000', 'TMT' => '+0500', 'TOT' => '+1300', 'TRUT' => '+1000', 'TST' => '+0300', 'TUC ' => '+0000', 'TVT' => '+1200', 'U' => '-0800', 'ULAST' => '+0900', 'ULAT' => '+0800', 'USZ1' => '+0200', 'USZ1S' => '+0300', 'USZ3' => '+0400', 'USZ3S' => '+0500', 'USZ4' => '+0500', 'USZ4S' => '+0600', 'USZ5' => '+0600', 'USZ5S' => '+0700', 'USZ6' => '+0700', 'USZ6S' => '+0800', 'USZ7' => '+0800', 'USZ7S' => '+0900', 'USZ8' => '+0900', 'USZ8S' => '+1000', 'USZ9' => '+1000', 'USZ9S' => '+1100', 'UTZ' => '-0300', 'UYT' => '-0300', 'UZ10' => '+1100', 'UZ10S' => '+1200', 'UZ11' => '+1200', 'UZ11S' => '+1300', 'UZ12' => '+1200', 'UZ12S' => '+1300', 'UZT' => '+0500', 'V' => '-0900', 'VET' => '-0400', 'VLAST' => '+1100', 'VLAT' => '+1000', 'VTZ' => '-0200', 'VUT' => '+1100', 'W' => '-1000', 'WAKT' => '+1200', 'WAST' => undef, 'WAT' => '+0100', 'WEST' => '+0100', 'WESZ' => '+0100', 'WET' => '+0000', 'WETDST' => '+0100', 'WEZ' => '+0000', 'WFT' => '+1200', 'WGST' => '-0200', 'WGT' => '-0300', 'WIB' => '+0700', 'WIT' => '+0900', 'WITA' => '+0800', 'WST' => undef, 'WTZ' => '-0100', 'WUT' => '+0100', 'X' => '-1100', 'Y' => '-1200', 'YAKST' => '+1000', 'YAKT' => '+0900', 'YAPT' => '+1000', 'YDT' => '-0800', 'YEKST' => '+0600', 'YEKT' => '+0500', 'YST' => '-0900', 'Z' => '+0000', 'UTC' => '+0000', ); sub _build_zone_map { return \%zone_map; } } sub parse_datetime { my $self = shift; my $string = shift; my $parser = $self->_parser; if ( $self->{debug} ) { warn "Regex for $self->{pattern}: $parser->{regex}\n"; warn "Fields: @{$parser->{fields}}\n"; } my @matches = ( $string =~ $parser->{regex} ); unless (@matches) { my $msg = 'Your datetime does not match your pattern'; if ( $self->{debug} ) { $msg .= qq{ - string = "$string" - regex = $parser->{regex}}; } $msg .= q{.}; $self->_our_croak($msg); return; } my %args; my $i = 0; for my $f ( @{ $parser->{fields} } ) { unless ( defined $matches[$i] ) { die "Something horrible happened - the string matched $parser->{regex}" . " but did not return the expected fields: [@{$parser->{fields}}]"; } $args{$f} = $matches[ $i++ ]; } # We need to copy the %args here because _munge_args will delete keys in # order to turn this into something that can be passed to a DateTime # constructor. my ( $constructor, $args ) = $self->_munge_args( {%args} ) or return; my $dt = try { DateTime->$constructor($args) }; $self->_our_croak('Parsed values did not produce a valid date') unless $dt; return unless $dt && $self->_check_dt( $dt, \%args ); $dt->set_time_zone( $self->{time_zone} ) if $self->{time_zone}; return $dt; } sub _parser { my $self = shift; return $self->{parser} ||= $self->_build_parser; } sub _build_parser { my $self = shift; my ( $replacement_tokens_re, $replacements, $pattern_tokens_re, $patterns, ) = $self->_parser_pieces; my $pattern = $self->{pattern}; # When the first replacement is a glibc pattern, the first round of # replacements may simply replace one replacement token (like %X) with # another replacement token (like %I). $pattern =~ s/%($replacement_tokens_re)/$replacements->{$1}/g for 1 .. 2; if ( $self->{debug} && $pattern ne $self->{pattern} ) { warn "Pattern after replacement substitution: $pattern\n"; } my $regex; my @fields; my @postprocess; while ( $pattern =~ / \G %($pattern_tokens_re) | %([1-9]?)(N) | (%[0-9]*[a-zA-Z]) | ([^%]+) /xg ) { # Using \G in the regex match fails for some reason on Perl 5.8, so we # do this hack instead. substr( $pattern, 0, pos $pattern, q{} ) if PERL_58; if ($1) { my $p = $patterns->{$1} or croak "Unidentified token in pattern: $1 in $self->{pattern}"; if ( $p->{field} ) { $regex .= qr/($p->{regex})/; push @fields, $p->{field}; } else { $regex .= qr/$p->{regex}/; } } elsif ($3) { $regex .= $2 ? qr/([0-9]{$2})/ : qr/([0-9]+)/; push @fields, 'nanosecond'; } elsif ($4) { croak qq{Pattern contained an unrecognized strptime token, "$4"}; } else { $regex .= qr/\Q$5/; } } return { regex => qr/\A\s*$regex/, fields => \@fields, }; } { my $d = qr/(?:[0-9])/; my $one_or_two_digits = qr/[0-9 ]?$d/; # These patterns are all locale-independent. There are a few that depend # on the locale, and must be re-calculated for each new parser object. my %universal_patterns = ( '%' => { regex => qr/%/, }, C => { regex => $one_or_two_digits, field => 'century', }, d => { regex => $one_or_two_digits, field => 'day', }, g => { regex => $one_or_two_digits, field => 'iso_week_year_100', }, G => { regex => qr/$d{4}/, field => 'iso_week_year', }, H => { regex => $one_or_two_digits, field => 'hour', }, I => { regex => $one_or_two_digits, field => 'hour_12', }, j => { regex => qr/$d{1,3}/, field => 'day_of_year', }, m => { regex => $one_or_two_digits, field => 'month', }, M => { regex => $one_or_two_digits, field => 'minute', }, n => { regex => qr/\s+/, }, O => { regex => qr{[a-zA-Z_]+(?:/[a-zA-Z_]+(?:/[a-zA-Z_]+)?)?}, field => 'time_zone_name', }, s => { regex => qr/$d+/, field => 'epoch', }, S => { regex => $one_or_two_digits, field => 'second', }, U => { regex => $one_or_two_digits, field => 'week_sun_0', }, u => { regex => $one_or_two_digits, field => 'day_of_week', }, w => { regex => $one_or_two_digits, field => 'day_of_week_sun_0', }, W => { regex => $one_or_two_digits, field => 'week_mon_1', }, y => { regex => $one_or_two_digits, field => 'year_100', }, Y => { regex => qr/$d{4}/, field => 'year', }, z => { regex => qr/[+-]$d{4}/, field => 'time_zone_offset', }, Z => { regex => qr/[a-zA-Z]{1,6}/, field => 'time_zone_abbreviation', }, ); $universal_patterns{e} = $universal_patterns{d}; $universal_patterns{k} = $universal_patterns{H}; $universal_patterns{l} = $universal_patterns{I}; $universal_patterns{t} = $universal_patterns{n}; my %universal_replacements = ( D => '%m/%d/%y', F => '%Y-%m-%d', r => '%I:%M:%S %p', R => '%H:%M', T => '%H:%M:%S', ); sub _parser_pieces { my $self = shift; my %replacements = %universal_replacements; $replacements{c} = $self->{locale}->glibc_datetime_format; $replacements{x} = $self->{locale}->glibc_date_format; $replacements{X} = $self->{locale}->glibc_time_format; my %patterns = %universal_patterns; $patterns{a} = $patterns{A} = { regex => do { my $days = join '|', map {quotemeta} sort { ( length $b <=> length $a ) or ( $a cmp $b ) } keys %{ $self->_locale_days }; qr/$days/i; }, field => 'day_name', }; $patterns{b} = $patterns{B} = $patterns{h} = { regex => do { my $months = join '|', map {quotemeta} sort { ( length $b <=> length $a ) or ( $a cmp $b ) } keys %{ $self->_locale_months }; qr/$months/i; }, field => 'month_name', }; $patterns{p} = $patterns{P} = { regex => do { my $am_pm = join '|', map {quotemeta} sort { ( length $b <=> length $a ) or ( $a cmp $b ) } @{ $self->{locale}->am_pm_abbreviated }; qr/$am_pm/i; }, field => 'am_pm', }; return ( $self->_token_re_for( keys %replacements ), \%replacements, $self->_token_re_for( keys %patterns ), \%patterns, ); } } sub _locale_days { my $self = shift; return $self->{locale_days} if $self->{locale_days}; my $wide = $self->{locale}->day_format_wide; my $abbr = $self->{locale}->day_format_abbreviated; my %locale_days; for my $i ( 0 .. 6 ) { $locale_days{ lc $wide->[$i] } = $i; $locale_days{ lc $abbr->[$i] } = $i; } return $self->{locale_days} ||= \%locale_days; } sub _locale_months { my $self = shift; return $self->{locale_months} if $self->{locale_months}; my $wide = $self->{locale}->month_format_wide; my $abbr = $self->{locale}->month_format_abbreviated; my %locale_months; for my $i ( 0 .. 11 ) { $locale_months{ lc $wide->[$i] } = $i + 1; $locale_months{ lc $abbr->[$i] } = $i + 1; } return $self->{locale_months} ||= \%locale_months; } sub _token_re_for { shift; my $t = join '|', sort { ( length $b <=> length $a ) or ( $a cmp $b ) } @_; return qr/$t/; } { # These are fields we parse that cannot be passed to a DateTime # constructor my @non_dt_keys = qw( am_pm century day_name day_of_week day_of_week_sun_0 hour_12 iso_week_year iso_week_year_100 month_name time_zone_abbreviation time_zone_name time_zone_offset week_mon_1 week_sun_0 year_100 ); sub _munge_args { my $self = shift; my $args = shift; if ( defined $args->{month_name} ) { my $num = $self->_locale_months->{ lc $args->{month_name} } or die "We somehow parsed a month name ($args->{month_name})" . ' that does not correspond to any month in this locale!'; $args->{month} = $num; } if ( defined $args->{am_pm} && defined $args->{hour_12} ) { my ( $am, $pm ) = @{ $self->{locale}->am_pm_abbreviated }; $args->{hour} = $args->{hour_12}; if ( lc $args->{am_pm} eq lc $am ) { $args->{hour} = 0 if $args->{hour} == 12; } else { $args->{hour} += 12 unless $args->{hour} == 12; } } elsif ( defined $args->{hour_12} ) { $self->_our_croak( qq{Parsed a 12-hour based hour, "$args->{hour_12}",} . ' but the pattern does not include an AM/PM specifier' ); return; } if ( defined $args->{year_100} ) { if ( defined $args->{century} ) { $args->{year} = $args->{year_100} + ( $args->{century} * 100 ); } else { $args->{year} = $args->{year_100} + ( $args->{year_100} >= 69 ? 1900 : 2000 ); } } if ( $args->{time_zone_offset} ) { $args->{time_zone} = DateTime::TimeZone->new( name => $args->{time_zone_offset} ); } if ( defined $args->{time_zone_abbreviation} ) { my $abbr = $args->{time_zone_abbreviation}; unless ( exists $self->{zone_map}{$abbr} ) { $self->_our_croak( qq{Parsed an unrecognized time zone abbreviation, "$args->{time_zone_abbreviation}"} ); return; } if ( !defined $self->{zone_map}{$abbr} ) { $self->_our_croak( qq{The time zone abbreviation that was parsed is ambiguous, "$args->{time_zone_abbreviation}"} ); return; } $args->{time_zone} = DateTime::TimeZone->new( name => $self->{zone_map}{$abbr} ); } else { $args->{time_zone} ||= 'floating'; } if ( $args->{time_zone_name} ) { my $name = $args->{time_zone_name}; my $tz; unless ( $tz = try { DateTime::TimeZone->new( name => $name ) } ) { $name = lc $name; $name =~ s{(^|[/_])(.)}{$1\U$2}g; } $tz = try { DateTime::TimeZone->new( name => $name ) }; unless ($tz) { $self->_our_croak( qq{The Olson time zone name that was parsed does not appear to be valid, "$args->{time_zone_name}"} ); return; } $args->{time_zone} = $tz if $tz; } delete @{$args}{@non_dt_keys}; $args->{locale} = $self->{locale}; for my $k ( grep { defined $args->{$_} } qw( month day hour minute second nanosecond ) ) { $args->{$k} =~ s/^\s+//; } # If we parsed "12345" we treat it as "123450000" but if we parsed # "000123456" we treat it as 123,456 nanoseconds. This is all a bit # weird and confusing but it matches how this module has always # worked. $args->{nanosecond} *= 10**( 9 - length $args->{nanosecond} ) if defined $args->{nanosecond} && length $args->{nanosecond} != 9; for my $k (qw( year month day )) { $args->{$k} = 1 unless defined $args->{$k}; } if ( defined $args->{epoch} ) { $args->{epoch} .= q{.} . $args->{nanosecond} if defined $args->{nanosecond}; delete @{$args}{ qw( day_of_year year month day hour minute second nanosecond ) }; return ( 'from_epoch', $args ); } elsif ( $args->{day_of_year} ) { delete @{$args}{qw( epoch month day )}; return ( 'from_day_of_year', $args ); } return ( 'new', $args ); } } sub _check_dt { my $self = shift; my $dt = shift; my $args = shift; my $is_am = defined $args->{am_pm} && lc $args->{am_pm} eq lc $self->{locale}->am_pm_abbreviated->[0]; if ( defined $args->{hour} && defined $args->{hour_12} ) { unless ( ( $args->{hour} % 12 ) == $args->{hour_12} ) { $self->_our_croak( 'Parsed an input with 24-hour and 12-hour time values that do not match' . qq{ - "$args->{hour}" versus "$args->{hour_12}"} ); return; } } if ( defined $args->{hour} && defined $args->{am_pm} ) { if ( ( $is_am && $args->{hour} >= 12 ) || ( !$is_am && $args->{hour} < 12 ) ) { $self->_our_croak( 'Parsed an input with 24-hour and AM/PM values that do not match' . qq{ - "$args->{hour}" versus "$args->{am_pm}"} ); return; } } if ( defined $args->{year} && defined $args->{century} ) { unless ( int( $args->{year} / 100 ) == $args->{century} ) { $self->_our_croak( 'Parsed an input with year and century values that do not match' . qq{ - "$args->{year}" versus "$args->{century}"} ); return; } } if ( defined $args->{year} && defined $args->{year_100} ) { unless ( ( $args->{year} % 100 ) == $args->{year_100} ) { $self->_our_croak( 'Parsed an input with year and year-within-century values that do not match' . qq{ - "$args->{year}" versus "$args->{year_100}"} ); return; } } if ( defined $args->{time_zone_abbreviation} && defined $args->{time_zone_offset} ) { unless ( $self->{zone_map}{ $args->{time_zone_abbreviation} } && $self->{zone_map}{ $args->{time_zone_abbreviation} } eq $args->{time_zone_offset} ) { $self->_our_croak( 'Parsed an input with time zone abbreviation and time zone offset values that do not match' . qq{ - "$args->{time_zone_abbreviation}" versus "$args->{time_zone_offset}"} ); return; } } if ( defined $args->{epoch} ) { for my $key ( qw( year month day minute hour second hour_12 day_of_year )) { if ( defined $args->{$key} && $dt->$key != $args->{$key} ) { my $print_key = $key eq 'hour_12' ? 'hour (1-12)' : $key eq 'day_of_year' ? 'day of year' : $key; $self->_our_croak( "Parsed an input with epoch and $print_key values that do not match" . qq{ - "$args->{epoch}" versus "$args->{$key}"} ); return; } } } if ( defined $args->{month} && defined $args->{day_of_year} ) { unless ( $dt->month == $args->{month} ) { $self->_our_croak( 'Parsed an input with month and day of year values that do not match' . qq{ - "$args->{month}" versus "$args->{day_of_year}"} ); return; } } if ( defined $args->{day_name} ) { my $dow = $self->_locale_days->{ lc $args->{day_name} }; defined $dow or die "We somehow parsed a day name ($args->{day_name})" . ' that does not correspond to any day in this locale!'; unless ( $dt->day_of_week_0 == $dow ) { $self->_our_croak( 'Parsed an input where the day name does not match the date' . qq{ - "$args->{day_name}" versus "} . $dt->ymd . q{"} ); return; } } if ( defined $args->{day_of_week} ) { unless ( $dt->day_of_week == $args->{day_of_week} ) { $self->_our_croak( 'Parsed an input where the day of week does not match the date' . qq{ - "$args->{day_of_week}" versus "} . $dt->ymd . q{"} ); return; } } if ( defined $args->{day_of_week_sun_0} ) { unless ( ( $dt->day_of_week % 7 ) == $args->{day_of_week_sun_0} ) { $self->_our_croak( 'Parsed an input where the day of week (Sunday as 0) does not match the date' . qq{ - "$args->{day_of_week_sun_0}" versus "} . $dt->ymd . q{"} ); return; } } if ( defined $args->{iso_week_year} ) { unless ( $dt->week_year == $args->{iso_week_year} ) { $self->_our_croak( 'Parsed an input where the ISO week year does not match the date' . qq{ - "$args->{iso_week_year}" versus "} . $dt->ymd . q{"} ); return; } } if ( defined $args->{iso_week_year_100} ) { unless ( ( 0 + substr( $dt->week_year, -2 ) ) == $args->{iso_week_year_100} ) { $self->_our_croak( 'Parsed an input where the ISO week year (without century) does not match the date' . qq{ - "$args->{iso_week_year_100}" versus "} . $dt->ymd . q{"} ); return; } } if ( defined $args->{week_mon_1} ) { unless ( ( 0 + $dt->strftime('%W') ) == $args->{week_mon_1} ) { $self->_our_croak( 'Parsed an input where the ISO week number (Monday starts week) does not match the date' . qq{ - "$args->{week_mon_1}" versus "} . $dt->ymd . q{"} ); return; } } if ( defined $args->{week_sun_0} ) { unless ( ( 0 + $dt->strftime('%U') ) == $args->{week_sun_0} ) { $self->_our_croak( 'Parsed an input where the ISO week number (Sunday starts week) does not match the date' . qq{ - "$args->{week_sun_0}" versus "} . $dt->ymd . q{"} ); return; } } return 1; } sub pattern { my $self = shift; if (@_) { my $pattern = shift; deprecated( feature => 'accessor writers', message => 'Calling pattern() as a writer is deprecated.', ); my $new; try { $new = $self->_clone_with( pattern => $pattern ); } catch { $self->_our_carp($_); } return unless $new; %{$self} = %{$new}; } return $self->{pattern}; } sub locale { my $self = shift; if (@_) { my $locale = shift; deprecated( feature => 'accessor writers', message => 'Calling locale() as a writer is deprecated.', ); my $new; try { $new = $self->_clone_with( locale => $locale ); } catch { $self->_our_carp($_); } return unless $new; %{$self} = %{$new}; } return $self->{locale}->can('code') ? $self->{locale}->code : $self->{locale}->id; } sub time_zone { my $self = shift; if (@_) { my $time_zone = shift; deprecated( feature => 'accessor writers', message => 'Calling time_zone() as a writer is deprecated.', ); my $new; try { $new = $self->_clone_with( time_zone => $time_zone ); } catch { $self->_our_carp($_); } return unless $new; %{$self} = %{$new}; } return $self->{time_zone}->name; } # Only used for deprecated accessors-as-writers feature sub _clone_with { my $self = shift; return ( ref $self )->new( pattern => $self->{pattern}, locale => $self->{locale}, ( $self->{time_zone} ? ( time_zone => $self->{time_zone} ) : () ), on_error => $self->{on_error}, debug => $self->{debug}, @_, ); } sub parse_duration { croak q{DateTime::Format::Strptime doesn't do durations.}; } sub format_datetime { my $self = shift; my $dt = shift; my $pattern = $self->pattern; $pattern =~ s/%O/$dt->time_zone->name/eg; return $dt->clone->set_locale( $self->locale )->strftime($pattern); } sub format_duration { croak q{DateTime::Format::Strptime doesn't do durations.}; } sub _our_croak { my $self = shift; my $error = shift; return $self->{on_error}->( $self, $error ) if ref $self->{on_error}; croak $error if $self->{on_error} eq 'croak'; $self->{errmsg} = $error; return; } sub _our_carp { my $self = shift; my $error = shift; return $self->{on_error}->( $self, $error ) if ref $self->{on_error}; carp $error if $self->{on_error} eq 'croak'; $self->{errmsg} = $error; return; } sub errmsg { $_[0]->{errmsg}; } # Exportable functions: sub strftime { my ( $pattern, $dt ) = @_; return DateTime::Format::Strptime->new( pattern => $pattern, on_error => 'croak' )->format_datetime($dt); } sub strptime { my ( $pattern, $time_string ) = @_; return DateTime::Format::Strptime->new( pattern => $pattern, on_error => 'croak' )->parse_datetime($time_string); } 1; # ABSTRACT: Parse and format strp and strf time patterns __END__ =pod =head1 NAME DateTime::Format::Strptime - Parse and format strp and strf time patterns =head1 VERSION version 1.63 =head1 SYNOPSIS use DateTime::Format::Strptime; my $strp = DateTime::Format::Strptime->new( pattern => '%T', locale => 'en_AU', time_zone => 'Australia/Melbourne', ); my $dt = $strp->parse_datetime('23:16:42'); $strp->format_datetime($dt); # 23:16:42 # Croak when things go wrong: my $strp = DateTime::Format::Strptime->new( pattern => '%T', locale => 'en_AU', time_zone => 'Australia/Melbourne', on_error => 'croak', ); # Will throw an exception $newpattern = $strp->pattern('%Q'); # Do something else when things go wrong: my $strp = DateTime::Format::Strptime->new( pattern => '%T', locale => 'en_AU', time_zone => 'Australia/Melbourne', on_error => \&phone_police, ); =head1 DESCRIPTION This module implements most of C, the POSIX function that is the reverse of C, for C. While C takes a C and a pattern and returns a string, C takes a string and a pattern and returns the C object associated. =encoding UTF-8 =for Pod::Coverage parse_duration format_duration =head1 METHODS This class offers the following methods. =head2 DateTime::Format::Strptime->new(%args) This methods creates a new object. It accepts the following arguments: =over 4 =item * pattern This is the pattern to use for parsing. This is required. =item * time_zone The default time zone to use for objects returned from parsing. =item * locale The locale to use for objects returned from parsing. =item * on_error This can be one of C<'undef'> (the string, not an C), 'croak', or a subroutine reference. =over 8 =item * 'undef' This is the default behavior. The module will return C on errors. The error can be accessed using the C<< $object->errmsg >> method. This is the ideal behaviour for interactive use where a user might provide an illegal pattern or a date that doesn't match the pattern. =item * 'croak' The module will croak with an error message on errors. =item * sub{...} or \&subname When given a code ref, the module will call that sub on errors. The sub receives two parameters: the object and the error message. If your sub does not die, then the formatter will continue on as if C was C<'undef'>. =back =back =head2 $strptime->parse_datetime($string) Given a string in the pattern specified in the constructor, this method will return a new C object. If given a string that doesn't match the pattern, the formatter will croak or return undef, depending on the setting of C in the constructor. =head2 $strptime->format_datetime($datetime) Given a C object, this methods returns a string formatted in the object's format. This method is synonymous with C's strftime method. =head2 $strptime->locale This method returns the locale passed to the object's constructor. =head2 $strptime->pattern This method returns the pattern passed to the object's constructor. =head2 $strptime->time_zone This method returns the time zone passed to the object's constructor. =head2 $strptime->errmsg If the on_error behavior of the object is 'undef', you can retrieve error messages with this method so you can work out why things went wrong. =head1 EXPORTS These subs are available as optional exports. =head2 strptime( $strptime_pattern, $string ) Given a pattern and a string this function will return a new C object. =head2 strftime( $strftime_pattern, $datetime ) Given a pattern and a C object this function will return a formatted string. =head1 STRPTIME PATTERN TOKENS The following tokens are allowed in the pattern string for strptime (parse_datetime): =over 4 =item * %% The % character. =item * %a or %A The weekday name according to the current locale, in abbreviated form or the full name. =item * %b or %B or %h The month name according to the current locale, in abbreviated form or the full name. =item * %C The century number (0-99). =item * %d or %e The day of month (01-31). This will parse single digit numbers as well. =item * %D Equivalent to %m/%d/%y. (This is the American style date, very confusing to non-Americans, especially since %d/%m/%y is widely used in Europe. The ISO 8601 standard pattern is %F.) =item * %F Equivalent to %Y-%m-%d. (This is the ISO style date) =item * %g The year corresponding to the ISO week number, but without the century (0-99). =item * %G The 4-digit year corresponding to the ISO week number. =item * %H The hour (00-23). This will parse single digit numbers as well. =item * %I The hour on a 12-hour clock (1-12). =item * %j The day number in the year (1-366). =item * %m The month number (01-12). This will parse single digit numbers as well. =item * %M The minute (00-59). This will parse single digit numbers as well. =item * %n Arbitrary whitespace. =item * %N Nanoseconds. For other sub-second values use C<%[number]N>. =item * %p The equivalent of AM or PM according to the locale in use. (See L) =item * %r Equivalent to %I:%M:%S %p. =item * %R Equivalent to %H:%M. =item * %s Number of seconds since the Epoch. =item * %S The second (0-60; 60 may occur for leap seconds. See L). =item * %t Arbitrary whitespace. =item * %T Equivalent to %H:%M:%S. =item * %U The week number with Sunday the first day of the week (0-53). The first Sunday of January is the first day of week 1. =item * %u The weekday number (1-7) with Monday = 1. This is the C standard. =item * %w The weekday number (0-6) with Sunday = 0. =item * %W The week number with Monday the first day of the week (0-53). The first Monday of January is the first day of week 1. =item * %y The year within century (0-99). When a century is not otherwise specified (with a value for %C), values in the range 69-99 refer to years in the twentieth century (1969-1999); values in the range 00-68 refer to years in the twenty-first century (2000-2068). =item * %Y A 4-digit year, including century (for example, 1991). =item * %z An RFC-822/ISO 8601 standard time zone specification. (For example +1100) [See note below] =item * %Z The timezone name. (For example EST -- which is ambiguous) [See note below] =item * %O This extended token allows the use of Olson Time Zone names to appear in parsed strings. B: This pattern cannot be passed to C's C method, but can be passed to C. =back =head1 AUTHOR EMERITUS This module was created by Rick Measham. =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 SEE ALSO C mailing list. http://datetime.perl.org/ L, L, L, L =head1 AUTHORS =over 4 =item * Dave Rolsky =item * Rick Measham =back =head1 CONTRIBUTOR =for stopwords D. Ilmari Mannsåker D. Ilmari Mannsåker =head1 COPYRIGHT AND LICENSE This software is Copyright (c) 2016 by Dave Rolsky. This is free software, licensed under: The Artistic License 2.0 (GPL Compatible) =cut DateTime-Format-Strptime-1.63/META.json0000644000175000017500000006514712645520607017477 0ustar autarchautarch{ "abstract" : "Parse and format strp and strf time patterns", "author" : [ "Dave Rolsky ", "Rick Measham " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 5.043, CPAN::Meta::Converter version 2.150005", "license" : [ "artistic_2" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "DateTime-Format-Strptime", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "develop" : { "requires" : { "Code::TidyAll" : "0.24", "File::Spec" : "0", "IO::Handle" : "0", "IPC::Open3" : "0", "Perl::Critic" : "1.123", "Perl::Tidy" : "20140711", "Pod::Coverage::TrustPod" : "0", "Test::Code::TidyAll" : "0.24", "Test::EOL" : "0", "Test::Fatal" : "0", "Test::Mojibake" : "0", "Test::More" : "0.96", "Test::NoTabs" : "0", "Test::Pod" : "1.41", "Test::Pod::Coverage" : "1.08", "Test::Pod::LinkCheck" : "0", "Test::Spelling" : "0.12", "Test::Version" : "1" } }, "runtime" : { "requires" : { "Carp" : "0", "DateTime" : "1.00", "DateTime::Locale" : "0.45", "DateTime::TimeZone" : "0.79", "Exporter" : "0", "JSON::PP" : "2.27300", "Package::DeprecationManager" : "0.15", "Params::Validate" : "1.20", "Try::Tiny" : "0", "constant" : "0", "strict" : "0", "warnings" : "0" } }, "test" : { "recommends" : { "CPAN::Meta" : "2.120900" }, "requires" : { "ExtUtils::MakeMaker" : "0", "File::Spec" : "0", "Test::Builder" : "0", "Test::Fatal" : "0", "Test::More" : "0.96", "Test::Warnings" : "0", "lib" : "0", "utf8" : "0" } } }, "provides" : { "DateTime::Format::Strptime" : { "file" : "lib/DateTime/Format/Strptime.pm", "version" : "1.63" } }, "release_status" : "stable", "resources" : { "bugtracker" : { "mailto" : "bug-datetime-format-strptime@rt.cpan.org", "web" : "http://rt.cpan.org/Public/Dist/Display.html?Name=DateTime-Format-Strptime" }, "homepage" : "http://metacpan.org/release/DateTime-Format-Strptime", "repository" : { "type" : "git", "url" : "git://github.com/autarch/DateTime-Format-Strptime.git", "web" : "https://github.com/autarch/DateTime-Format-Strptime" } }, "version" : "1.63", "x_Dist_Zilla" : { "perl" : { "version" : "5.022001" }, "plugins" : [ { "class" : "Dist::Zilla::Plugin::MakeMaker", "config" : { "Dist::Zilla::Role::TestRunner" : { "default_jobs" : 1 } }, "name" : "@DROLSKY/MakeMaker", "version" : "5.043" }, { "class" : "Dist::Zilla::Plugin::Authority", "name" : "@DROLSKY/Authority", "version" : "1.009" }, { "class" : "Dist::Zilla::Plugin::AutoPrereqs", "name" : "@DROLSKY/AutoPrereqs", "version" : "5.043" }, { "class" : "Dist::Zilla::Plugin::CopyFilesFromBuild", "name" : "@DROLSKY/CopyFilesFromBuild", "version" : "0.151680" }, { "class" : "Dist::Zilla::Plugin::Git::GatherDir", "config" : { "Dist::Zilla::Plugin::GatherDir" : { "exclude_filename" : [ "Build.PL", "LICENSE", "Makefile.PL", "README.md", "cpanfile" ], "exclude_match" : [], "follow_symlinks" : 0, "include_dotfiles" : 0, "prefix" : "", "prune_directory" : [], "root" : "." }, "Dist::Zilla::Plugin::Git::GatherDir" : { "include_untracked" : 0 } }, "name" : "@DROLSKY/Git::GatherDir", "version" : "2.036" }, { "class" : "Dist::Zilla::Plugin::GitHub::Meta", "name" : "@DROLSKY/GitHub::Meta", "version" : "0.41" }, { "class" : "Dist::Zilla::Plugin::GitHub::Update", "config" : { "Dist::Zilla::Plugin::GitHub::Update" : { "metacpan" : 1 } }, "name" : "@DROLSKY/GitHub::Update", "version" : "0.41" }, { "class" : "Dist::Zilla::Plugin::MetaResources", "name" : "@DROLSKY/MetaResources", "version" : "5.043" }, { "class" : "Dist::Zilla::Plugin::MetaProvides::Package", "config" : { "Dist::Zilla::Plugin::MetaProvides::Package" : { "finder_objects" : [ { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : "@DROLSKY/MetaProvides::Package/AUTOVIV/:InstallModulesPM", "version" : "5.043" } ] }, "Dist::Zilla::Role::MetaProvider::Provider" : { "inherit_missing" : "1", "inherit_version" : "1", "meta_noindex" : "1" } }, "name" : "@DROLSKY/MetaProvides::Package", "version" : "2.003001" }, { "class" : "Dist::Zilla::Plugin::NextRelease", "name" : "@DROLSKY/NextRelease", "version" : "5.043" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "test", "type" : "requires" } }, "name" : "@DROLSKY/Test::More with subtest", "version" : "5.043" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "develop", "type" : "requires" } }, "name" : "@DROLSKY/Modules for use with tidyall", "version" : "5.043" }, { "class" : "Dist::Zilla::Plugin::PromptIfStale", "config" : { "Dist::Zilla::Plugin::PromptIfStale" : { "check_all_plugins" : 1, "check_all_prereqs" : 1, "modules" : [], "phase" : "release", "skip" : [ "Dist::Zilla::Plugin::DROLSKY::Contributors", "Dist::Zilla::Plugin::DROLSKY::License", "Dist::Zilla::Plugin::DROLSKY::TidyAll", "Dist::Zilla::Plugin::DROLSKY::VersionProvider" ] } }, "name" : "@DROLSKY/PromptIfStale", "version" : "0.047" }, { "class" : "Dist::Zilla::Plugin::ReadmeAnyFromPod", "config" : { "Dist::Zilla::Role::FileWatcher" : { "version" : "0.006" } }, "name" : "@DROLSKY/README.md in build", "version" : "0.150250" }, { "class" : "Dist::Zilla::Plugin::ReadmeAnyFromPod", "config" : { "Dist::Zilla::Role::FileWatcher" : { "version" : "0.006" } }, "name" : "@DROLSKY/README.md in root", "version" : "0.150250" }, { "class" : "Dist::Zilla::Plugin::Test::Pod::Coverage::Configurable", "name" : "@DROLSKY/Test::Pod::Coverage::Configurable", "version" : "0.05" }, { "class" : "Dist::Zilla::Plugin::Test::PodSpelling", "config" : { "Dist::Zilla::Plugin::Test::PodSpelling" : { "directories" : [], "spell_cmd" : "", "stopwords" : [ "DROLSKY", "DROLSKY's", "Measham", "POSIX", "PayPal", "Rolsky", "Rolsky", "Rolsky's", "STRPTIME", "errmsg", "formatter", "strf", "strp", "strptime" ], "wordlist" : "Pod::Wordlist" } }, "name" : "@DROLSKY/Test::PodSpelling", "version" : "2.007000" }, { "class" : "Dist::Zilla::Plugin::Test::ReportPrereqs", "name" : "@DROLSKY/Test::ReportPrereqs", "version" : "0.021" }, { "class" : "Dist::Zilla::Plugin::Test::Version", "name" : "@DROLSKY/Test::Version", "version" : "1.05" }, { "class" : "Dist::Zilla::Plugin::ManifestSkip", "name" : "@DROLSKY/ManifestSkip", "version" : "5.043" }, { "class" : "Dist::Zilla::Plugin::MetaYAML", "name" : "@DROLSKY/MetaYAML", "version" : "5.043" }, { "class" : "Dist::Zilla::Plugin::License", "name" : "@DROLSKY/License", "version" : "5.043" }, { "class" : "Dist::Zilla::Plugin::ExtraTests", "name" : "@DROLSKY/ExtraTests", "version" : "5.043" }, { "class" : "Dist::Zilla::Plugin::ExecDir", "name" : "@DROLSKY/ExecDir", "version" : "5.043" }, { "class" : "Dist::Zilla::Plugin::ShareDir", "name" : "@DROLSKY/ShareDir", "version" : "5.043" }, { "class" : "Dist::Zilla::Plugin::Manifest", "name" : "@DROLSKY/Manifest", "version" : "5.043" }, { "class" : "Dist::Zilla::Plugin::CheckVersionIncrement", "name" : "@DROLSKY/CheckVersionIncrement", "version" : "0.121750" }, { "class" : "Dist::Zilla::Plugin::TestRelease", "name" : "@DROLSKY/TestRelease", "version" : "5.043" }, { "class" : "Dist::Zilla::Plugin::ConfirmRelease", "name" : "@DROLSKY/ConfirmRelease", "version" : "5.043" }, { "class" : "Dist::Zilla::Plugin::UploadToCPAN", "name" : "@DROLSKY/UploadToCPAN", "version" : "5.043" }, { "class" : "Dist::Zilla::Plugin::CheckPrereqsIndexed", "name" : "@DROLSKY/CheckPrereqsIndexed", "version" : "0.017" }, { "class" : "Dist::Zilla::Plugin::CPANFile", "name" : "@DROLSKY/CPANFile", "version" : "5.043" }, { "class" : "Dist::Zilla::Plugin::DROLSKY::Contributors", "name" : "@DROLSKY/DROLSKY::Contributors", "version" : "0.40" }, { "class" : "Dist::Zilla::Plugin::DROLSKY::License", "name" : "@DROLSKY/DROLSKY::License", "version" : "0.40" }, { "class" : "Dist::Zilla::Plugin::DROLSKY::TidyAll", "name" : "@DROLSKY/DROLSKY::TidyAll", "version" : "0.40" }, { "class" : "Dist::Zilla::Plugin::DROLSKY::VersionProvider", "name" : "@DROLSKY/DROLSKY::VersionProvider", "version" : "0.40" }, { "class" : "Dist::Zilla::Plugin::DROLSKY::Git::CheckFor::CorrectBranch", "config" : { "Dist::Zilla::Role::Git::Repo" : { "repo_root" : "." } }, "name" : "@DROLSKY/DROLSKY::Git::CheckFor::CorrectBranch", "version" : "0.40" }, { "class" : "Dist::Zilla::Plugin::Git::CheckFor::MergeConflicts", "config" : { "Dist::Zilla::Role::Git::Repo" : { "repo_root" : "." } }, "name" : "@DROLSKY/Git::CheckFor::MergeConflicts", "version" : "0.013" }, { "class" : "Dist::Zilla::Plugin::Git::Contributors", "config" : { "Dist::Zilla::Plugin::Git::Contributors" : { "include_authors" : 0, "include_releaser" : 1, "order_by" : "name", "paths" : [ "." ] } }, "name" : "@DROLSKY/Git::Contributors", "version" : "0.017" }, { "class" : "Dist::Zilla::Plugin::InstallGuide", "name" : "@DROLSKY/InstallGuide", "version" : "1.200006" }, { "class" : "Dist::Zilla::Plugin::Meta::Contributors", "name" : "@DROLSKY/Meta::Contributors", "version" : "0.002" }, { "class" : "Dist::Zilla::Plugin::MetaConfig", "name" : "@DROLSKY/MetaConfig", "version" : "5.043" }, { "class" : "Dist::Zilla::Plugin::MetaJSON", "name" : "@DROLSKY/MetaJSON", "version" : "5.043" }, { "class" : "Dist::Zilla::Plugin::SurgicalPodWeaver", "config" : { "Dist::Zilla::Plugin::PodWeaver" : { "finder" : [ ":InstallModules", ":ExecFiles" ], "plugins" : [ { "class" : "Pod::Weaver::Plugin::EnsurePod5", "name" : "@CorePrep/EnsurePod5", "version" : "4.012" }, { "class" : "Pod::Weaver::Plugin::H1Nester", "name" : "@CorePrep/H1Nester", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Name", "name" : "Name", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Version", "name" : "Version", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Region", "name" : "prelude", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "SYNOPSIS", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "DESCRIPTION", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Leftovers", "name" : "Leftovers", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Region", "name" : "postlude", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Authors", "name" : "Authors", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Contributors", "name" : "Contributors", "version" : "0.009" }, { "class" : "Pod::Weaver::Section::Legal", "name" : "Legal", "version" : "4.012" } ] } }, "name" : "@DROLSKY/SurgicalPodWeaver", "version" : "0.0023" }, { "class" : "Dist::Zilla::Plugin::MojibakeTests", "name" : "@DROLSKY/MojibakeTests", "version" : "0.8" }, { "class" : "Dist::Zilla::Plugin::PodSyntaxTests", "name" : "@DROLSKY/PodSyntaxTests", "version" : "5.043" }, { "class" : "Dist::Zilla::Plugin::Test::EOL", "config" : { "Dist::Zilla::Plugin::Test::EOL" : { "filename" : "xt/author/eol.t", "finder" : [ ":InstallModules", ":ExecFiles", ":TestFiles" ], "trailing_whitespace" : "1" } }, "name" : "@DROLSKY/Test::EOL", "version" : "0.18" }, { "class" : "Dist::Zilla::Plugin::Test::NoTabs", "config" : { "Dist::Zilla::Plugin::Test::NoTabs" : { "filename" : "xt/author/no-tabs.t", "finder" : [ ":InstallModules", ":ExecFiles", ":TestFiles" ] } }, "name" : "@DROLSKY/Test::NoTabs", "version" : "0.15" }, { "class" : "Dist::Zilla::Plugin::Test::Portability", "name" : "@DROLSKY/Test::Portability", "version" : "2.000006" }, { "class" : "Dist::Zilla::Plugin::Test::TidyAll", "name" : "@DROLSKY/Test::TidyAll", "version" : "0.01" }, { "class" : "Dist::Zilla::Plugin::Test::Compile", "config" : { "Dist::Zilla::Plugin::Test::Compile" : { "bail_out_on_fail" : "0", "fail_on_warning" : "author", "fake_home" : 0, "filename" : "xt/author/00-compile.t", "module_finder" : [ ":InstallModules" ], "needs_display" : 0, "phase" : "develop", "script_finder" : [ ":PerlExecFiles" ], "skips" : [] } }, "name" : "@DROLSKY/Test::Compile", "version" : "2.054" }, { "class" : "Dist::Zilla::Plugin::Git::Check", "config" : { "Dist::Zilla::Plugin::Git::Check" : { "untracked_files" : "die" }, "Dist::Zilla::Role::Git::DirtyFiles" : { "allow_dirty" : [ "Build.PL", "CONTRIBUTING.md", "Changes", "LICENSE", "Makefile.PL", "README.md", "cpanfile" ], "allow_dirty_match" : [], "changelog" : "Changes" }, "Dist::Zilla::Role::Git::Repo" : { "repo_root" : "." } }, "name" : "@DROLSKY/Git::Check", "version" : "2.036" }, { "class" : "Dist::Zilla::Plugin::Git::Commit", "config" : { "Dist::Zilla::Plugin::Git::Commit" : { "add_files_in" : [], "commit_msg" : "v%v%n%n%c" }, "Dist::Zilla::Role::Git::DirtyFiles" : { "allow_dirty" : [ "Build.PL", "CONTRIBUTING.md", "Changes", "LICENSE", "Makefile.PL", "README.md", "cpanfile" ], "allow_dirty_match" : [], "changelog" : "Changes" }, "Dist::Zilla::Role::Git::Repo" : { "repo_root" : "." }, "Dist::Zilla::Role::Git::StringFormatter" : { "time_zone" : "local" } }, "name" : "@DROLSKY/commit generated files", "version" : "2.036" }, { "class" : "Dist::Zilla::Plugin::Git::Tag", "config" : { "Dist::Zilla::Plugin::Git::Tag" : { "branch" : null, "changelog" : "Changes", "signed" : 0, "tag" : "v1.63", "tag_format" : "v%v", "tag_message" : "v%v" }, "Dist::Zilla::Role::Git::Repo" : { "repo_root" : "." }, "Dist::Zilla::Role::Git::StringFormatter" : { "time_zone" : "local" } }, "name" : "@DROLSKY/Git::Tag", "version" : "2.036" }, { "class" : "Dist::Zilla::Plugin::Git::Push", "config" : { "Dist::Zilla::Plugin::Git::Push" : { "push_to" : [ "origin" ], "remotes_must_exist" : 1 }, "Dist::Zilla::Role::Git::Repo" : { "repo_root" : "." } }, "name" : "@DROLSKY/Git::Push", "version" : "2.036" }, { "class" : "Dist::Zilla::Plugin::BumpVersionAfterRelease", "config" : { "Dist::Zilla::Plugin::BumpVersionAfterRelease" : { "finders" : [ ":ExecFiles", ":InstallModules" ], "global" : 0, "munge_makefile_pl" : 1 } }, "name" : "@DROLSKY/BumpVersionAfterRelease", "version" : "0.012" }, { "class" : "Dist::Zilla::Plugin::Git::Commit", "config" : { "Dist::Zilla::Plugin::Git::Commit" : { "add_files_in" : [], "commit_msg" : "Bump version after release" }, "Dist::Zilla::Role::Git::DirtyFiles" : { "allow_dirty" : [ "Changes", "dist.ini" ], "allow_dirty_match" : [ "(?^:.+)" ], "changelog" : "Changes" }, "Dist::Zilla::Role::Git::Repo" : { "repo_root" : "." }, "Dist::Zilla::Role::Git::StringFormatter" : { "time_zone" : "local" } }, "name" : "@DROLSKY/commit version bump", "version" : "2.036" }, { "class" : "Dist::Zilla::Plugin::Git::Push", "config" : { "Dist::Zilla::Plugin::Git::Push" : { "push_to" : [ "origin" ], "remotes_must_exist" : 1 }, "Dist::Zilla::Role::Git::Repo" : { "repo_root" : "." } }, "name" : "@DROLSKY/push version bump", "version" : "2.036" }, { "class" : "Dist::Zilla::Plugin::Test::Pod::LinkCheck", "name" : "@DROLSKY/Test::Pod::LinkCheck", "version" : "1.002" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "develop", "type" : "requires" } }, "name" : "DevelopRequires", "version" : "5.043" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":InstallModules", "version" : "5.043" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":IncModules", "version" : "5.043" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":TestFiles", "version" : "5.043" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExtraTestFiles", "version" : "5.043" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExecFiles", "version" : "5.043" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":PerlExecFiles", "version" : "5.043" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ShareFiles", "version" : "5.043" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":MainModule", "version" : "5.043" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":AllFiles", "version" : "5.043" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":NoFiles", "version" : "5.043" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : "@DROLSKY/MetaProvides::Package/AUTOVIV/:InstallModulesPM", "version" : "5.043" } ], "zilla" : { "class" : "Dist::Zilla::Dist::Builder", "config" : { "is_trial" : "0" }, "version" : "5.043" } }, "x_authority" : "cpan:DROLSKY", "x_contributors" : [ "D. Ilmari Mannsåker " ] } DateTime-Format-Strptime-1.63/tidyall.ini0000644000175000017500000000032412645520607020203 0ustar autarchautarch[PerlTidy] select = **/*.{pl,pm,t,psgi} ignore = t/00-* ignore = t/author-* ignore = t/release-* ignore = blib/**/* ignore = .build/**/* ignore = DateTime-Format-Strptime-*/**/* argv = --profile=$ROOT/perltidyrc DateTime-Format-Strptime-1.63/Changes0000644000175000017500000002715012645520607017341 0ustar autarchautarch1.63 2016-01-13 [BUG FIXES] - The behaviour of silently ignoring text after the matching part was lost in the rewrite. This has been restored. Patch by Dagfinn Ilmari Mannsåker. RT #111155. 1.62 2015-12-19 [BUG FIXES] - When on_error was set to something that did not die (including the default error handling), calling ->parse_datetime with some bad inputs could cause the module to error out internally by trying to call methods on an undefined value instead of returning undef. Reported by Mike Dorman. RT #110247. 1.61 2015-11-13 [BUG FIXES] - If you loaded this module with warnings globally enabled ("perl -w", which you should never do), then you'd get a warning about the import subroutine being redefined. This broke the Package::DeprecationManager API for turning off deprecation warnings. This has been fixed in Package::DeprecationManager 0.15. Reported by Martin. RT #108871. 1.60 2015-11-07 - This release is identical to the prior trial release. The changes for the trial releases are reproduced below for convenience. [BACKWARDS INCOMPATIBILITIES] - The error messages for various types of failures have changed. - The never-documented diagnostic parameter for the constructor has been removed. - The never-documented feature to allow you to use arbitrary DateTime.pm methods in the parsing pattern has been removed. This never made much sense anyway, since most DateTime.pm methods are not constructor params, but they were used that way. - Using the pattern, locale, and time_zone to set the respective attribute is now deprecated. Make a new object instead of changing one of these values. [BUG FIXES] - Fixed a warning from the tests with newer Perl versions. RT #107620. - Clarified docs to note that %Y and %G require 4-digit years. Reported by Karen Etheridge. RT #103147. - Using the 24-hour token (%H) with an AM/PM specifier (%p) now leads to an error if you try to parse something like "23:01 AM". Reported by Ric Signes. RT #92445. 1.59 2015-10-25 (TRIAL RELEASE) - The previous release accidentally included an old version of Strptime.pm in the root dir, causing all sorts of chaos and test failures. 1.58 2015-10-18 (TRIAL RELEASE) - This release is a substantial rewrite. Please test it and file bugs for any unintentional breakage. * The error messages for various types of failures have changed. * The never-documented diagnostic parameter for the constructor has been removed. * The never-documented feature to allow you to use arbitrary DateTime.pm methods in the parsing pattern has been removed. This never made much sense anyway, since most DateTime.pm methods are not constructor params, but they were used that way. * Using the pattern, locale, and time_zone to set the respective attribute is now deprecated. Make a new object instead of changing one of these values. - Fixed a warning from the tests with newer Perl versions. RT #107620. - Clarified docs to note that %Y and %G require 4-digit years. Reported by Karen Etheridge. RT #103147. 1.57 2015-10-04 - Make all tests pass with both the current DateTime::Locale and the upcoming new version (currently still in trial releases). 1.56 2014-08-07 - Recent DateTime::TimeZone changes broke the tests. - Fixed Latin-1 content in test code. It's now UTF-8. 1.55 2014-08-07. - Broken release. I deleted this from PAUSE. 1.54 2013-04-02 - Require DateTime.pm 1.00 because without it tests will break. 1.53 2013-04-02 - A fix in DateTime.pm 1.00 broke a test in this distro. Reported by Anthony J Lucas. RT #84371. 1.52 2012-07-01 - Shut up "unescaped braces in regex" warning from 5.17.0. RT #77514. Patch by Zefram. 1.51 2012-05-27 - Packaging cleanup, including listing Test::More as a test prereq, not a runtime prereq. RT #76128. 1.5000 2010-10-16 - This module did not recognize UTC as a valid time zone. Patch by Danijel Tašov. RT #59209. 1.4000 2010-06-28 - Actually update $VERSION in module file. Reported by David Wheeler. 1.3000 2010-06-26 - Specifiers which allowed for leading space before a number (like %e) would cause DateTime.pm to throw an error if the date being parsed actually contained leading space. Patch by Alex Vandiver. RT #58459. - License is now Artistic 2.0 1.2000 2010-03-19 - Updated to use non-deprecated DateTime::Locale API 1.1000 2009-07-13 -- Regex Pattern - If the pattern you pass in is a regular expression, that will be honored. - Changed the locale tests to use require the latest version of Locale until the target stops moving. 1.0901 2009-05-16 -- Official release of 1.0900_01 1.0900_01 2009-04-18 - Makefile.PL changes for Windows users as per issue #16 1.0900 2009-02-22 - It seems that I also wasn't seeing notifications from RT (please don't use it, use the Gooogle project) so all the following are fixed: - 36672 Started failing mid May - 23313 Bug handling time zones like America/New_York - 25555 Module dies even when on_error is 'undef' - 23768 Olson timezone handling incorrect - 22450 locale test failing with bleadperl - 20487 nmake test_more fail (with patch); incorrect META.yml - 12071 format_datetime uses datetime locale rather than format locale - 11863 bug in DateTime::Format::Strptime 1.0601 when using %s - And a couple from Google: - #8 Add DateTime::Locale to documentation - #10 Parsing bug -- can't detect word boundry after month abbr 1.0800 2008-08-07 - It seems that I wasn't getting notifications from Google when people had reported bugs, so there's a pile of fixes in this release. Hopefully that fixes everyone's issues. 1.0702 2007-09-19 - Updated the META.yml file to have the correct 'resources' and match the latest spec - Updated the docus with a 'resources' section that has the same information in it for readers of POD. - This version ONLY changes the documentation and so it not a required update. 1.0701 2007-09-18 - Many people pointed out that while this module hadn't broken the tests for the French locale had. This is due to a new source for the data in DateTime::Locale. - This version ONLY changes the tests and so it not a required update. 1.0700 Sat, 5 Nov 2005 09:44:10 +1100 - Mike Schilli pointed out that strings without time zones or constructors without a time zone should be returning a DateTime in the floating time zone rather than UTC. - Jason Bodnar requested greater allowance for time zones in strings .. so I've now added the ability to use an Olson time zone identifier with %O. Note that this is a token specifically added to Strptime and it WILL NOT WORK with DateTime's strftime method. 1.0601 Wed, 1 Sep 2004 07:52:44 +1000 - Dave Faraldo and Jonathan Lefter pointed out that one of the new Locale tests in t/006... will fail on the 30th and 31st of the month as not all months have those days. Patch supplied by Jonathan has been applied. - This is just a test fix and doesn't alter the way the module runs in any way. If you already got 1.06 to run then you don't need this. 1.0600 Sat, 28 Aug 2004 15:02:47 +1000 - Fixed bug from RT (#7502) from dfaraldo@redhat.com that made validation fall over by assuming midnight always exists. The patch now assumes Midday exists (both he and I assume that DST will never start at midday anywhere anytime!) - This is a major change and you should install this release if you ever use any time_zone other than floating or UTC. And if you don't use them today, you may tomorrow - so upgrade OK? 1.0500 Wed, 18 Aug 2004 17:24:32 +1000 - Adapted and applied patches from Jean Forget to allow day names and month names to have \W characters and to allow am/pm values from other locales - Jean's patch also included some doc patches - Patched the synopsis a Jean suggestion to demonstrate how to use the non-default error behaviors - Added tests for these bugs - Added t/more/* and the make test_more target so I can test every locale if I want to. - It's over a year since I deprecated the language parameter so I've now removed it. You've had a year of warnings! - This is a major change and you should install this release if you use any locale other than en. 1.0400 Sun, 10 Aug 2003 00:22:00 +1000 - Applied patches from Joshua Hoblitt to move the the brand new DateTime::Locale rather than the old ::Language modules - Implemented %x, %X and %c for locale formats - Fixed a bug on the two digit year determinator - Added a test for locales known as 004locale.t - This is a major change and you should install this release if you are using DateTime >= 0.14 (the first release with Locale) 1.0302 Sat, 28 Jun 2003 09:15:21 +1000 - Test 004 was failing on Windows due to the path delimiter being a backslash rather than a slash. This release should also fix Strptime for Mac users, although I've had no complaints from such users. (Myself being one of the only ones currently using Strptime AFAIK!) Thanks Ron Hill for the bug report. 1.0301 Wed, 25 Jun 2003 22:40:12 +1000 - Updated to handle the post 0.12 DateTime that now validates dates. Still handles old DateTime. 1.0300 Sat, 07 Jun 2003 10:40:23 +1000 - The calls to die() have changed by request of Dave Rolsky and Iain Truskett (Thanks!). We now allow each object to have its own behavior. - The default behavior has been changed to returning undef. This was requested by someone (tell me if it was you!) and made a lot of sense to me. - Never released to CPAN 1.0200 Wed, 28 May 2003 21:02:03 +1000 - The docs for Time::Local talk about the 'proclivity to croak' which basically means the module croaks easily. So did this one until now. Until now, if you allowed a user to specify a pattern and they entered one that was non parsable, this module would croak causing your script to croak. This is a Bad Thing (tm). The behaviour now remains the same, however if you set $DateTime::Format::StrpTime::CROAK to false, methods will return undef rather than croaking. $DateTime::Format::StrpTime::errmsg will tell you what went wrong. The default is to continue to croak. This means you have to delibrately turn it off. Hopefully you'll change you script to do this at the same time you change it to check the return values of the methods :) 1.0103 Wed, 28 May 2003 20:10:57 +1000 - Applied doc patches from Iain Truskett (Thanks!) - Clarified parameter discrepancy between synopsis and docs (Thanks Chris Winters) 1.0102 Fri, 16 May 2003 07:28:18 +1000 - Fixed the same test as above. Think I actually succeeded this time! 1.0101 Tue, 13 May 2003 07:58:23 +1000 - Fixed a test that was broken if DateTime::TimeZone was not version 0.13 or above. 1.0100 Sun, 11 May 2003 13:54:36 +1000 - If we have the latest DateTime we run the test mentioned above - Fixed my version format as advised by Iain Truskett if it still doesn't work it's because of me, not him - Added the ability to handle nanoseconds as requested by Michael Goltze. - Got Time Zones working, including mapping non-ambiguous TLAs offsets and Olsen names (the latter uses the %q token) 1.00.02 Tue, 29 Apr 2003 07:03:19 +1000 - Fixed a test that only worked in DateTime was from CVS - Fixed two issues noted by Iain Truskett: - Removed a diag() in test 1 that was just there for testing the test - Added a linebreak to the end of the MANIFEST 1.00.01 Mon, 28 Apr 2003 07:12:01 +1000 - removed alien life-forms (characters that didn't ASCIIfy) * No API change, just made it so it will install now! 1.00.00 Sun, 27 Apr 2003 17:56:27 +1000 - first CPAN release - added tests - should be 100% compatible with DateTime's strftime function DateTime-Format-Strptime-1.63/MANIFEST0000644000175000017500000000117112645520607017172 0ustar autarchautarch# This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.043. Changes INSTALL LICENSE MANIFEST META.json META.yml Makefile.PL README.md bench cpanfile dist.ini lib/DateTime/Format/Strptime.pm perlcriticrc perltidyrc t/00-report-prereqs.dd t/00-report-prereqs.t t/author-00-compile.t t/author-eol.t t/author-mojibake.t t/author-no-tabs.t t/author-pod-spell.t t/author-pod-syntax.t t/author-test-all-my-deps.t t/author-test-version.t t/basic.t t/edge.t t/errors.t t/import.t t/lib/T.pm t/locales.t t/release-pod-coverage.t t/release-pod-linkcheck.t t/release-portability.t t/release-tidyall.t tidyall.ini weaver.ini DateTime-Format-Strptime-1.63/perlcriticrc0000644000175000017500000000270312645520607020453 0ustar autarchautarchseverity = 3 verbose = 11 theme = core + pbp + bugs + maintenance + cosmetic + complexity + security + tests + moose exclude = Subroutines::ProhibitCallsToUndeclaredSubs [BuiltinFunctions::ProhibitStringySplit] severity = 3 [CodeLayout::RequireTrailingCommas] severity = 3 [ControlStructures::ProhibitCStyleForLoops] severity = 3 [InputOutput::RequireCheckedSyscalls] functions = :builtins exclude_functions = sleep severity = 3 [RegularExpressions::ProhibitComplexRegexes] max_characters = 200 [RegularExpressions::ProhibitUnusualDelimiters] severity = 3 [Subroutines::ProhibitUnusedPrivateSubroutines] private_name_regex = _(?!build)\w+ [TestingAndDebugging::ProhibitNoWarnings] allow = redefine [ValuesAndExpressions::ProhibitEmptyQuotes] severity = 3 [ValuesAndExpressions::ProhibitInterpolationOfLiterals] severity = 3 [ValuesAndExpressions::RequireUpperCaseHeredocTerminator] severity = 3 [Variables::ProhibitPackageVars] add_packages = Carp Test::Builder [-Subroutines::RequireFinalReturn] [-ErrorHandling::RequireCarping] # No need for /xsm everywhere [-RegularExpressions::RequireDotMatchAnything] [-RegularExpressions::RequireExtendedFormatting] [-RegularExpressions::RequireLineBoundaryMatching] # http://stackoverflow.com/questions/2275317/why-does-perlcritic-dislike-using-shift-to-populate-subroutine-variables [-Subroutines::RequireArgUnpacking] # "use v5.14" is more readable than "use 5.014" [-ValuesAndExpressions::ProhibitVersionStrings] DateTime-Format-Strptime-1.63/INSTALL0000644000175000017500000000202112645520607017065 0ustar autarchautarchThis is the Perl distribution DateTime-Format-Strptime. Installing DateTime-Format-Strptime is straightforward. ## Installation with cpanm If you have cpanm, you only need one line: % cpanm DateTime::Format::Strptime If you are installing into a system-wide directory, you may need to pass the "-S" flag to cpanm, which uses sudo to install the module: % cpanm -S DateTime::Format::Strptime ## Installing with the CPAN shell Alternatively, if your CPAN shell is set up, you should just be able to do: % cpan DateTime::Format::Strptime ## Manual installation As a last resort, you can manually install it. Download the tarball, untar it, then build it: % perl Makefile.PL % make && make test Then install it: % make install If you are installing into a system-wide directory, you may need to run: % sudo make install ## Documentation DateTime-Format-Strptime documentation is available as POD. You can run perldoc from a shell to read the documentation: % perldoc DateTime::Format::Strptime DateTime-Format-Strptime-1.63/README.md0000644000175000017500000001721012645520607017321 0ustar autarchautarchNAME DateTime::Format::Strptime - Parse and format strp and strf time patterns VERSION version 1.63 SYNOPSIS use DateTime::Format::Strptime; my $strp = DateTime::Format::Strptime->new( pattern => '%T', locale => 'en_AU', time_zone => 'Australia/Melbourne', ); my $dt = $strp->parse_datetime('23:16:42'); $strp->format_datetime($dt); # 23:16:42 # Croak when things go wrong: my $strp = DateTime::Format::Strptime->new( pattern => '%T', locale => 'en_AU', time_zone => 'Australia/Melbourne', on_error => 'croak', ); # Will throw an exception $newpattern = $strp->pattern('%Q'); # Do something else when things go wrong: my $strp = DateTime::Format::Strptime->new( pattern => '%T', locale => 'en_AU', time_zone => 'Australia/Melbourne', on_error => \&phone_police, ); DESCRIPTION This module implements most of strptime(3), the POSIX function that is the reverse of strftime(3), for DateTime. While strftime takes a DateTime and a pattern and returns a string, strptime takes a string and a pattern and returns the DateTime object associated. METHODS This class offers the following methods. DateTime::Format::Strptime->new(%args) This methods creates a new object. It accepts the following arguments: * pattern This is the pattern to use for parsing. This is required. * time_zone The default time zone to use for objects returned from parsing. * locale The locale to use for objects returned from parsing. * on_error This can be one of 'undef' (the string, not an undef), 'croak', or a subroutine reference. * 'undef' This is the default behavior. The module will return undef on errors. The error can be accessed using the $object->errmsg method. This is the ideal behaviour for interactive use where a user might provide an illegal pattern or a date that doesn't match the pattern. * 'croak' The module will croak with an error message on errors. * sub{...} or \&subname When given a code ref, the module will call that sub on errors. The sub receives two parameters: the object and the error message. If your sub does not die, then the formatter will continue on as if on_error was 'undef'. $strptime->parse_datetime($string) Given a string in the pattern specified in the constructor, this method will return a new DateTime object. If given a string that doesn't match the pattern, the formatter will croak or return undef, depending on the setting of on_error in the constructor. $strptime->format_datetime($datetime) Given a DateTime object, this methods returns a string formatted in the object's format. This method is synonymous with DateTime's strftime method. $strptime->locale This method returns the locale passed to the object's constructor. $strptime->pattern This method returns the pattern passed to the object's constructor. $strptime->time_zone This method returns the time zone passed to the object's constructor. $strptime->errmsg If the on_error behavior of the object is 'undef', you can retrieve error messages with this method so you can work out why things went wrong. EXPORTS These subs are available as optional exports. strptime( $strptime_pattern, $string ) Given a pattern and a string this function will return a new DateTime object. strftime( $strftime_pattern, $datetime ) Given a pattern and a DateTime object this function will return a formatted string. STRPTIME PATTERN TOKENS The following tokens are allowed in the pattern string for strptime (parse_datetime): * %% The % character. * %a or %A The weekday name according to the current locale, in abbreviated form or the full name. * %b or %B or %h The month name according to the current locale, in abbreviated form or the full name. * %C The century number (0-99). * %d or %e The day of month (01-31). This will parse single digit numbers as well. * %D Equivalent to %m/%d/%y. (This is the American style date, very confusing to non-Americans, especially since %d/%m/%y is widely used in Europe. The ISO 8601 standard pattern is %F.) * %F Equivalent to %Y-%m-%d. (This is the ISO style date) * %g The year corresponding to the ISO week number, but without the century (0-99). * %G The 4-digit year corresponding to the ISO week number. * %H The hour (00-23). This will parse single digit numbers as well. * %I The hour on a 12-hour clock (1-12). * %j The day number in the year (1-366). * %m The month number (01-12). This will parse single digit numbers as well. * %M The minute (00-59). This will parse single digit numbers as well. * %n Arbitrary whitespace. * %N Nanoseconds. For other sub-second values use %[number]N. * %p The equivalent of AM or PM according to the locale in use. (See DateTime::Locale) * %r Equivalent to %I:%M:%S %p. * %R Equivalent to %H:%M. * %s Number of seconds since the Epoch. * %S The second (0-60; 60 may occur for leap seconds. See DateTime::LeapSecond). * %t Arbitrary whitespace. * %T Equivalent to %H:%M:%S. * %U The week number with Sunday the first day of the week (0-53). The first Sunday of January is the first day of week 1. * %u The weekday number (1-7) with Monday = 1. This is the DateTime standard. * %w The weekday number (0-6) with Sunday = 0. * %W The week number with Monday the first day of the week (0-53). The first Monday of January is the first day of week 1. * %y The year within century (0-99). When a century is not otherwise specified (with a value for %C), values in the range 69-99 refer to years in the twentieth century (1969-1999); values in the range 00-68 refer to years in the twenty-first century (2000-2068). * %Y A 4-digit year, including century (for example, 1991). * %z An RFC-822/ISO 8601 standard time zone specification. (For example +1100) [See note below] * %Z The timezone name. (For example EST -- which is ambiguous) [See note below] * %O This extended token allows the use of Olson Time Zone names to appear in parsed strings. NOTE: This pattern cannot be passed to DateTime's strftime() method, but can be passed to format_datetime(). AUTHOR EMERITUS This module was created by Rick Measham. BUGS Please report any bugs or feature requests to bug-datetime-format-strptime@rt.cpan.org, or through the web interface at http://rt.cpan.org. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. SEE ALSO datetime@perl.org mailing list. http://datetime.perl.org/ perl, DateTime, DateTime::TimeZone, DateTime::Locale AUTHORS * Dave Rolsky * Rick Measham CONTRIBUTOR D. Ilmari Mannsåker COPYRIGHT AND LICENSE This software is Copyright (c) 2016 by Dave Rolsky. This is free software, licensed under: The Artistic License 2.0 (GPL Compatible)