[react-big-calendar] add dateFnsLocalizer() (#42250)

* add dateFnsLocalizer()

* test
This commit is contained in:
Antoine Rousseau
2020-02-13 17:44:02 -08:00
committed by GitHub
parent 8cbc83c0d1
commit ceecc45f35
2 changed files with 24 additions and 0 deletions
+1
View File
@@ -337,6 +337,7 @@ export interface components {
}
export function globalizeLocalizer(globalizeInstance: object): DateLocalizer;
export function momentLocalizer(momentInstance: object): DateLocalizer;
export function dateFnsLocalizer(config: object): DateLocalizer;
export interface Navigate {
PREVIOUS: 'PREV';
NEXT: 'NEXT';
@@ -5,6 +5,7 @@ import {
CalendarProps,
momentLocalizer,
globalizeLocalizer,
dateFnsLocalizer,
move,
Views,
components,
@@ -22,6 +23,7 @@ import withDragAndDrop from "react-big-calendar/lib/addons/dragAndDrop";
// Don't want to add this as a dependency, because it is only used for tests.
declare const globalize: any;
declare const moment: any;
declare const dateFnsConfig: any;
declare const allViews: View[];
@@ -78,6 +80,27 @@ class CalendarResource {
ReactDOM.render(<Basic localizer={localizer} />, document.body);
}
// date-fns Example Test
{
interface Props {
localizer: DateLocalizer;
}
const Basic = ({ localizer }: Props) => (
<Calendar
events={getEvents()}
views={allViews}
step={60}
showMultiDayTimes
defaultDate={new Date(2015, 3, 1)}
localizer={localizer}
/>
);
const localizer = dateFnsLocalizer(dateFnsConfig);
ReactDOM.render(<Basic localizer={localizer} />, document.body);
}
// Drag and Drop Example Test
{
interface Props {