You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Normally, you can get a list of weekdays like so: moment.weekdays() and if you want them ordered in a localized way (such as Montag/monday as first day of week for Germany) you can do moment.weekdays(true)
But when using the "Accessing locale specific functionality" approach (https://momentjs.com/docs/#/i18n/locale-data/), the .weekdays() method throws the error Uncaught TypeError: m.day is not a function if you try to pass true as the first argument ... localeData = moment.localeData(); localeData.weekdays(true)
And if you omit the first argument to weekdays, then you get the days names in the correct localized language, but they are not in the correct localized order (first day of week is always Sunday [incorrect] but the day name are in the localized language [correct])
What I'd like to do is use an "instance specific locale" (DE) https://momentjs.com/docs/#/i18n/instance-locale/ and then get the weekdays array in a localized way (with montag/monday as the first day of the week), but I can't seem to get around the .weekdays(true) error
moment.locale('en'); // default the locale to English
const localLocale = moment();
localLocale.locale('de'); // set this instance to use German
localLocale.locale(); // --> 'de' (confirm instance is German)
moment.locale(); // --> 'en (confirmglobal is still default/English)
localLocale.localeData().weekdays(); // --> (7) ["Sonntag", "Montag", ...] (week starts on Sonntag/Sunday but I want Montag/Monday
localLocale.localeData().weekdays(true); // --> Uncaught TypeError: m.day is not a function (was hopeful for Montag/Monday as first day of week
moment.weekdays(true); // --> (7) ["Sunday", "Monday", ...] (still works for default/english)
moment.localeData().weekdays(true); // --> Uncaught TypeError: m.day is not a function
Environment:
This can be replicated in the dev tools console on the momentjs.com/docs site (I tried in Chrome 69/MacOS)
moment.locale('de') localeData = moment.localeData() localeData.weekdays(); // starts with 'Sonntag' (Sunday) but should be Montag/Monday localeData.weekdays(true); // throws error
Other information that may be helpful:
The time zone setting of the machine the code is running on
The time and date at which the code was run
Other libraries in use (TypeScript, Immutable.js, etc)
If you are reporting an issue, please run the following code in the environment you are using and include the output:
console.log((newDate()).toString())// Thu Sep 20 2018 14:34:30 GMT+0200 (Central European Summer Time)console.log((newDate()).toLocaleString())// 9/20/2018, 2:34:30 PMconsole.log((newDate()).getTimezoneOffset())// -120console.log(navigator.userAgent)// Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36console.log(moment.version)// 2.22.2
The text was updated successfully, but these errors were encountered:
Description of the Issue and Steps to Reproduce:
Normally, you can get a list of weekdays like so:
moment.weekdays()
and if you want them ordered in a localized way (such as Montag/monday as first day of week for Germany) you can domoment.weekdays(true)
But when using the "Accessing locale specific functionality" approach (https://momentjs.com/docs/#/i18n/locale-data/), the .weekdays() method throws the error
Uncaught TypeError: m.day is not a function
if you try to passtrue
as the first argument ...localeData = moment.localeData(); localeData.weekdays(true)
And if you omit the first argument to weekdays, then you get the days names in the correct localized language, but they are not in the correct localized order (first day of week is always Sunday [incorrect] but the day name are in the localized language [correct])
What I'd like to do is use an "instance specific locale" (DE) https://momentjs.com/docs/#/i18n/instance-locale/ and then get the weekdays array in a localized way (with montag/monday as the first day of the week), but I can't seem to get around the .weekdays(true) error
Environment:
This can be replicated in the dev tools console on the momentjs.com/docs site (I tried in Chrome 69/MacOS)
moment.locale('de')
localeData = moment.localeData()
localeData.weekdays(); // starts with 'Sonntag' (Sunday) but should be Montag/Monday
localeData.weekdays(true); // throws error
Other information that may be helpful:
If you are reporting an issue, please run the following code in the environment you are using and include the output:
The text was updated successfully, but these errors were encountered: