[6.x] Fix range date fields not updating with configured timezone#14984
[6.x] Fix range date fields not updating with configured timezone#14984lazerg wants to merge 1 commit into
Conversation
|
Thanks for taking a crack at this! After tracing it through, this doesn't actually fix #14636. The Control Panel always submits datetime values with an explicit UTC offset already applied (e.g. The real bug is likely in Closing for now — feel free to update the PR description if you're actually intending on fixing a different issue, and we can reopen it if you want to keep going. |
|
@jasonvarga you were right, thanks for tracing it. The CP sends an absolute UTC value so the Carbon timezone arg did nothing on real saves, and only my naive test strings made it look fixed. I reworked it as the frontend fix you pointed at. The range branch in The new test drives |
|
Turns out GitHub won't let this one reopen since the branch was force-pushed with the rework ( |
Fixes #14636
Reworked from the original backend approach after @jasonvarga pointed out it was 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. The real fix is on the frontend.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.