Skip to content

Commit cc7fc6a

Browse files
authored
Merge pull request #1465 from RicoNL/date-picker-locale
Date picker locale
2 parents 34abdb9 + 391bcef commit cc7fc6a

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

docs/documentation/docs/controls/DateTimePicker.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,11 @@ The `DateTimePicker` control can be configured with the following properties:
5353
| label | string | no | Property field label displayed on top. |
5454
| disabled | boolean | no | Specifies if the control is disabled or not. |
5555
| formatDate | function | no | Defines a formatDate function that can override the output value in Date picker. |
56+
| parseDateFromString | function | no | Optional method to parse the text input value to date, it is only useful when allowTextInput is set to true |
5657
| dateConvention | DateConvention | no | Defines the date convention to use. The default is date and time.|
5758
| timeConvention | TimeConvention | no | Defines the time convention to use. The default value is the 24-hour clock convention. |
5859
| firstDayOfWeek | DayOfWeek | no | Specify the first day of the week for your locale. |
60+
| firstWeekOfYear | FirstWeekOfYear | no | Defines when the first week of the year should start. |
5961
| key | string | no | A unique key that indicates the identity of this control |
6062
| onGetErrorMessage | function | no | The method is used to get the validation error message and determine whether the input value is valid or not. See [this documentation](https://learn.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/guidance/validate-web-part-property-values) to learn how to use it. |
6163
| showGoToToday | boolean | no | Controls whether the "Go to today" link should be shown or not |

src/controls/dateTimePicker/DateTimePicker.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,15 @@ export class DateTimePicker extends React.Component<IDateTimePickerProps, IDateT
227227
timeConvention,
228228
dateConvention = DateConvention.DateTime,
229229
firstDayOfWeek,
230+
firstWeekOfYear,
230231
isMonthPickerVisible = true,
231232
showGoToToday,
232233
allowTextInput = true,
233234
showMonthPickerAsOverlay = false,
234235
showWeekNumbers = false,
235236
showSeconds = false,
236237
formatDate,
238+
parseDateFromString,
237239
value = this.state.day,
238240
strings: dateStrings = new DateTimePickerStrings(), // Defines the DatePicker control labels
239241
timeDisplayControlType,
@@ -322,13 +324,15 @@ export class DateTimePicker extends React.Component<IDateTimePickerProps, IDateT
322324
<div className={styles.picker}>
323325
<DatePicker
324326
formatDate={formatDate}
327+
parseDateFromString={parseDateFromString}
325328
disabled={disabled}
326329
value={value}
327330
strings={dateStrings}
328331
isMonthPickerVisible={isMonthPickerVisible}
329332
onSelectDate={this.onSelectDate}
330333
allowTextInput={allowTextInput}
331334
firstDayOfWeek={firstDayOfWeek}
335+
firstWeekOfYear={firstWeekOfYear}
332336
showGoToToday={showGoToToday}
333337
showMonthPickerAsOverlay={showMonthPickerAsOverlay}
334338
showWeekNumbers={showWeekNumbers}

src/controls/dateTimePicker/IDateTimePickerProps.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DayOfWeek } from 'office-ui-fabric-react/lib/utilities/dateValues/DateValues';
1+
import { DayOfWeek, FirstWeekOfYear } from 'office-ui-fabric-react/lib/utilities/dateValues/DateValues';
22
import { TimeConvention, DateConvention } from './DateTimeConventions';
33
import { IDateTimePickerStrings } from './IDateTimePickerStrings';
44
import { TimeDisplayControlType } from './TimeDisplayControlType';
@@ -24,6 +24,10 @@ export interface IDateTimePickerProps {
2424
* By defaut date.toDateString() is used.
2525
*/
2626
formatDate?: (date: Date) => string;
27+
/**
28+
* Optional method to parse the text input value to date, it is only useful when allowTextInput is set to true
29+
*/
30+
parseDateFromString?: (dateStr: string) => Date;
2731
/**
2832
* Defines the date convention to use. The default is date and time.
2933
*/
@@ -36,6 +40,10 @@ export interface IDateTimePickerProps {
3640
* Specify the first day of the week for your locale.
3741
*/
3842
firstDayOfWeek?: DayOfWeek;
43+
/**
44+
* Defines when the first week of the year should start, FirstWeekOfYear.FirstDay, FirstWeekOfYear.FirstFullWeek or FirstWeekOfYear.FirstFourDayWeek are the possible values
45+
*/
46+
firstWeekOfYear?: FirstWeekOfYear
3947
/**
4048
* An UNIQUE key indicates the identity of this control
4149
*/

0 commit comments

Comments
 (0)