MadMG / moment-jdateformatparser

Translates the `java.text.SimpleDateFormat` date format to the `moment.js` date format.
MIT License
58 stars 29 forks source link

Single 'y' representation of year #6

Closed peterot closed 9 years ago

peterot commented 9 years ago

Hi,

I recently found that after an upgrade to Angular 1.3.9 some of the standard AngularJS $locale DATETIME_FORMATS were no longer converting properly to the moment equivalent. It turns out that many of the DATETIME_FORMATS strings were converted to use the single 'y' representation of the year instead of the 'yyyy'.

It seems a little odd but unlike the 'yy' string, this should result in full display of the year (just with no padding 0s for years of fewer than 4 digits).

From the angular locale docs: 'y': 1 digit representation of year, e.g. (AD 1 => 1, AD 199 => 199)

It appears that SimpleDateFormat exhibits the same behaviour.

It looks like there isn't an exact equivalent of 'y' in momentjs format strings but the addition of the javaFormatMapping - y: 'YYYY' might provide an approximation.

Thanks

herom commented 9 years ago

hey @peterot thanks a lot for raising the issue and sorry for the long delay in the response. I talked to @MadMG earlier and we'll incorporate the y:YYYY mapping to match the SimpleDataFormat formats.

:+1: