Skip to content

Tracking Issue for duration_constructors_lite #140881

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

Open
1 of 3 tasks
Dietr1ch opened this issue May 10, 2025 · 3 comments
Open
1 of 3 tasks

Tracking Issue for duration_constructors_lite #140881

Dietr1ch opened this issue May 10, 2025 · 3 comments
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. S-tracking-unimplemented Status: The feature has not been implemented. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@Dietr1ch
Copy link
Contributor

Dietr1ch commented May 10, 2025

Feature gate: #![feature(duration_constructors_lite)]

This is a tracking issue for duration_constructors_lite.

duration_constructors_lite implements the non-controversial bits of duration_constructors.

Public API

  • std::time::Duration
    • from_mins(u64)
    • from_hours(u64)

History

(Remember to update the S-tracking-* label when checking boxes.)

  • Original duration_constructors implementation core: add Duration constructors #120307
    • Adds new Duration constructors from_mins, from_hours, from_days and from_weeks.
    • Daylight savings time coupled with possible confusion between "standard/scientific/stopwatch" time and "civil/human" time makes using from_days and from_weeks wrong too easy.
    • Without a CivilDuration type to disambiguate Duration as the "standard/scientific" time duration its safer to avoid introducing from_days and from_weeks even if Duration explicitly aims to model "standard/scientific".

Steps

  • Implementation: #140882
  • Final comment period (FCP)1
  • Stabilization PR

Unresolved Questions

  • Best way to implement from_days and other larger quantities in the future.
    • It seems we need a Civil time type in std to help avoid mis-interpreting std::time::Duration.

Misc

I want to thank all folks who participated in #120301. It's not fun to argue online for so long, but very much needed to grow the language in a sound way as it's even harder to undo mistakes.

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html

@Dietr1ch Dietr1ch added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC S-tracking-unimplemented Status: The feature has not been implemented. labels May 10, 2025
fmease added a commit to fmease/rust that referenced this issue May 11, 2025
…_lite, r=BurntSushi

Split duration_constructors to get non-controversial constructors out

This implements rust-lang#140881
rust-timer added a commit to rust-lang-ci/rust that referenced this issue May 11, 2025
Rollup merge of rust-lang#140882 - Dietr1ch:dev/duration_constructors_lite, r=BurntSushi

Split duration_constructors to get non-controversial constructors out

This implements rust-lang#140881
@Dietr1ch
Copy link
Contributor Author

I don't think this feature will change at all. Should I just draft the stabilisation PR? It might seem soon, but this has been discussed for a while in duration_constructors, so waiting here to me would be mostly a formality as the recent changes are essentially non-code ones.

@BurntSushi
Copy link
Member

BurntSushi commented May 13, 2025

@rfcbot fcp merge

This feature is new, but they represent a less controversial subset of duration_constructors (from #120301) that has been on nightly for quite some time. These routines allow constructing durations from hours or minutes, where as #120301 allows the same but from days or weeks.

One concern that has been raised about the hour/minute constructors is that of leap seconds (since some minutes have 61 seconds and in theory some minutes could have 59 seconds, although a negative leap second has never occurred). In my experience, there is no widespread practice for interpreting an hour as anything different from 60 minutes and interpreting a minute as anything different from 60 seconds, despite the presence of leap seconds. Moreover, our SystemTime type already ignores leap seconds.

As for why these were split out of duration_constructors, see #120301 for a fair bit of discussion.

@rfcbot
Copy link
Collaborator

rfcbot commented May 13, 2025

Team member @BurntSushi has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels May 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. S-tracking-unimplemented Status: The feature has not been implemented. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants