You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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".
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.
Feature gate:
#![feature(duration_constructors_lite)]This is a tracking issue for
duration_constructors_lite.duration_constructors_liteimplements the non-controversial bits ofduration_constructors.Public API
std::time::Durationfrom_mins(u64)from_hours(u64)History
(Remember to update the
S-tracking-*label when checking boxes.)duration_constructorsimplementation core: add Duration constructors #120307Durationconstructorsfrom_mins,from_hours,from_daysandfrom_weeks.from_daysandfrom_weekswrong too easy.CivilDurationtype to disambiguateDurationas the "standard/scientific" time duration its safer to avoid introducingfrom_daysandfrom_weekseven ifDurationexplicitly aims to model "standard/scientific".Steps
duration_constructors_litefeature #145135Unresolved Questions
from_daysand other larger quantities in the future.stdto help avoid mis-interpretingstd::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
https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩