gr2m / moment-parseformat

A moment.js plugin to extract the format of a date/time string
http://gr2m.github.io/moment-parseformat
Apache License 2.0
45 stars 30 forks source link

3-1-81 → YY-M-D #12

Closed onecreative closed 9 years ago

onecreative commented 10 years ago

moment.parseFormat('3-1-81') parsed to YY-M-D, I expected: M-D-YY

Looks like this is still a problem. I checked 9-17-80, and it worked, but I'm guessing that was because of the 17.

gr2m commented 10 years ago

yes, 9-17-80 is parsed correctly, 3-1-81 should be parsed as D-M-Y, as 81 can only be a year, and the default fallback is DMY.

It works as expected when you do

moment.parseFormat('3-1-81', {preferredOrder: 'MDY'})
gr2m commented 9 years ago

Fixed via https://github.com/gr2m/moment.parseFormat/commit/5d3230648c41933075d34b49f3ad4c9eed342223

It now parses to D-M-YY. If you prefer the Month-Day-Year order, pass {preferredOrder: 'MDY'}