diff --git a/packages/pluggableWidgets/calendar-web/src/Calendar.xml b/packages/pluggableWidgets/calendar-web/src/Calendar.xml index 8759359961..59bbc47589 100644 --- a/packages/pluggableWidgets/calendar-web/src/Calendar.xml +++ b/packages/pluggableWidgets/calendar-web/src/Calendar.xml @@ -114,6 +114,10 @@ + + Time format + Default time format is "hh:mm a" + Day start hour The hour at which the day view starts (0–23) diff --git a/packages/pluggableWidgets/calendar-web/src/helpers/CalendarPropsBuilder.ts b/packages/pluggableWidgets/calendar-web/src/helpers/CalendarPropsBuilder.ts index 9aa4dced4f..29f6ca0428 100644 --- a/packages/pluggableWidgets/calendar-web/src/helpers/CalendarPropsBuilder.ts +++ b/packages/pluggableWidgets/calendar-web/src/helpers/CalendarPropsBuilder.ts @@ -1,5 +1,11 @@ import { ObjectItem } from "mendix"; -import { CalendarProps as ReactCalendarProps, Formats, NavigateAction, ViewsProps } from "react-big-calendar"; +import { + CalendarProps as ReactCalendarProps, + DateLocalizer, + Formats, + NavigateAction, + ViewsProps +} from "react-big-calendar"; import { withDragAndDropProps } from "react-big-calendar/lib/addons/dragAndDrop"; import { CalendarContainerProps } from "../../typings/CalendarProps"; @@ -115,6 +121,14 @@ export class CalendarPropsBuilder { formats.eventTimeRangeFormat = () => ""; } + if (this.props.timeFormat?.status === "available") { + const timeFormat = this.props.timeFormat.value ?? "hh:mm a"; + + formats.timeGutterFormat = (date: Date, _culture: string, localizer: DateLocalizer) => { + return localizer.format(date, timeFormat); + }; + } + return formats; } diff --git a/packages/pluggableWidgets/calendar-web/typings/CalendarProps.d.ts b/packages/pluggableWidgets/calendar-web/typings/CalendarProps.d.ts index c042e7c7fe..85db3e5cd8 100644 --- a/packages/pluggableWidgets/calendar-web/typings/CalendarProps.d.ts +++ b/packages/pluggableWidgets/calendar-web/typings/CalendarProps.d.ts @@ -46,6 +46,7 @@ export interface CalendarContainerProps { defaultViewCustom: DefaultViewCustomEnum; defaultViewStandard: DefaultViewStandardEnum; startDateAttribute?: EditableValue; + timeFormat?: DynamicValue; minHour: number; maxHour: number; customViewCaption?: DynamicValue; @@ -99,6 +100,7 @@ export interface CalendarPreviewProps { defaultViewCustom: DefaultViewCustomEnum; defaultViewStandard: DefaultViewStandardEnum; startDateAttribute: string; + timeFormat: string; minHour: number | null; maxHour: number | null; customViewCaption: string;