houseabsolute / DateTime-Format-ISO8601

Parses ISO8601 formats
http://metacpan.org/release/DateTime-Format-ISO8601/
Other
3 stars 3 forks source link

parsing 1991-W01 throws exception #6

Closed autarch closed 3 years ago

autarch commented 3 years ago

Migrated from rt.cpan.org #104346 (status was 'open')

Requestors:

From szabgab@cpan.org (@szabgab) on 2015-05-11 12:49:53 :

From the documentation it is unclear to me what "1991-W01" indicates but parsing "1991-W01" throws an exception while "1991-W02" parses.

autarch commented 3 years ago

From kentnl@cpan.org (@kentfredric) on 2016-05-13 08:41:54 :

Confirming: Tried all possible variations of week parsing I saw mentioned, can't get any of them to work in the proximity of week 1.

Week 54 ( which doesn't actually exist ) fails in a similar way, but Week 53 does not.

$ perl -d:Confess -MDateTime::Format::ISO8601 -e 'DateTime::Format::ISO8601->new->parse_datetime(q[2014-W01-1]) ' The 'day_of_year' parameter ("-1") to DateTime::from_day_of_year did not pass the 'is between 1 and 366' callback at /home/kent/perl5/perlbrew/perls/5.24.0-RC5/lib/site_perl/5.24.0/x86_64-linux/DateTime.pm line 679. DateTime::from_day_of_year(undef, "year", 2014, "day_of_year", -1) called at /home/kent/perl5/perlbrew/perls/5.24.0-RC5/lib/site_perl/5.24.0/DateTime/Format/Builder/Parser/Regex.pm line 67 DateTime::Format::Builder::Parser::Regex::make(DateTime::Format::Builder::Parser::Regex=HASH(0x29fc338), "2014-W01-1", undef, HASH(0x29fd578)) called at /home/kent/perl5/perlbrew/perls/5.24.0-RC5/lib/site_perl/5.24.0/DateTime/Format/Builder/Parser/generic.pm line 82 DateTime::Format::Builder::Parser::generic::ANON[/home/kent/perl5/perlbrew/perls/5.24.0-RC5/lib/site_perl/5.24.0/DateTime/Format/Builder/Parser/generic.pm:84](DateTime::Format::ISO8601=HASH(0x27d7c00), "2014-W01-1", HASH(0x207d4f0)) called at /home/kent/perl5/perlbrew/perls/5.24.0-RC5/lib/site_perl/5.24.0/DateTime/Format/Builder/Parser.pm line 338 DateTime::Format::Builder::Parser::ANON[/home/kent/perl5/perlbrew/perls/5.24.0-RC5/lib/site_perl/5.24.0/DateTime/Format/Builder/Parser.pm:342](DateTime::Format::ISO8601=HASH(0x27d7c00), "2014-W01-1", HASH(0x207d4f0)) called at /home/kent/perl5/perlbrew/perls/5.24.0-RC5/lib/site_perl/5.24.0/DateTime/Format/Builder/Parser.pm line 272 DateTime::Format::Builder::Parser::ANON/home/kent/perl5/perlbrew/perls/5.24.0-RC5/lib/site_perl/5.24.0/DateTime/Format/Builder/Parser.pm:285 called at /home/kent/perl5/perlbrew/perls/5.24.0-RC5/lib/site_perl/5.24.0/DateTime/Format/Builder/Parser.pm line 63 DateTime::Format::Builder::Parser::parse(DateTime::Format::Builder::Parser=HASH(0x29f1be8), DateTime::Format::ISO8601=HASH(0x27d7c00), "2014-W01-1") called at /home/kent/perl5/perlbrew/perls/5.24.0-RC5/lib/site_perl/5.24.0/DateTime/Format/Builder.pm line 139 DateTime::Format::Builder::ANON/home/kent/perl5/perlbrew/perls/5.24.0-RC5/lib/site_perl/5.24.0/DateTime/Format/Builder.pm:140 called at -e line 1

$ perl -d:Confess -MDateTime::Format::ISO8601 -e 'DateTime::Format::ISO8601->new->parse_datetime(q[2014-W53-1]) '

$ perl -d:Confess -MDateTime::Format::ISO8601 -e 'DateTime::Format::ISO8601->new->parse_datetime(q[2014-W54-1]) ' The 'day_of_year' parameter ("370") to DateTime::from_day_of_year did not pass the 'is between 1 and 366' callback at /home/kent/perl5/perlbrew/perls/5.24.0-RC5/lib/site_perl/5.24.0/x86_64-linux/DateTime.pm line 679. DateTime::from_day_of_year(undef, "day_of_year", 370, "year", 2014) called at /home/kent/perl5/perlbrew/perls/5.24.0-RC5/lib/site_perl/5.24.0/DateTime/Format/Builder/Parser/Regex.pm line 67 DateTime::Format::Builder::Parser::Regex::make(DateTime::Format::Builder::Parser::Regex=HASH(0x1afb468), "2014-W54-1", undef, HASH(0x1afc1f0)) called at /home/kent/perl5/perlbrew/perls/5.24.0-RC5/lib/site_perl/5.24.0/DateTime/Format/Builder/Parser/generic.pm line 82 DateTime::Format::Builder::Parser::generic::ANON[/home/kent/perl5/perlbrew/perls/5.24.0-RC5/lib/site_perl/5.24.0/DateTime/Format/Builder/Parser/generic.pm:84](DateTime::Format::ISO8601=HASH(0x18d68c0), "2014-W54-1", HASH(0x117c4f0)) called at /home/kent/perl5/perlbrew/perls/5.24.0-RC5/lib/site_perl/5.24.0/DateTime/Format/Builder/Parser.pm line 338 DateTime::Format::Builder::Parser::ANON[/home/kent/perl5/perlbrew/perls/5.24.0-RC5/lib/site_perl/5.24.0/DateTime/Format/Builder/Parser.pm:342](DateTime::Format::ISO8601=HASH(0x18d68c0), "2014-W54-1", HASH(0x117c4f0)) called at /home/kent/perl5/perlbrew/perls/5.24.0-RC5/lib/site_perl/5.24.0/DateTime/Format/Builder/Parser.pm line 272 DateTime::Format::Builder::Parser::ANON/home/kent/perl5/perlbrew/perls/5.24.0-RC5/lib/site_perl/5.24.0/DateTime/Format/Builder/Parser.pm:285 called at /home/kent/perl5/perlbrew/perls/5.24.0-RC5/lib/site_perl/5.24.0/DateTime/Format/Builder/Parser.pm line 63 DateTime::Format::Builder::Parser::parse(DateTime::Format::Builder::Parser=HASH(0x1af07e8), DateTime::Format::ISO8601=HASH(0x18d68c0), "2014-W54-1") called at /home/kent/perl5/perlbrew/perls/5.24.0-RC5/lib/site_perl/5.24.0/DateTime/Format/Builder.pm line 139 DateTime::Format::Builder::ANON/home/kent/perl5/perlbrew/perls/5.24.0-RC5/lib/site_perl/5.24.0/DateTime/Format/Builder.pm:140 called at -e line 1

autarch commented 3 years ago

From jhoblitt@cpan.org on 2016-05-13 15:55:37 :

I'm guessing this is an off by one error in __normalize_week(). It would be great if someone could dig into this.

autarch commented 3 years ago

Fixed in 0.12