javascript - Getting what is the first day of the week based on Locale with momentJs -
using momentjs, possible first day of week (monday(1), sunday(7)...) based on locale without creating new moment?
i know can access first day of week current locale with:
moment.locale('uk'); moment().startof('week').isoweekday(); //returns 1 moment.locale('en'); moment().startof('week').isoweekday(); //returns 7
but think it's bit ugly...
creating momentjs object. going first date of week. resolving weekday.any improve idea? thx!
this question has proper reply in momentjs's current api:
moment.localedata('en-us').firstdayofweek();
as op asked - no instance of moment() needed, no ugliness of going "start of", plain simple utilize of localedata.
note, might required download moment+locale file larger (44kb) moment (about 12kb).
seems case version 2.2.0, more info can found on docs: http://momentjs.com/docs/#/i18n/locale-data/
javascript momentjs
No comments:
Post a Comment