Skip to content

Commit

Permalink
Remove millisecond granularity from date/time pickers (#3435)
Browse files Browse the repository at this point in the history
Fixes #3117
  • Loading branch information
devongovett committed Aug 23, 2022
1 parent a9736a1 commit 207e204
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/@react-spectrum/datepicker/src/DatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function DatePicker<T extends DateValue>(props: SpectrumDatePickerProps<T>, ref:
let timePlaceholder = placeholder && 'hour' in placeholder ? placeholder : null;
let timeMinValue = props.minValue && 'hour' in props.minValue ? props.minValue : null;
let timeMaxValue = props.maxValue && 'hour' in props.maxValue ? props.maxValue : null;
let timeGranularity = state.granularity === 'hour' || state.granularity === 'minute' || state.granularity === 'second' || state.granularity === 'millisecond' ? state.granularity : null;
let timeGranularity = state.granularity === 'hour' || state.granularity === 'minute' || state.granularity === 'second' ? state.granularity : null;
let showTimeField = !!timeGranularity;

let visibleMonths = useVisibleMonths(maxVisibleMonths);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function DateRangePicker<T extends DateValue>(props: SpectrumDateRangePickerProp
let timePlaceholder = placeholder && 'hour' in placeholder ? placeholder : null;
let timeMinValue = props.minValue && 'hour' in props.minValue ? props.minValue : null;
let timeMaxValue = props.maxValue && 'hour' in props.maxValue ? props.maxValue : null;
let timeGranularity = state.granularity === 'hour' || state.granularity === 'minute' || state.granularity === 'second' || state.granularity === 'millisecond' ? state.granularity : null;
let timeGranularity = state.granularity === 'hour' || state.granularity === 'minute' || state.granularity === 'second' ? state.granularity : null;
let showTimeField = !!timeGranularity;

let visibleMonths = useVisibleMonths(maxVisibleMonths);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export function useDatePickerState(props: DatePickerStateOptions): DatePickerSta
let v = (value || props.placeholderValue);
let [granularity, defaultTimeZone] = useDefaultProps(v, props.granularity);
let dateValue = value != null ? value.toDate(defaultTimeZone ?? 'UTC') : null;
let hasTime = granularity === 'hour' || granularity === 'minute' || granularity === 'second' || granularity === 'millisecond';
let hasTime = granularity === 'hour' || granularity === 'minute' || granularity === 'second';
let shouldCloseOnSelect = props.shouldCloseOnSelect ?? true;

let [selectedDate, setSelectedDate] = useState<DateValue>(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export function useDateRangePickerState(props: DateRangePickerStateOptions): Dat

let v = (value?.start || value?.end || props.placeholderValue);
let [granularity] = useDefaultProps(v, props.granularity);
let hasTime = granularity === 'hour' || granularity === 'minute' || granularity === 'second' || granularity === 'millisecond';
let hasTime = granularity === 'hour' || granularity === 'minute' || granularity === 'second';
let shouldCloseOnSelect = props.shouldCloseOnSelect ?? true;

let [dateRange, setSelectedDateRange] = useState<DateRange>(null);
Expand Down
4 changes: 2 additions & 2 deletions packages/@react-types/datepicker/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type MappedDateValue<T> =
T extends CalendarDate ? CalendarDate :
never;

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

1 comment on commit 207e204

@adobe-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.