Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(wkt): Support jiff From conversions for Duration and Timestamp #1154

Closed
wants to merge 3 commits into from

Conversation

fiadliel
Copy link
Contributor

jiff is a promising time handling crate based on the design of the Temporal JavaScript API. It is planned for a long-term 1.0 version to be released later in the year.

This commit adds support for converting to and from jiff::SignedDuration and jiff::Timestamp for version 0.2.

To ease the transition between version 0.2 and 1.0, I've named the feature jiff-0_2, so that support for multiple versions could coexist. But if preferred, I can rename the feature to just jiff.

Fixes #1153

…oogleapis#1153)

jiff is a promising time handling crate based on the design of the
Temporal JavaScript API. It is planned for a long-term 1.0 version
to be released later in the year.

This commit adds support for converting to and from
`jiff::SignedDuration` and `jiff::Timestamp` for version 0.2.
@coryan
Copy link
Contributor

coryan commented Feb 12, 2025

Generally this looks good. I assume the motivation for naming the feature jiff-0_2 is to provide (eventually) jiff-0_3 and jiff for a future 1.0 release? I would like to avoid an implicit commitment to support multiple versions. Though I guess we can always remove supported versions while our own version is 0.x (we would need to bump the 0.x to 0.${x + 1}`, of course).
Thoughts?

PS: not asking you to change anything yet, just trying to understand motivations and tradeoffs.

Copy link

codecov bot commented Feb 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.14%. Comparing base (9538e8a) to head (1186d47).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1154      +/-   ##
==========================================
+ Coverage   96.10%   96.14%   +0.03%     
==========================================
  Files          35       35              
  Lines        1388     1399      +11     
==========================================
+ Hits         1334     1345      +11     
  Misses         54       54              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@fiadliel
Copy link
Contributor Author

Generally this looks good. I assume the motivation for naming the feature jiff-0_2 is to provide (eventually) jiff-0_3 and jiff for a future 1.0 release? I would like to avoid an implicit commitment to support multiple versions. Though I guess we can always remove supported versions while our own version is 0.x (we would need to bump the 0.x to 0.${x + 1}`, of course).

I came across this idea in, for example, https://github.com/sfackler/rust-postgres/blob/master/postgres/Cargo.toml where it seemed like a nice approach for supporting multiple crates - in the case where it's implementing trait implementations for your own traits and third party types.

I firstly thought it would make it easier to transition between jiff 0.2 and jiff 1.0, because it unties the strict need to update both libraries simultaneously.
Secondly, the approach could allow support for multiple versions on a longer-term basis, but I can both see how this is maybe not ideal from your point of view. Also for jiff, since 1.0 is expected to be an LTS version, it's very much not necessary here.

But at the end of the day, the benefit here is definitely minor, and I can switch to just calling the feature jiff.

@fiadliel
Copy link
Contributor Author

Updated the feature name as jiff.

Also updated the Timestamp tests to verify that the jiff and wkt values both represent the same point in time (otherwise, it proves that the first value in the test case was converted to the other, but not that the test case values were wisely chosen).

@coryan
Copy link
Contributor

coryan commented Feb 13, 2025

I think we are going to wait until jiff gains more traction before taking a dependency on it. It looks very promising, and once it reaches 1.0 I think the case is easier. For now, we want to be conservative on adding extra deps to our public API (even if protected by feature flags).

I hope you do not feel like you wasted a lot of time on this. We are still refining our thinking about how to manage deps for Rust.

@fiadliel
Copy link
Contributor Author

No hard feelings here - it's fair. Also given the beta nature of both these libraries at this point in time, it's not going to inconvenience a lot of users.

I'll close this PR for now, but you can use it as reference code in the future if you want.

@fiadliel fiadliel closed this Feb 13, 2025
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.

Support conversions to/from datatypes in jiff time handling library
2 participants