react-big-calendar: Start week from Monday instead of Sunday? (localizer not working)
I’m not sure but this seems that it’s not working anymore and there is a bit of inconsistency from docs and github repo.
In the docs http://intljusticemission.github.io/react-big-calendar/examples/index.html#intro
import BigCalendar from 'react-big-calendar';
import moment from 'moment';
// Setup the localizer by providing the moment (or globalize) Object
// to the correct localizer.
BigCalendar.momentLocalizer(moment); // or globalizeLocalizer
I tried this also with moment.locale('en-GB')
before passing the object.
Then I checked the master repo and seems different:
BigCalendar.setLocalizer(
BigCalendar.momentLocalizer(moment)
);
Both of them are not working for me anyway, the week is always starting on Sunday when it’s supposed to start on Monday.
Which one is supposed to be correct?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 16 (4 by maintainers)
Found the issue, for some reason using webpack it’s not importing the locales so it always default to
en
which isen-us
noten-gb
This is the fix:
for me only the following worked:
Please, mind that in your proposal (that, by the way, fixed my problem), your
startOfWeek
property doesn’t return a thing. The correct code would be:you can setup start week in package date-fns for all language by way.
import startOfWeek from 'date-fns/startOfWeek’import getDay from 'date-fns/getDay’const locales = { ‘en-US’: require(‘date-fns/locale/en-US’), }const localizer = dateFnsLocalizer({ format, parse, startOfWeek: ()=> { startOfWeek(new Date(), { weekStartsOn: 0 }) }, getDay, locales, })
with 0 - Sunday 1 - Monday …
Vào 22:01, Th 2, 30 thg 11, 2020 Petar Ćevriz notifications@github.com đã viết:
Hello,
I am using moment to set locale as well and this is working for me:
Hope it helps…
you can add props for Calendar <Calendar … culture="en-GB />
Thank you!