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 get the locale format? #680

Closed
Tropicalista opened this issue Sep 20, 2019 · 11 comments · Fixed by #734 or BlueWallet/BlueWallet#862 · May be fixed by cds-snc/apply-for-a-grant#32
Closed

How to get the locale format? #680

Tropicalista opened this issue Sep 20, 2019 · 11 comments · Fixed by #734 or BlueWallet/BlueWallet#862 · May be fixed by cds-snc/apply-for-a-grant#32
Labels

Comments

@Tropicalista
Copy link

What is the equivalent of this moment code?

moment.localeData().longDateFormat('L')

@iamkun
Copy link
Owner

iamkun commented Sep 20, 2019

We will add it later to LocaleData plugin https://github.com/iamkun/dayjs/blob/dev/src/plugin/localeData/index.js

You can get it in this way at the present

var dayjs = require("dayjs")
var LocalizedFormat = require( 'dayjs/plugin/localizedFormat')

dayjs.extend(LocalizedFormat)

console.log(dayjs.Ls.en.formats.L)

@Tropicalista
Copy link
Author

Thanks!

@donedgardo
Copy link

donedgardo commented Nov 14, 2019

@iamkun has this been added? currently trying to use react-dates from airbnb with dayjs. And it uses this longDateFormat method :/
react-dates/react-dates#1294

@Tropicalista
Copy link
Author

It's not added at the moment

@iamkun
Copy link
Owner

iamkun commented Nov 15, 2019

Sorry for the delay, I'll add it today 😁

@iamkun
Copy link
Owner

iamkun commented Nov 15, 2019

Added in #734, and will be available in the next release.

Usage:

var dayjs = require("dayjs")
var LocalizedFormat = require( 'dayjs/plugin/localizedFormat')
var localeData = require( 'dayjs/plugin/localeData')

dayjs.extend(LocalizedFormat)
dayjs.extend(localeData)

console.log(dayjs().localeData().longDateFormat('L'))

@donedgardo
Copy link

donedgardo commented Nov 18, 2019

You are amazing thanks!

iamkun pushed a commit that referenced this issue Dec 18, 2019
## [1.8.18](v1.8.17...v1.8.18) (2019-12-18)

### Bug Fixes

* Add missing locale type definition ([#716](#716)) ([cde5d0b](cde5d0b))
* Fix .locale() handel unsupported locale ([78ec173](78ec173))
* Update Italian locale (it) ([#727](#727)) ([5b53e98](5b53e98))
* Update locale (fa) ([#733](#733)) ([9ad2e47](9ad2e47))
* Update locale (zh-cn) ([#706](#706)) ([e31e544](e31e544))
* Update locale (zh-cn) meridiem ([#735](#735)) ([15d1b81](15d1b81))
* Update LocaleData plugin to support dayjs().longDateFormat() ([#734](#734)) ([aa0f210](aa0f210)), closes [#680](#680)
* Update Mongolian (mn) locale relativeTime ([#753](#753)) ([6d51435](6d51435))
* Update Swedish locale (sv) fix ordinal error ([#745](#745)) ([49670d5](49670d5)), closes [#743](#743)
@iamkun
Copy link
Owner

iamkun commented Dec 18, 2019

🎉 This issue has been resolved in version 1.8.18 🎉

The release is available on:

Your semantic-release bot 📦🚀

@andruskutt
Copy link

Seems that localeData().longDateFormat('L') is implemented only for instance:
dayjs().localeData().longDateFormat('L')

dayjs.localeData().longDateFormat('L') is missing.

Adding
longDateFormat: format => localeObject.longDateFormat(format)
somewhere here https://github.com/iamkun/dayjs/blob/dev/src/plugin/localeData/index.js#L41
should be enough?

@iamkun
Copy link
Owner

iamkun commented Sep 30, 2020

Thanks, @xvaara added longDateFormat to global localeData #1106

@xrzhuang
Copy link

xrzhuang commented Jun 4, 2021

how do I test that this works? I want to observe localeData() on various different formats. For example it appears to work on my browser, but I want to view the result for other locales like de

andrewhood125ruhuc added a commit to andrewhood125ruhuc/SidRH2 that referenced this issue May 10, 2022
## [1.8.18](iamkun/dayjs@v1.8.17...v1.8.18) (2019-12-18)

### Bug Fixes

* Add missing locale type definition ([#716](iamkun/dayjs#716)) ([cde5d0b](iamkun/dayjs@cde5d0b))
* Fix .locale() handel unsupported locale ([78ec173](iamkun/dayjs@78ec173))
* Update Italian locale (it) ([#727](iamkun/dayjs#727)) ([5b53e98](iamkun/dayjs@5b53e98))
* Update locale (fa) ([#733](iamkun/dayjs#733)) ([9ad2e47](iamkun/dayjs@9ad2e47))
* Update locale (zh-cn) ([#706](iamkun/dayjs#706)) ([e31e544](iamkun/dayjs@e31e544))
* Update locale (zh-cn) meridiem ([#735](iamkun/dayjs#735)) ([15d1b81](iamkun/dayjs@15d1b81))
* Update LocaleData plugin to support dayjs().longDateFormat() ([#734](iamkun/dayjs#734)) ([aa0f210](iamkun/dayjs@aa0f210)), closes [#680](iamkun/dayjs#680)
* Update Mongolian (mn) locale relativeTime ([#753](iamkun/dayjs#753)) ([6d51435](iamkun/dayjs@6d51435))
* Update Swedish locale (sv) fix ordinal error ([#745](iamkun/dayjs#745)) ([49670d5](iamkun/dayjs@49670d5)), closes [#743](iamkun/dayjs#743)
andrewhood125ruhuc added a commit to andrewhood125ruhuc/SidRH2 that referenced this issue May 10, 2022
## [1.8.18](iamkun/dayjs@v1.8.17...v1.8.18) (2019-12-18)

### Bug Fixes

* Add missing locale type definition ([#716](iamkun/dayjs#716)) ([cde5d0b](iamkun/dayjs@cde5d0b))
* Fix .locale() handel unsupported locale ([78ec173](iamkun/dayjs@78ec173))
* Update Italian locale (it) ([#727](iamkun/dayjs#727)) ([5b53e98](iamkun/dayjs@5b53e98))
* Update locale (fa) ([#733](iamkun/dayjs#733)) ([9ad2e47](iamkun/dayjs@9ad2e47))
* Update locale (zh-cn) ([#706](iamkun/dayjs#706)) ([e31e544](iamkun/dayjs@e31e544))
* Update locale (zh-cn) meridiem ([#735](iamkun/dayjs#735)) ([15d1b81](iamkun/dayjs@15d1b81))
* Update LocaleData plugin to support dayjs().longDateFormat() ([#734](iamkun/dayjs#734)) ([aa0f210](iamkun/dayjs@aa0f210)), closes [#680](iamkun/dayjs#680)
* Update Mongolian (mn) locale relativeTime ([#753](iamkun/dayjs#753)) ([6d51435](iamkun/dayjs@6d51435))
* Update Swedish locale (sv) fix ordinal error ([#745](iamkun/dayjs#745)) ([49670d5](iamkun/dayjs@49670d5)), closes [#743](iamkun/dayjs#743)
splashwizard pushed a commit to splashwizard/tracking-time that referenced this issue Oct 21, 2024
## [1.8.18](iamkun/dayjs@v1.8.17...v1.8.18) (2019-12-18)

### Bug Fixes

* Add missing locale type definition ([#716](iamkun/dayjs#716)) ([cde5d0b](iamkun/dayjs@cde5d0b))
* Fix .locale() handel unsupported locale ([78ec173](iamkun/dayjs@78ec173))
* Update Italian locale (it) ([#727](iamkun/dayjs#727)) ([5b53e98](iamkun/dayjs@5b53e98))
* Update locale (fa) ([#733](iamkun/dayjs#733)) ([9ad2e47](iamkun/dayjs@9ad2e47))
* Update locale (zh-cn) ([#706](iamkun/dayjs#706)) ([e31e544](iamkun/dayjs@e31e544))
* Update locale (zh-cn) meridiem ([#735](iamkun/dayjs#735)) ([15d1b81](iamkun/dayjs@15d1b81))
* Update LocaleData plugin to support dayjs().longDateFormat() ([#734](iamkun/dayjs#734)) ([aa0f210](iamkun/dayjs@aa0f210)), closes [#680](iamkun/dayjs#680)
* Update Mongolian (mn) locale relativeTime ([#753](iamkun/dayjs#753)) ([6d51435](iamkun/dayjs@6d51435))
* Update Swedish locale (sv) fix ordinal error ([#745](iamkun/dayjs#745)) ([49670d5](iamkun/dayjs@49670d5)), closes [#743](iamkun/dayjs#743)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment