Skip to content

Fix millisecond rounding carry in isoformat - #428

Merged
jswhit merged 1 commit into
Unidata:masterfrom
vera-rubin:fix/isoformat-millisecond-carry
Oct 30, 2026
Merged

jswhit merged 1 commit into
Unidata:masterfrom
vera-rubin:fix/isoformat-millisecond-carry

Conversation

@vera-rubin

Copy link
Copy Markdown
Contributor

An input of 999999 microseconds is rendered as .1000 by isoformat(timespec="milliseconds"), even though its documented ISO date representation makes that fraction 0.1 seconds. With cftime's existing rounding, this example should produce 2026-01-01T00:00:01.000:

import cftime
print(cftime.datetime(2026, 1, 1, microsecond=999999)
      .isoformat(timespec="milliseconds"))

We carry a rounded millisecond value of 1000 through the existing calendar arithmetic, including midnight and month boundaries, without changing the input.

The regression test and full pytest suite pass.

Tested cftime 1.6.6.1 (master 211e91f), CPython 3.12.3 on x86_64 Linux.

— ChipLab

@CLAassistant

CLAassistant commented Oct 19, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@jswhit
jswhit merged commit e2f9b08 into Unidata:master Oct 30, 2026
18 checks passed
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.

3 participants