DateTimePicker: Alternate timezones now behave correctly (#86750)

* Add failing tests for timezone handling

* Fix `DateTimePicker.tsx` timezone handling

- Resolves `onBlur` issue
- Resolve Calendar and TimeOfDay issues
- Update test to cover different timezone

* Handle `console.warn` in test

* Handle `console.warn` in test #2

* Better handling of invalid date

When parsing date string with `dateTime`, adding a second `formatInput` aids in both parsing the actual string and avoid `console.warn` when `moment` reverts to be using `Date`.

* add more test cases

* Ash/proposed changes (#86854)

* simplify

* only need this change

* formatting

* const > let

* add test to ensure calendar is always showing the matching day

* separate state

* undo story changes

* update util function comments

* fix for selecting date in the calendar

---------

Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com>
This commit is contained in:
Thomas Wikman
2024-04-29 10:46:44 +01:00
committed by GitHub
co-authored by Ashley Harrison
parent ccd2bff8b0
commit 7fab894e9b
5 changed files with 254 additions and 79 deletions
@@ -53,7 +53,7 @@ export interface DateTimeDuration {
export interface DateTime extends Object {
add: (amount?: DateTimeInput, unit?: DurationUnit) => DateTime;
set: (unit: DurationUnit, amount: DateTimeInput) => void;
set: (unit: DurationUnit | 'date', amount: DateTimeInput) => void;
diff: (amount: DateTimeInput, unit?: DurationUnit, truncate?: boolean) => number;
endOf: (unitOfTime: DurationUnit) => DateTime;
format: (formatInput?: FormatInput) => string;