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

15/05/1987 → MM/DD/YYYY #8

Closed brunomacf closed 10 years ago

brunomacf commented 10 years ago

moment.parseFormat('15/05/1987') parsed to MM/DD/YYYY, I expected: <please fill in>

The correct would be DD/MM/YYYY!!

gr2m commented 10 years ago

Usually the / is used in the US as separator in the date, which has the Month-Day-Year order. For Day-Month-Year, use . as separator. Is that not the convention where come from?

brunomacf commented 10 years ago

I'm from Brazil and here the convention is DD/MM/YYYY

gr2m commented 10 years ago

Good to know, cheers! I'll add an additional check if the day part is > 12 and if yes, I'll swap the order. It's not a bullet proof solution, but better than nothing I guess.

onecreative commented 10 years ago

It could be beneficial to check for the country or region before the script decides which method to favor. I believe it is mostly the US that puts the month first, whereas the UK and AU put the day first.

By collecting information on how different areas show their dates, you could group the logic that way. You can also provide an option for explicitly stating the region. I think this would provide for a very intuitive user experience.

gr2m commented 10 years ago

this is fixed via 491494e.

It could be beneficial to check for the country or region before the script decides which method to favor

I agree. But I'd leave that to another library. It could determine the preferred order and pass it as preferredOrder option