Skip to content

Fix midnight rounding being ignored for date-only formats - #113

Open
gthb wants to merge 1 commit into
borgar:masterfrom
gthb:fix/date-only-midnight-rounding
Open

gthb wants to merge 1 commit into
borgar:masterfrom
gthb:fix/date-only-midnight-rounding

Conversation

@gthb

@gthb gthb commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

A date-time is rounded to the second before formatting. When that rounding reaches midnight, the date becomes the next day.

numfmt did that only when the pattern included a time field, but Excel does it for a date-only pattern too:

  • TEXT(45000.9999942130,"yyyy-mm-dd") is 2023-03-16 (0.499997 s before midnight)
  • TEXT(45000.9999942129,"yyyy-mm-dd") is 2023-03-15 (0.500005 s before midnight)

So drop the time-field condition, and update the m/d/yy expectations that encoded the old rule.

A date-time is rounded to the second before formatting. When that rounding
reaches midnight, the date becomes the next day. That was done only when the
pattern included a time field, but Excel does it for a date-only pattern too:

- TEXT(45000.999995,"yyyy-mm-dd") returns 2023-03-16
- TEXT(45000.99999,"yyyy-mm-dd") returns 2023-03-15

Drop the time-field condition, and update the m/d/yy expectations that encoded
the old rule.
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.

1 participant