Skip to content

Support explicit precision in format_common_iso() #246

@sasanjac

Description

@sasanjac

Instant objects omit the least representative time information when 0. When converting them to strings, this information is not added back, resulting in differently formatted strings.
It is also not added back when rounding and specifying the required precision.
This is particularly difficult when a specific format is required.

whenever.Instant.from_utc(2025, 6, 6, 12, 10, 10, nanosecond=12456789).round("millisecond").format_common_iso()

results in

'2025-06-06T12:10:10.012Z'
whenever.Instant.from_utc(2025, 6, 6, 12, 10, 10, nanosecond=1).round("millisecond").format_common_iso()

results in

'2025-06-06T12:10:10Z'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions