Skip to content

Commit

Permalink
Add support for formatDate to DateTimePicker.
Browse files Browse the repository at this point in the history
Based on pnp#240 by @AJIXuMuK
  • Loading branch information
robert-lindstrom committed Mar 21, 2019
1 parent d86268d commit 47a8fb1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/documentation/docs/controls/DateTimePicker.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ The `DateTimePicker` control can be configured with the following properties:
| ---- | ---- | ---- | ---- |
| label | string | no | Property field label displayed on top. |
| disabled | boolean | no | Specifies if the control is disabled or not. |
| formatDate | function | no | Defines a formatDate function to display the date of the custom Field. By defaut date.toDateString() is used. |
| formatDate | function | no | Defines a formatDate function that can override the output value in Date picker. |
| dateConvention | DateConvention | no | Defines the date convention to use. The default is date and time.|
| timeConvention | TimeConvention | no | Defines the time convention to use. The default value is the 24-hour clock convention. |
| firstDayOfWeek | DayOfWeek | no | Specify the first day of the week for your locale. |
Expand Down
2 changes: 2 additions & 0 deletions src/controls/dateTimePicker/DateTimePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ export class DateTimePicker extends React.Component<IDateTimePickerProps, IDateT
showMonthPickerAsOverlay = false,
showWeekNumbers = false,
showSeconds = false,
formatDate,
value = this.state.day,
strings: dateStrings = new DateTimePickerStrings() // Defines the DatePicker control labels
} = this.props;
Expand Down Expand Up @@ -369,6 +370,7 @@ export class DateTimePicker extends React.Component<IDateTimePickerProps, IDateT
</div>
<div className={styles.picker}>
<DatePicker
formatDate={formatDate}
disabled={disabled}
value={value}
strings={dateStrings}
Expand Down
1 change: 1 addition & 0 deletions src/webparts/controlsTest/components/ControlsTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ export default class ControlsTest extends React.Component<IControlsTestProps, IC

<DateTimePicker
label="DateTime Picker (Controlled)"
formatDate={d => `${d.getFullYear()} - ${d.getMonth() + 1} - ${d.getDate()}`}
dateConvention={DateConvention.DateTime}
timeConvention={TimeConvention.Hours24}
firstDayOfWeek={DayOfWeek.Monday}
Expand Down

0 comments on commit 47a8fb1

Please sign in to comment.