Skip to content

Commit bfdf77c

Browse files
[WC-2892]: Calendar time format (#1729)
2 parents cf6e6bc + d479904 commit bfdf77c

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

packages/pluggableWidgets/calendar-web/src/Calendar.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@
114114
<attributeType name="DateTime" />
115115
</attributeTypes>
116116
</property>
117+
<property key="timeFormat" type="textTemplate" required="false">
118+
<caption>Time format</caption>
119+
<description>Default time format is "hh:mm a"</description>
120+
</property>
117121
<property key="minHour" type="integer" defaultValue="0">
118122
<caption>Day start hour</caption>
119123
<description>The hour at which the day view starts (0–23)</description>

packages/pluggableWidgets/calendar-web/src/helpers/CalendarPropsBuilder.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { ObjectItem } from "mendix";
2-
import { CalendarProps as ReactCalendarProps, Formats, NavigateAction, ViewsProps } from "react-big-calendar";
2+
import {
3+
CalendarProps as ReactCalendarProps,
4+
DateLocalizer,
5+
Formats,
6+
NavigateAction,
7+
ViewsProps
8+
} from "react-big-calendar";
39
import { withDragAndDropProps } from "react-big-calendar/lib/addons/dragAndDrop";
410

511
import { CalendarContainerProps } from "../../typings/CalendarProps";
@@ -115,6 +121,14 @@ export class CalendarPropsBuilder {
115121
formats.eventTimeRangeFormat = () => "";
116122
}
117123

124+
if (this.props.timeFormat?.status === "available") {
125+
const timeFormat = this.props.timeFormat.value ?? "hh:mm a";
126+
127+
formats.timeGutterFormat = (date: Date, _culture: string, localizer: DateLocalizer) => {
128+
return localizer.format(date, timeFormat);
129+
};
130+
}
131+
118132
return formats;
119133
}
120134

packages/pluggableWidgets/calendar-web/typings/CalendarProps.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export interface CalendarContainerProps {
4646
defaultViewCustom: DefaultViewCustomEnum;
4747
defaultViewStandard: DefaultViewStandardEnum;
4848
startDateAttribute?: EditableValue<Date>;
49+
timeFormat?: DynamicValue<string>;
4950
minHour: number;
5051
maxHour: number;
5152
customViewCaption?: DynamicValue<string>;
@@ -99,6 +100,7 @@ export interface CalendarPreviewProps {
99100
defaultViewCustom: DefaultViewCustomEnum;
100101
defaultViewStandard: DefaultViewStandardEnum;
101102
startDateAttribute: string;
103+
timeFormat: string;
102104
minHour: number | null;
103105
maxHour: number | null;
104106
customViewCaption: string;

0 commit comments

Comments
 (0)