On Mon, Jul 06, 2009 at 12:02:38PM -0500, Dave Rolsky wrote:
> [ please keep discussion on the datetime@perl.org list ]
> 
> On Mon, 6 Jul 2009, Luc St-Louis wrote:
> 
> >Hi Dave,
> >
> >I was trying to install DateTime::Format::Strptime this morning, but
> >tests were failing. I think I tracked it down to DateTime::Locale whose
> >generated files (like DateTime/Locale/en.pm) appear to be broken. I was
> >able to build the test files in tools/t/test-data with
> >tools/generate-from-cldr, and there are differences like the following,
> >in en.pm for example:
> >
> >    {
> >   -    my $date_format_full = "EEEE\,\ MMMM\ d\,\ yyyy";
> >   +    my $date_format_full = "EEEE\,\ MMMM\ d\,\ y";
> >        sub date_format_full { return $date_format_full }
> >    }
> >
> >That 'y' instead of 'yyyy' appears to be wrong and breaks tests in
> >DateTime::Format::Strptime.
> 
> This data comes from the latest CLDR data. If you look at the 1.7.1 en.xml 
> files you'll see:
> 
> <dateFormatLength type="full">
>     <dateFormat>
>         <pattern>EEEE, MMMM d, y</pattern>
>     </dateFormat>
> </dateFormatLength>
> 
> So the corresponding en.pm file seems correct to me.
> 
> The Strptime tests rely on a given pattern from a given release of 
> DateTime::Locale, which is not a good idea.
> 
> It'd be best if Strptime could include some copies of the locale data for 
> its own testing.
> 
> 
> -dave

Ah, I think I understand now. It appears that DateTime::Format::Strptime
misinterprets some CLDR patterns, the code expecting for example the 'y'
pattern to mean a short year, like '98', (see
.../DateTime/Format/Strptime.pm, version 1.0901, line 770), instead of
what the CLDR specifies (a long year, like '1998'). This test:

    t/004_locale_defaults.t .. 1/48
    #   Failed test 'en_US : %x : year'
    #   at t/004_locale_defaults.t line 44.
    #          got: '2019'
    #     expected: '1998'
    ...

fails, as it should (the expectation is correct, the 'got' is wrong).

By the way, in the 002_dates.t test, '%y-%m-%d' matches '98-12-31', as
it should I suppose, but not because it's a shortened '1998' for
example, but rather because it's seen as the year '98' literally. Unless
4-digit years are somehow privileged?

Reply via email to