Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use localeData ? #542

Closed
y0c opened this issue Mar 24, 2019 · 6 comments
Closed

How to use localeData ? #542

y0c opened this issue Mar 24, 2019 · 6 comments

Comments

@y0c
Copy link
Contributor

y0c commented Mar 24, 2019

Hi
i want to change moment.js to day.js in my library.

I wonder how to use localaleData in day.js.
In case of moment.js

moment.localeData(locale).monthsShort()
@iamkun
Copy link
Owner

iamkun commented Mar 24, 2019

@y0c
update doc: https://day.js.org/docs/en/plugin/locale-data

We have an experimental plugin localeData from v1.8.10

import dayjs from 'dayjs'
import localeData from 'dayjs/plugin/localeData'
import 'dayjs/locale/ko'

dayjs.extend(localeData) // use plugin
dayjs.locale('ko') // use locale

dayjs().localeData().monthsShort(dayjs())

demo: https://runkit.com/embed/488qfv8m02rz

And if you only want to get the locale object, just import ko from 'dayjs/locale/ko', like this https://github.com/iamkun/dayjs/blob/dev/docs/en/I18n.md#customize

feedback is welcomed.

@y0c
Copy link
Contributor Author

y0c commented Mar 24, 2019

Great, Thanks ! :)

@iamkun iamkun closed this as completed Apr 2, 2019
@gpbl
Copy link

gpbl commented Aug 11, 2019

Isn't there a way to get the locale object from a dayjs date?

Also I find the syntax for dayjs().localeData().monthsShort(dayjs()) a bit confusing. Which one of the two dayjs() instances should be the localized ones? Why do i have to pass to dayjs() instances and not just dayjs().localeData()?

Thanks.

@iamkun
Copy link
Owner

iamkun commented Aug 11, 2019

updates #645

@transtone
Copy link

transtone commented Feb 23, 2020

weeksMin, weeksShort ?

@iamkun
Copy link
Owner

iamkun commented Feb 23, 2020

@transtone do you mean weekdaysMin weekdaysShort ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants