[6.x] Fix range date fields ignoring the configured timezone on save#15001
Merged
jasonvarga merged 1 commit intoJul 13, 2026
Merged
Conversation
e29804f to
483e38f
Compare
Member
|
Beautiful, thank you. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #14636. Supersedes #14984.
This replaces #14984, which took a backend approach that @jasonvarga correctly identified as a no-op on real saves: the Control Panel always submits an absolute UTC value, and
Carbon::parse()ignores its timezone argument once the string carries an offset. He pinpointed the real cause inDateFieldtype.vueand offered to reopen, but the branch had been force-pushed with this rework and GitHub won't let the old PR reopen, so this is a fresh PR from the same branch.Root cause
DateFieldtype.vue'sdatePickerUpdated()handles single dates and ranges differently. For a single date, the naiveCalendarDateTimefrom the picker is first interpreted in the field's configured timezone before being converted to UTC:The range branch skipped that step and sent the naive
start/endstraight to UTC viatoZoned(start, 'UTC'), so the field's wall-clock time was treated as if it were already UTC. Loading usesparseAbsolute(value, displayTimezone)(correct), so the load/save round-trip was asymmetric and the stored value drifted by the offset on every save.Fix
Interpret the range's naive
start/endindisplayTimezonebefore converting to UTC, the same way single dates already do.Test
Added a
DateFieldtype.test.jscase that drivesdatePickerUpdated()with theCalendarDateTimeobjects the picker actually emits (range + time mode, configured timezone). For a New York field, entering05:00now saves09:00Z; it fails on the current code (which saves05:00Z) and passes with the fix. Full unit suite green.