Repository navigation
Fix planted date saving one day off (#2388) - #2528
Open
David-VanAssche wants to merge 1 commit into
Open
David-VanAssche wants to merge 1 commit into
David-VanAssche wants to merge 1 commit into
Conversation
The planted date inputs parsed the selected YYYY-MM-DD date at midnight in the browser's timezone, then only changed the display offset. When the device's utc offset differed from the browser's, the saved timestamp fell on the previous (or next) day in the device's timezone. Parse the date as midnight in the device's utc offset instead, for both the single-plant and bulk date inputs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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 #2388
Problem
The planted date inputs,
EditDatePlantedandPlantDateBulkUpdate, parse the selectedYYYY-MM-DDvalue withmoment(value), which gives midnight in the browser's timezone. They then call.utcOffset(offset), which only changes the display offset; the instant stays the same. When the device'stz_offset_hrsis behind the browser's offset (e.g. a browser in Munich with the device offset at 0), the saved instant falls on the previous day in the device's timezone, so the input shows the selected date minus one. When the device offset is ahead of the browser's, the date can shift forward instead.Fix
Parse the date as midnight in the device's UTC offset:
This doesn't depend on the browser's timezone at all.
Tests
it.eachcases for UTC offsets -11, -5, 0, +5 and +13 to both components, each asserting the exact saved timestamp. Previously the tests only checked that the value contained"Z".TZ=UTC,Europe/Berlin,America/Los_Angeles,Pacific/KiritimatiandAsia/Kolkata. All 10 fail without the fix and pass with it.bun run typecheckand ESLint on the changed files are clean.bun testrun: 7460 pass. The 1 failure was<GardenModel /> loads sequence visualization when selected, which passes when run alone, so it looks flaky and unrelated.Note: the existing
<PlantDateBulkUpdate /> updates plant datestest fails underTZ=America/Los_Angelesonmaintoo, because of the local-time formatting in the confirm message. I left it unchanged to keep this PR focused.🤖 Generated with Claude Code