fix(ui): clear miliseconds in date fields unless theyre explicitly provided in the display format (#12650)
Fixes https://github.com/payloadcms/payload/issues/12532 Normally we clear any values when picking a date such that your hour, minutes and seconds are normalised to 0 unless specified. Equally when you specify a time we will normalise seconds so that only minutes are relevant as configured. Miliseconds were never removed from the actual date value and whatever milisecond the editor was in was that value that was being added. There's this [abandoned issue](https://github.com/Hacker0x01/react-datepicker/issues/1991) from the UI library `react-datepicker` as it's not something configurable. This fixes that problem by making sure that miliseconds are always 0 unless the `displayFormat` includes `SSS` as an intention to show and customise them. This also caused [issues with scheduled jobs](https://github.com/payloadcms/payload/issues/12566) if things were slightly out of order or not being scheduled in the expected time interval.
This commit is contained in:
@@ -903,6 +903,7 @@ export interface DateField {
|
||||
id: string;
|
||||
default: string;
|
||||
timeOnly?: string | null;
|
||||
timeOnlyWithMiliseconds?: string | null;
|
||||
timeOnlyWithCustomFormat?: string | null;
|
||||
dayOnly?: string | null;
|
||||
dayAndTime?: string | null;
|
||||
@@ -2486,6 +2487,7 @@ export interface CustomRowIdSelect<T extends boolean = true> {
|
||||
export interface DateFieldsSelect<T extends boolean = true> {
|
||||
default?: T;
|
||||
timeOnly?: T;
|
||||
timeOnlyWithMiliseconds?: T;
|
||||
timeOnlyWithCustomFormat?: T;
|
||||
dayOnly?: T;
|
||||
dayAndTime?: T;
|
||||
|
||||
Reference in New Issue
Block a user