1
0
Fork 0
mirror of synced 2024-08-19 12:01:20 +12:00

Fix flatpickr offsetting date by one hour on initial selection of time-only fields

This commit is contained in:
Andrew Kingston 2022-08-13 16:25:01 +01:00
parent 3a7c92e202
commit ee5085f57f

View file

@ -59,6 +59,13 @@
// If time only set date component to 2000-01-01
if (timeOnly) {
// Classic flackpickr causing issues.
// When selecting a time first the first time for a "time only" field,
// the time is always offset by 1 hour for some reason (regardless of time
// zone) so we need to correct it.
if (!value && newValue) {
newValue = new Date(dates[0].getTime() + 60 * 60 * 1000).toISOString()
}
newValue = `2000-01-01T${newValue.split("T")[1]}`
}