Skip to content

Fix Date Picker always inserting 12:00 instead of the picked date - #48

Merged
Amato21 merged 3 commits into
masterfrom
fix-datepicker-noon-bug
Jul 21, 2026
Merged

Fix Date Picker always inserting 12:00 instead of the picked date#48
Amato21 merged 3 commits into
masterfrom
fix-datepicker-noon-bug

Conversation

@Amato21

@Amato21 Amato21 commented Jul 21, 2026

Copy link
Copy Markdown
Owner

Summary

Reported by the maintainer: picking a date via the Date Picker's calendar grid or a quick-select button (Today/Tomorrow/Next week/...) always inserted 12:00 as the time, regardless of what was actually selected.

Root cause

getDateStr() reformatted the already-resolved this.selectedDate down to a bare "YYYY-MM-DD" string and fed that back into plugin.parseDate() to build the preview/output — discarding whatever time this.selectedDate actually had. chrono-node defaults a date given with no time component to noon. Verified directly: parsing a bare "2026-07-20" produces a moment at 2026-07-20T12:00:00.

Fix

Only round-trip through the NLP parser when the user actually typed free-form text in the manual field (which may legitimately include a time, e.g. "today at 3pm"). For calendar/quick-button selections, format this.selectedDate directly — it's already a fully-resolved moment with nothing left to parse.

While auditing the rest of the modal (as requested), also found and fixed a related inconsistency: quick-select buttons built their moments with plain moment()/moment().add(...), carrying the real current wall-clock time instead of a clean date — clicking "Tomorrow" at 14:32 selected tomorrow at 14:32. Normalized to .startOf("day"), matching the calendar grid (already midnight-based), the modal's initial selectedDate, and the Home-key shortcut.

Verification

  • 4 new tests: calendar-click no longer calls plugin.parseDate/shows noon, quick-button pick same, typed free-form text (with a real time) still parses correctly, and selectedDate defaults to midnight on construction.
  • Confirmed the 2 core regression tests actually catch the bug: temporarily reverted getDateStr() to the old re-parse logic, reran, both failed exactly reproducing the reported "12:00 no matter what" behavior, then passed again after restoring the fix.
  • Full suite: 583/583 passing.
  • npx tsc --noEmit, npx eslint, and npm run build all clean.

Generated by Claude Code

Reported: picking a date via the calendar grid or a quick-select
button always inserted 12:00 as the time. Root cause: getDateStr()
reformatted the already-resolved this.selectedDate down to a bare
"YYYY-MM-DD" string and fed that back into plugin.parseDate() to
build the output -- discarding whatever time this.selectedDate
actually had, and chrono-node defaults a date given with no time
component to noon. Verified directly: parsing a bare "2026-07-20"
produces a moment at 2026-07-20T12:00:00.

Fix: only round-trip through the NLP parser when the user actually
typed free-form text in the manual field (which may legitimately
include a time, e.g. "today at 3pm"); for calendar/quick-button
selections, format this.selectedDate directly -- it's already a
fully-resolved moment with nothing left to parse.

Also fixed a related inconsistency while auditing the rest of the
modal: quick-select buttons (Today/Tomorrow/Next week/...) built their
moments with plain moment()/moment().add(...), carrying the real
current wall-clock time instead of a clean date -- clicking "Tomorrow"
at 14:32 selected tomorrow at 14:32. Normalized to .startOf("day"),
matching the calendar grid (already midnight-based) and the modal's
initial selectedDate and Home-key shortcut.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011AnUmNKkH1y4ZAEPKF1WwQ

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request fixes a bug in the Date Picker where selecting a date via the calendar grid or quick-select buttons incorrectly defaulted the time to 12:00 or carried the current wall-clock time. This is resolved by normalizing selected dates to midnight and avoiding redundant round-trips through the NLP parser unless manual text is typed. The reviewer suggested optimizing performance by caching the parsed Moment object to avoid redundant NLP parsing calls on every keystroke in the manual input field.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/modals/date-picker.ts Outdated
claude added 2 commits July 21, 2026 13:57
Typing in the Date Picker's manual field invoked plugin.parseDate()
2-3 times per keystroke (once in onChange to validate, again via
updateSelectedDate -> updatePreview -> getDateStr, and once more via
onChange's own trailing updatePreview() call). Caches the parsed
moment for the current input text, shared between onChange and
getDateStr(), and removes the now-redundant explicit updatePreview()
call after a successful parse (updateSelectedDate() already runs it).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011AnUmNKkH1y4ZAEPKF1WwQ
The Date Picker previously always carried some time value alongside
the picked date -- the real current wall-clock time for calendar/
quick-button selections (fixed to always be midnight in the prior
commit), or whatever chrono-node inferred from typed free-form text.
There was no way to control or clear it, since nothing in the modal's
UI exposes a time-of-day control.

Rather than adding a settings menu to make the time optional, simplify:
this is a date picker, not a time picker, so it never surfaces a time,
full stop -- including when the manual input field is used to type a
phrase that includes one (e.g. "today at 3pm"). Also removed the
unused modalToggleTime setting and switched the default/placeholder
format from "YYYY-MM-DD HH:mm" to "YYYY-MM-DD".

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011AnUmNKkH1y4ZAEPKF1WwQ
@Amato21
Amato21 merged commit 90642ec into master Jul 21, 2026
2 checks passed
@Amato21 Amato21 mentioned this pull request Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants