iamkun / dayjs

⏰ Day.js 2kB immutable date-time library alternative to Moment.js with the same modern API
https://day.js.org
MIT License
47k stars 2.3k forks source link

en-US locale is missing #1532

Open m-zzz opened 3 years ago

m-zzz commented 3 years ago

Describe the bug Is the locale "en" the same as "en-us"? I see here https://unpkg.com/dayjs@1.10.5/locale.json just "es-us" locale for United States.

Expected behavior Maybe it make sense to add also "en-us" locale?

Information

MirzaLeka commented 3 years ago

I believe the DayJS defaults to en-us when you don't specify any or set locale as 'en-us' without importing it. I think en locale is the same as en-gb

But yeah it's confusing

barrymichaeldoyle commented 2 years ago

A bit frustrating since en-gb and en-us aren't the same... Eg. in US dates are formatted like MM/DD/YYYY, however in GB it's formatted like this: DD/MM/YYYY

MirzaLeka commented 2 years ago

It's simple really. If you need to use one or the other, just call the locale method with it.

dayjs().locale('en-us').format('ll'); // Dec 21, 2021
dayjs().locale('en-gb').format('ll'); // 21 Dec 2021

Given that en-US is the default, you won't be importing it. You can learn more about Day.js locales here.

barrymichaeldoyle commented 2 years ago

That that's not working... When I set my locale to en-gb the date format is still MM/DD/YYYY when it should be DD/MM/YYYY

barrymichaeldoyle commented 2 years ago

Nevermind, I got it sorted after readying your blog post, thank you!

hervehobbes commented 2 years ago

When using the localeData plugin, except if you use (load) 'en-gb', you don't have the requested functions (methods), for example globalLocaleData.longDateFormat('L') or globalLocaleData.weekdaysMin() and so on.