Hello, I am using DateTime::Format::ISO8601-0.06 (perl, v5.10.0 built for i686-linux-thread-multi-64int-ld).
When I try to parse '2009-W01-1', I get an following error: The "'day_of_year' parameter ("-2") to DateTime::from_day_of_year did not pass the 'is between 1 and 366' callback ... DateTime::from_day_of_year(undef, 'day_of_year', -2, 'year', 2009)" 2009-W01-1 should parse to 2008-12-29. Matrix of dates for 2009-W01-x: 2009-W01-1 = Err (days = -2) should be 2008-12-29. 2009-W01-2 = Err (days = -1) should be 2008-12-30. 2009-W01-3 = Err (days = 0) should be 2008-12-31. 2009-W01-4 = OK (days = 1) 2009-01-01. #First Thursday of 2009 2009-W01-5 = OK (days = 2) 2009-01-02. 2009-W01-6 = OK (days = 3) 2009-01-03. 2009-W01-7 = OK (days = 4) 2009-01-04. Just a guess, but it looks like if the days are <= 0, the day_of_year parameter should be 365 (366:leap year) + days, and year should be the previous year (perhaps in _normalize_week()). Thanks, Jim $ perl -MDateTime -MDateTime::Format::ISO8601 -wle '$dtf = DateTime::Format::ISO8601->new; $dt = $dtf->parse_datetime( "2009-W01-1" ); print $dt->ymd("-")' The 'day_of_year' parameter ("-2") to DateTime::from_day_of_year did not pass the 'is between 1 and 366' callback at /usr/local/lib/perl5/site_perl/5.10.0/i686-linux-thread-multi-64int-ld/DateTime.pm line 589 DateTime::from_day_of_year(undef, 'day_of_year', -2, 'year', 2009) called at /usr/local/lib/perl5/site_perl/5.10.0/DateTime/Format/Builder/Parser/Regex.pm line 128 DateTime::Format::Builder::Parser::Regex::make('DateTime::Format::Builder::Parser::Regex=HASH(0x83dd9ac)', '2009-W01-1', undef, 'HASH(0x83ddce0)') called at /usr/local/lib/perl5/site_perl/5.10.0/DateTime/Format/Builder/Parser/generic.pm line 123 DateTime::Format::Builder::Parser::generic::__ANON__('DateTime::Format::ISO8601=HASH(0x837bd50)', '2009-W01-1', 'HASH(0x8067b44)') called at /usr/local/lib/perl5/site_perl/5.10.0/DateTime/Format/Builder/Parser.pm line 538 DateTime::Format::Builder::Parser::__ANON__('DateTime::Format::ISO8601=HASH(0x837bd50)', '2009-W01-1', 'HASH(0x8067b44)') called at /usr/local/lib/perl5/site_perl/5.10.0/DateTime/Format/Builder/Parser.pm line 443 DateTime::Format::Builder::Parser::__ANON__('DateTime::Format::ISO8601=HASH(0x837bd50)', '2009-W01-1') called at /usr/local/lib/perl5/site_perl/5.10.0/DateTime/Format/Builder/Parser.pm line 85 DateTime::Format::Builder::Parser::parse('DateTime::Format::Builder::Parser=HASH(0x83d3090)', 'DateTime::Format::ISO8601=HASH(0x837bd50)', '2009-W01-1') called at /usr/local/lib/perl5/site_perl/5.10.0/DateTime/Format/Builder.pm line 189 DateTime::Format::Builder::__ANON__('DateTime::Format::ISO8601=HASH(0x837bd50)', '2009-W01-1') called at -e line 1 (Should be: 2008-12-29) ... perl -MDateTime -MDateTime::Format::ISO8601 -wle '$dtf = DateTime::Format::ISO8601->new; $dt = $dtf->parse_datetime( "2009-W01-4" ); print $dt->ymd("-")' (OK) 2009-01-01