Skip to content

Commit 1797cd7

Browse files
committed
Merge branch 'PrasadKasireddy-patch-1' of https://github.com/PrasadKasireddy/sp-dev-fx-controls-react into PrasadKasireddy-PrasadKasireddy-patch-1
2 parents a9a02fb + 371ad08 commit 1797cd7

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

docs/documentation/docs/controls/DateTimePicker.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ The `DateTimePicker` control can be configured with the following properties:
6969
| timeDisplayControlType | TimeDisplayControlType | no | Specifies what type of control to use when rendering time part. |
7070
| showLabels | boolean | no | Specifies if labels in front of date and time parts should be rendered. |
7171
| placeholder | string | no | Placeholder text for the DatePicker. |
72+
| maxDate | Date | no | The maximum allowable date. |
73+
| minDate | Date | no | The minimum allowable date. |
7274

7375
Enum `TimeDisplayControlType`
7476

src/controls/dateTimePicker/DateTimePicker.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { Async, css } from 'office-ui-fabric-react/lib/Utilities';
1515
import { IDateTimePickerProps, IDateTimePickerState, DateTimePickerStrings } from ".";
1616
import { TimeHelper } from "./TimeHelper";
1717
import { TimeDisplayControlType } from "./TimeDisplayControlType";
18+
import { addMonths, addYears } from 'office-ui-fabric-react/lib/utilities/dateMath/DateMath';
1819

1920
interface IDateComponents {
2021
day: Date;
@@ -53,7 +54,8 @@ export class DateTimePicker extends React.Component<IDateTimePickerProps, IDateT
5354
hours,
5455
minutes,
5556
seconds,
56-
errorMessage: ''
57+
errorMessage: '',
58+
today: new Date(Date.now())
5759
};
5860

5961
this.async = new Async(this);
@@ -205,7 +207,9 @@ export class DateTimePicker extends React.Component<IDateTimePickerProps, IDateT
205207
strings: dateStrings = new DateTimePickerStrings(), // Defines the DatePicker control labels
206208
timeDisplayControlType,
207209
placeholder,
208-
showLabels
210+
showLabels,
211+
minDate = addYears(this.state.today, 1),
212+
maxDate = addYears(this.state.today, 1)
209213
} = this.props;
210214

211215
const hours: number = value != null ? value.getHours() : this.state.hours;
@@ -293,6 +297,8 @@ export class DateTimePicker extends React.Component<IDateTimePickerProps, IDateT
293297
showMonthPickerAsOverlay={showMonthPickerAsOverlay}
294298
showWeekNumbers={showWeekNumbers}
295299
placeholder={placeholder}
300+
minDate={minDate}
301+
maxDate={maxDate}
296302
/>
297303
</div>
298304
</div>

src/controls/dateTimePicker/IDateTimePickerProps.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,16 @@ export interface IDateTimePickerProps {
107107
* Placeholder text for the DatePicker
108108
*/
109109
placeholder?: string;
110+
111+
/**
112+
* The minimum allowable date for the DatePicker
113+
*/
114+
115+
minDate?: Date;
116+
117+
/**
118+
* The maximum allowable date for the DatePicker
119+
*/
120+
121+
maxDate?: Date;
110122
}

src/controls/dateTimePicker/IDateTimePickerState.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ export interface IDateTimePickerState {
77
minutes?: number;
88
seconds?: number;
99
errorMessage?: string;
10+
today: Date;
1011
}

0 commit comments

Comments
 (0)