Repository navigation
Formula bar: a date cell shows its short date, whatever its format (#3510) - #3523
quantforge-br wants to merge 2 commits into
Conversation
…ver its format edit_text started from the cell's formatted text whenever it read back as the same date, so mmmm-yy showed September-26 and d-mmm showed 1-Sep, which reads back as September 1 of the current year. Excel shows the system short date (built-in format 14), the time with seconds when there is one, and the time alone under 1. Text that would not read back (fractions of a second, dates past 9999) still falls back to the serial.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
eliets2
left a comment
There was a problem hiding this comment.
First-pass review notes (automated; combined from specialist angles: docs and text). Please treat as suggestions and verify before acting.
What the change does: Fixes #3510 by changing display::edit_text so a constant number in a date or time format is shown in the formula bar as the short date m/d/yyyy, with time as m/d/yyyy h:mm:ss AM/PM or time alone as h:mm:ss AM/PM, regardless of the cell's number format, falling back to the serial when that text would not read back as the same number; formulas, text, and non-date formats are unchanged.
Logical units:
- Change to
edit_textformatting and fallback logic incrates/engine/src/display.rs - Replacement of
editing_a_date_cell_shows_a_date_not_the_serialwithediting_a_date_cell_shows_the_short_date_not_the_cell_formatcovering the formats and edge cases described
Findings:
- [docs]
crates/engine/src/display.rs,edit_textdoc comment: says the date is written "the system's way" as built-in format 14, but the code hardcodes the en-US stringsm/d/yyyy,m/d/yyyy h:mm:ss AM/PM, andh:mm:ss AM/PMand does not follow the regional short date. Fix: state that the format is hardcoded to en-USm/d/yyyyuntil the regional-format work lands. - [docs]
crates/engine/src/display.rs,edit_textdoc comment: says the serial is shown only when the text would not read back due to fractions of a second, but the fallback also applies to negative values and to dates that cannot be represented in the short-date text (e.g. past year 9999 in the 1904 system), whererawis returned. Fix: list those fallback cases in the comment so readers do not assume every date/time-formatted value is shown as a date/time.
Overlaps: The description notes following the system's regional short date is part of the Region work (#3048 and the PRs stacked on it), which will build on this change.
Verdict: needs changes — (1) clarify in the edit_text doc comment that the format is hardcoded to en-US, (2) list all fallback cases (negative values and unrepresentable dates, not only fractions of a second) in that comment, (3) no other findings were reported.
|
@eliets2 thanks, both points were right; fixed in fbf7d9d. The |
…whatever its format (storytold#3510)
Fixes #3510.
What was wrong
display::edit_text(what the formula bar and the cell editor start from) used the cell's formatted text for a date whenever that text read back as the same number, and an ISO date otherwise. So a date formattedmmmm-yyshowedSeptember-26in the formula bar, and the day could not be seen or edited.d-mmmshowed1-Sep, which only reads back as the right date during the year it was typed in.What Excel does
The formula bar shows a date the system's way, whatever the cell's format: the short date (built-in format 14,
m/d/yyyyin en-US), followed by the time with seconds when there is one (9/1/2026 1:30:00 PM), and the time alone for a value under 1 (9:36:00 AM).Change
edit_textformats a constant number in a date or time format withm/d/yyyy,m/d/yyyy h:mm:ss AM/PMorh:mm:ss AM/PM. If that text doesn't read back as the same number (fractions of a second, or dates past year 9999 in the 1904 system), it shows the serial as before. Formulas, text and non-date formats are unchanged.The short date stays
m/d/yyyyhere. Following the system's regional short date is part of the Region work (#3048 and the PRs stacked on it), which will build on this.Tests
editing_a_date_cell_shows_the_short_date_not_the_cell_formatreplacesediting_a_date_cell_shows_a_date_not_the_serial. It covers the [Bug Report] [GridCraft] Formula bar shows a date cell's formatted text instead of the date #3510 format ([$-40C]mmmm\-yy;@),mmmm-yy,d-mmm,dddd, mmmm d,yyyy-mm-dd, date with time, a time alone, a duration past one day, fractions of a second, a negative number and General. For each one it checks that committing the editor text unchanged keeps the value. It fails onmain(yyyy-mm-ddgives2026-03-04).snapshotexample for the two cells from the issue (9/1/2026and9/1/2026 1:30:00 PM).cargo xtask cisteps run locally: fmt, clippy-D warnings, 3532 tests passed and 0 failed, plus assets, layers, keytips, wasm andparity --check.Summary by CodeRabbit