Skip to content

Allow sub-millisecond resolution in LocalTime #2482

@sgoll

Description

@sgoll

Description

Looking at the code of LocalTime, it seems that it explicitly allows only milliseconds as sub-second resolution. It is unclear (at least, to me) why this is the case. It seems unintuitive because both LocalDateTime as well as DateTime allow arbitrary precision for the sub-second part.1

I would like to suggest lifting this limitation in LocalTime to bring it closer to LocalDateTime and DateTime.

This has come up in graphql-rust/juniper#1270 (comment) where serialization of the most common Rust time libraries is restricted to millisecond resolution despite all of them supporting nanosecond resolution internally.

Unfortunately, this could be considered a breaking change because it places the burden of parsing sub-millisecond resolution on downstream consumers.2

Footnotes

  1. Despite neither the documentation of LocalDateTime nor DateTime indicating so.

  2. Although I would argue that most parsers should be able to handle the introduction of additional digits without any significant changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions