Skip to content

Commit 207e204

Browse files
authored
Remove millisecond granularity from date/time pickers (#3435)
Fixes #3117
1 parent a9736a1 commit 207e204

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

packages/@react-spectrum/datepicker/src/DatePicker.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ function DatePicker<T extends DateValue>(props: SpectrumDatePickerProps<T>, ref:
104104
let timePlaceholder = placeholder && 'hour' in placeholder ? placeholder : null;
105105
let timeMinValue = props.minValue && 'hour' in props.minValue ? props.minValue : null;
106106
let timeMaxValue = props.maxValue && 'hour' in props.maxValue ? props.maxValue : null;
107-
let timeGranularity = state.granularity === 'hour' || state.granularity === 'minute' || state.granularity === 'second' || state.granularity === 'millisecond' ? state.granularity : null;
107+
let timeGranularity = state.granularity === 'hour' || state.granularity === 'minute' || state.granularity === 'second' ? state.granularity : null;
108108
let showTimeField = !!timeGranularity;
109109

110110
let visibleMonths = useVisibleMonths(maxVisibleMonths);

packages/@react-spectrum/datepicker/src/DateRangePicker.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ function DateRangePicker<T extends DateValue>(props: SpectrumDateRangePickerProp
104104
let timePlaceholder = placeholder && 'hour' in placeholder ? placeholder : null;
105105
let timeMinValue = props.minValue && 'hour' in props.minValue ? props.minValue : null;
106106
let timeMaxValue = props.maxValue && 'hour' in props.maxValue ? props.maxValue : null;
107-
let timeGranularity = state.granularity === 'hour' || state.granularity === 'minute' || state.granularity === 'second' || state.granularity === 'millisecond' ? state.granularity : null;
107+
let timeGranularity = state.granularity === 'hour' || state.granularity === 'minute' || state.granularity === 'second' ? state.granularity : null;
108108
let showTimeField = !!timeGranularity;
109109

110110
let visibleMonths = useVisibleMonths(maxVisibleMonths);

packages/@react-stately/datepicker/src/useDatePickerState.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export function useDatePickerState(props: DatePickerStateOptions): DatePickerSta
7171
let v = (value || props.placeholderValue);
7272
let [granularity, defaultTimeZone] = useDefaultProps(v, props.granularity);
7373
let dateValue = value != null ? value.toDate(defaultTimeZone ?? 'UTC') : null;
74-
let hasTime = granularity === 'hour' || granularity === 'minute' || granularity === 'second' || granularity === 'millisecond';
74+
let hasTime = granularity === 'hour' || granularity === 'minute' || granularity === 'second';
7575
let shouldCloseOnSelect = props.shouldCloseOnSelect ?? true;
7676

7777
let [selectedDate, setSelectedDate] = useState<DateValue>(null);

packages/@react-stately/datepicker/src/useDateRangePickerState.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export function useDateRangePickerState(props: DateRangePickerStateOptions): Dat
9595

9696
let v = (value?.start || value?.end || props.placeholderValue);
9797
let [granularity] = useDefaultProps(v, props.granularity);
98-
let hasTime = granularity === 'hour' || granularity === 'minute' || granularity === 'second' || granularity === 'millisecond';
98+
let hasTime = granularity === 'hour' || granularity === 'minute' || granularity === 'second';
9999
let shouldCloseOnSelect = props.shouldCloseOnSelect ?? true;
100100

101101
let [dateRange, setSelectedDateRange] = useState<DateRange>(null);

packages/@react-types/datepicker/src/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type MappedDateValue<T> =
3333
T extends CalendarDate ? CalendarDate :
3434
never;
3535

36-
export type Granularity = 'day' | 'hour' | 'minute' | 'second' | 'millisecond';
36+
export type Granularity = 'day' | 'hour' | 'minute' | 'second';
3737
interface DatePickerBase<T extends DateValue> extends InputBase, Validation, FocusableProps, LabelableProps, HelpTextProps, OverlayTriggerProps {
3838
/** The minimum allowed date that a user may select. */
3939
minValue?: DateValue,
@@ -111,7 +111,7 @@ export interface TimePickerProps<T extends TimeValue> extends InputBase, Validat
111111
* Determines the smallest unit that is displayed in the time picker.
112112
* @default 'minute'
113113
*/
114-
granularity?: 'hour' | 'minute' | 'second' | 'millisecond',
114+
granularity?: 'hour' | 'minute' | 'second',
115115
/** Whether to hide the time zone abbreviation. */
116116
hideTimeZone?: boolean,
117117
/**

0 commit comments

Comments
 (0)