Skip to content

Provide support for Jiff date/time types #1270

@sgoll

Description

@sgoll

Description

This is a proposal to add first-class support for the data types from Jiff. First-class support is necessary, and an external crate would be much more inconvenient to use, because of Rust's orphan rule as outlined in #87 (comment).

This should cover the following date/time types:

Timestamps

  • Timestamp, serialized as RFC 3339 (ISO 8601) date/time with UTC time zone, GraphQL scalar DateTime, e.g. 2024-06-19T19:22:45Z
  • Zoned, serialized as RFC 9557 date/time with time zone, GraphQL scalar ZonedDateTime1, e.g. 2024-07-04T08:39:00-04:00[America/New_York]

Wall-clocked

  • Date, serialized as date, without time zone, GraphQL scalar LocalDate, e.g. 2024-06-19
  • Time, serialized as time, without time zone, GraphQL scalar LocalTime, e.g. 15:22:45
  • DateTime, serialized as date/time, without time zone, GraphQL scalar LocalDateTime, e.g. 2024-06-19T15:22:45

Durations

  • Span, serialized as ISO 8601 duration, GraphQL scalar Duration, e.g. P5dT8h1m

Time zones

  • TimeZone, serialized as IANA time zone identifier, GraphQL scalar TimeZone, e.g. America/New_York

Where types overlap, the resulting serialization would be identical to the one for the chrono and time crates, with the difference of using GraphQL scalar LocalDate instead of Date.2

I am aware that Jiff is a very new library but I think it has great potential in the ecosystem. Having dealt with date/time intricacies in several projects, I regard it as one of the top-contenders for following or eventually even superseding chrono/time.

I am willing to provide a PR if this proposal is accepted. See #1271 for a PR that implements these features.

See #1272 for a PR that adds support for the types Zoned and TimeZone.

Footnotes

  1. This always includes the time zone specifier and uses RFC 8536 9557. This format seems not widely used yet. It is also not a valid input for GraphQL scalar DateTime, therefore we serialize it as the GraphQL scalar ZonedDateTime which has not been stabilized, or even defined elsewhere, yet.

  2. LocalDate seems to be the more appropriate type. I am not sure why chrono and time integration chose to use Date instead.

Metadata

Metadata

Assignees

Labels

featureNew feature or requestk::integrationRelated to integration with third-party libraries or systemslib::jiffRelated to `jiff` crate integration

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions