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
`react-big-calendar` is a full featured Calendar component for managing events and dates. It uses modern `flexbox` for layout, making it super responsive and performant. Leaving most of the layout heavy lifting to the browser.
10
+
9
11
Styles can be found at: `react-big-calendar/lib/css/react-big-calendar.css`, and should be included on the page
10
-
with the calendar component. Alternatively, you can include the styles directly in your SASS build. See the [Custom Styling](https://github.com/intljusticemission/react-big-calendar/blob/master/README.md#custom-styling) section of the README file for more details.
12
+
with the calendar component. Alternatively, you can include the styles directly in your SASS build. See the [Custom Styling](https://github.com/jquense/react-big-calendar/blob/master/README.md#custom-styling) section of the README file for more details.
11
13
12
-
Also make sure that your calendar's container
13
-
element has a height, or the calendar won't be visible (see why below).
14
+
Also make sure that your calendar's container element has a height, or the calendar won't be visible (see why below).
14
15
15
16
Date internationalization and localization is **hard** and `react-big-calendar` doesn't even attempt to
16
17
solve that problem. Instead you can use one of the many excellent solutions already
17
-
out there, via adapters called "localizers". Big Calendar comes with two localizers for use
18
-
with [Globalize.js](https://github.com/jquery/globalize) or [Moment.js](http://momentjs.com/).
18
+
out there, via adapters called "localizers". Big Calendar comes with three localizers for use
19
+
with [Globalize.js](https://github.com/jquery/globalize), [Moment.js](http://momentjs.com/) or [Luxon](https://moment.github.io/luxon).
19
20
20
21
Choose the localizer that best suits your needs, or write your own. Whatever you do, you'll need to set it up
21
22
before you can use the calendar (you only need to set it up once).
@@ -24,7 +25,7 @@ before you can use the calendar (you only need to set it up once).
24
25
import { Calendar, momentLocalizer } from'react-big-calendar'
25
26
importmomentfrom'moment'
26
27
27
-
// Setup the localizer by providing the moment (or globalize) Object
28
+
// Setup the localizer by providing the moment (or globalize, or Luxon) Object
28
29
// to the correct localizer.
29
30
constlocalizer=momentLocalizer(moment) // or globalizeLocalizer
30
31
@@ -44,3 +45,6 @@ Once you've configured a localizer, the Calendar is ready to accept `dateFormat`
44
45
how dates will be displayed throughout the component and are specific to the localizer of your choice. For
45
46
instance if you are using the Moment localizer,
46
47
then any [Moment format pattern](http://momentjs.com/docs/#/displaying/format/) is valid!
48
+
49
+
One thing to note is that, `react-big-calendar` treats event start/end dates as an _exclusive_ range which means that the event spans up to, but not including, the end date. In the case of displaying events on whole days, end dates are rounded _up_ to the next day. So an event ending on `Apr 8th 12:00:00 am` will not appear on the 8th, whereas one ending
50
+
on `Apr 8th 12:01:00 am` will. If you want _inclusive_ ranges consider providing a function `endAccessor` that returns the end date + 1 day for those events that end at midnight.
# <aid='timezonesIntro'href='#timezoneIntro'>Dealing With Time Zones</a>
2
+
3
+
Time Zones are... **hard**, and while changing the `culture` will help with internationalization and localization, it does not adjust the dates for a specific time zone. Javascript Date objects don't really support time zone switching natively, and date math gets **very** complicated. Thankfully `react-big-calender` does support `moment` as a localizer, so if you use [moment-timezone](https://momentjs.com/timezone/) you can get your events to display relevant to a time zone other than the browser native.
4
+
5
+
To change your events to display as a specific time zone, you must [change moment's default timezone](https://momentjs.com/timezone/docs/#/using-timezones/default-timezone/) for all dates, **using an IANA time zone**.
6
+
7
+
```jsx
8
+
import { Calendar, momentLocalizer } from'react-big-calendar'
9
+
importmomentfrom'moment'
10
+
import'moment-timezone'// or 'moment-timezone/builds/moment-timezone-with-data[-datarange].js'. See their docs
11
+
12
+
// Set the IANA time zone you want to use
13
+
moment.tz.setDefault('Europe/Paris')
14
+
15
+
// Setup the localizer by providing the moment Object
16
+
// to the correct localizer.
17
+
constlocalizer=momentLocalizer(moment) // or globalizeLocalizer
18
+
19
+
constMyCalendar=props=> (
20
+
<div>
21
+
<Calendar
22
+
localizer={localizer}
23
+
events={myEventsList}
24
+
startAccessor="start"
25
+
endAccessor="end"
26
+
/>
27
+
</div>
28
+
)
29
+
```
30
+
31
+
The `momentLocalizer` will now handle all dates and date math as if the date is in the timezone you specified. It is important to note that [changing moment's default timezone](https://momentjs.com/timezone/docs/#/using-timezones/default-timezone/) affects all dates, created by moment, from that point forward, so you may want to reset the default when your component unmounts. And, if switching timezones 'on-the-fly', you want to update your 'localizer' and any Date based props (min, max, getNow, etc) at the same time.
32
+
33
+
**Note:** The new `luxonLocalizer` operates in a similar fashion. View the 'Luxon Localizer' demo and view it's source for an example of it's usage.
0 commit comments