Coder Social home page Coder Social logo

Comments (9)

elado avatar elado commented on May 17, 2024 39

Just pasting here the full code to update locale:

moment.updateLocale('en', {
  week: {
    dow: 1,
  },
})

from react-dates.

ezequiel9 avatar ezequiel9 commented on May 17, 2024 31

Use
date.startOf('isoWeek'); instead of date.startOf('week');

from react-dates.

gautam-pahuja avatar gautam-pahuja commented on May 17, 2024 21

Doing this:

moment.updateLocale('en', {
  week: {
    dow: 1,
  },
})

and then This:

moment.weekdays() 

gives me:
["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]

Anyone else facing this?

from react-dates.

prabhsaran avatar prabhsaran commented on May 17, 2024 13

pass in true to the weekdays function
moment.weekdays(true)
so they are returned in locale specific order

from react-dates.

ljharb avatar ljharb commented on May 17, 2024 11

Moment docs imply that this is a locale-specific setting.

http://momentjs.com/docs/#/customization/ indicates that to override this, you should create your own moment locale - it looks like per http://momentjs.com/docs/#/i18n/changing-locale/ you can set this with:

week: {
  dow: 1
}

Since moment already handles this, perhaps it's best to leave it to that lib?

from react-dates.

vladbalan avatar vladbalan commented on May 17, 2024 3

Has anyone verified that it works? I set my moment()._locale._week.dow to 1, but the calendar still displays Su as the first day of the week.

from react-dates.

rodrigoespinozadev avatar rodrigoespinozadev commented on May 17, 2024 3

Use
date.startOf('isoWeek'); instead of date.startOf('week');

Thanks for the help

from react-dates.

majapw avatar majapw commented on May 17, 2024

Yeah! I don't think this is an issue for us to take on so much as for moment localization. For instance, if you change the locale to es you'll see that the week starts on Monday.

Which means that for your own app you should be able to alter this using moment. I'm going to close this as won't fix.

from react-dates.

majapw avatar majapw commented on May 17, 2024

Hi @vladbalan, I am not sure that you can set the starting weekday in moment that way. I do know that if you look at pl.airbnb.com, the calendar starts on Monday:
screen shot 2017-01-27 at 10 05 34 pm

This was done by calling moment.locale('pl'). Perhaps the parentheses are throwing it off. That is a moment object instead of the general moment class.

from react-dates.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.