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

Replace time crate with jiff #15293

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

oherrala
Copy link
Contributor

PR #15290 replaced humantime crate with jiff and this PR replaces time crate in favor of jiff.

This should not have functional change.

@rustbot
Copy link
Collaborator

rustbot commented Mar 10, 2025

r? @ehuss

rustbot has assigned @ehuss.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-configuration Area: cargo config files and env vars A-credential-provider Area: credential provider for storing and retreiving credentials A-registry-authentication Area: registry authentication and authorization (authn authz) A-testing-cargo-itself Area: cargo's tests S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 10, 2025
@oherrala
Copy link
Contributor Author

r? @epage

@rustbot rustbot assigned epage and unassigned ehuss Mar 10, 2025
@@ -619,7 +620,7 @@ fn auth_token_optional(
if let Some(cached_token) = cache.get(url) {
if cached_token
.expiration
.map(|exp| OffsetDateTime::now_utc() + Duration::minutes(1) < exp)
.map(|exp| Timestamp::now() + Duration::from_secs(60) < exp)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small thing, but you could do Timestamp::now() + SignedDuration::from_mins(1) here.

Copy link
Contributor Author

@oherrala oherrala Mar 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there some benefit to use SignedDuration instead of std's Duration? Latter is just shorter to write and does the same thing :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You get the from_mins constructor. But otherwise, in this case, no.

@@ -367,7 +367,6 @@ dependencies = [
"tar",
"tempfile",
"thiserror 2.0.11",
"time",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately it looks like this PR doesn't actually remove time from the dependency tree. As far as I can tell, it's still being brought in by pasetors.

It looks like it's primarily used by Cargo, so maybe they'd be open to a switch as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for highlighting this.

To be clear, this wouldn't be a blocker for this PR

@oherrala oherrala marked this pull request as ready for review March 13, 2025 09:51
#[serde(with = "time::serde::timestamp")]
expiration: OffsetDateTime,
#[serde(with = "jiff::fmt::serde::timestamp::second::required")]
expiration: Timestamp,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this a public API change and needs a major version bump?

Wonder why cargo-semver-checks didn't report to us.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If so, should we wait for jiff 1.0?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or change it to other integer type or wrapper type, so it is completely opaque.

There is no guarantee that jiff@2 won't come out a week after jiff@1 is out.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree an integer or wrapper type makes sense for something like this.

There is no guarantee that jiff@2 won't come out a week after jiff@1 is out.

Just to comment on this, it is my intent that jiff will stay at 1.0 indefinitely. For a jiff 2.0 to happen a week or even 1 month after jiff 1.0 is released, I think something spectacular would have had to go wrong.

Otherwise, I do have a track record of sticking to 1.0. regex is still at 1.0 even though there are mistakes in its API I would like to fix. Same with bstr.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @BurntSushi! I totally agree with it and fully trust you as a maintainer of those awesome crates. I meant to express that regardless it is 0.2 or 1.0, a major version bump is a major version bump. If we have fear of re-export we should make it opaque.

Sorry I didn't mean to make you feel bad 😞.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I didn't feel bad, I just want to make sure the right kinds of expectations are telegraphed. :) I just mean it would be a spectacular failure on my part if 2.0 were released right after 1.0.

My plan is to release Jiff 1.0 this summer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes and we already had this problem with time in the puiblic API. I was just wondering if we should consolidate the breaking changes or going ahead and moving forward. No strong opinion. So long as the serialization format is unchanged, breaking changes to this API are not too big of a deal; the target audience is very small.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the braking changes (whatever they are) be done in another PR before this? Or in this PR?

Copy link
Member

@weihanglo weihanglo Mar 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are removing time in this PR, the breaking change seems better to be in the same PR. Could be one more commit if needed.

Slightly prefer the approach making it opaque. Not really strong though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-configuration Area: cargo config files and env vars A-credential-provider Area: credential provider for storing and retreiving credentials A-registry-authentication Area: registry authentication and authorization (authn authz) A-testing-cargo-itself Area: cargo's tests S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants