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

Deprecate panicking TimeDelta initializers #1408

Closed
pitdicker opened this issue Feb 3, 2024 · 2 comments · Fixed by #1450
Closed

Deprecate panicking TimeDelta initializers #1408

pitdicker opened this issue Feb 3, 2024 · 2 comments · Fixed by #1450

Comments

@pitdicker
Copy link
Collaborator

The following methods can panic and have a try_ variant:

impl Duration {
    pub const fn weeks(weeks: i64) -> Duration;
    pub const fn days(days: i64) -> Duration;
    pub const fn hours(hours: i64) -> Duration;
    pub const fn minutes(minutes: i64) -> Duration;
    pub const fn seconds(seconds: i64) -> Duration;
    pub const fn milliseconds(milliseconds: i64) -> Duration;
}

The replacement methods have been introduced only recently in 0.4.32, and Duration::try_milliseconds has not seen a release yet.

In all other places in chrono we have deprecated such panicking methods, and I suppose we should do the same here.
I wonder when would be the right time?

cc @danwilliams

@djc
Copy link
Contributor

djc commented Feb 7, 2024

Once replacements are in the field, I think the next release after about 1-2 months should be okay to deprecate.

Might be interesting to pick apart the crates.io downloads to figure out what old releases are still getting picked up (and maybe, why)?

@pitdicker
Copy link
Collaborator Author

From #1408 (comment):

Might be interesting to pick apart the crates.io downloads to figure out what old releases are still getting picked up (and maybe, why)?

https://lib.rs/crates/chrono/versions has a nice breakdown. With just a superficial look there is a big correlation between use and for how long a version was the latest release.

Top 5:

version date downloads/mo probable reason
total 6.7M
0.4.33 2024-01-25 2.4M (±35%) Most-used is the current release.
0.4.31 2023-09-15 2.1M (±31%) This was the last release for four months before current
0.4.26 2023-05-30 738K (±11%) This was the last release for three months before 5 quick releases
0.4.23 2022-11-12 473K (±7%) Again the last release for four months before before 3 quick releases
0.4.19 2020-09-30 172K (±2.6) The last release for close to two years.

It seems to me there are no obvious blockers for users to upgrade. At least the 150 most popular crates that use chrono don't specify a max version, only a minimum version of chrono.

Also interesting that (2.4 + 0.145 + 2.1 + 0.77) / 6.678 = 71% of our users are now on a version of chrono without the time 0.1 dependency.

I have no idea how to figure out which older version of other crates causes the downloads of for example 0.4.19.

@pitdicker pitdicker changed the title Deprecate panicking Duration initializers Deprecate panicking TimeDelta initializers Feb 12, 2024
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 a pull request may close this issue.

2 participants