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
According to this, one can expect that maximum possible duration value is at least i64::MAX seconds. But in fact, the full range that i64 seconds gives us is restricted to i64::MAX milliseconds (see #16626 for more details).
I offer to change the internal representation of Duration to
pub struct Duraion {
ticks: i64, // A single tick represents 100 nanoseconds
nanos: i8 // to hold values from -99 to 99
}
Some pros:
Internals of struct Duraion are not exposed. So, we are free to change them.
This commit changes the internal representation of Duration from
pub struct Duraion {
secs: i64,
nanos: i32
}
to
/// An absolute amount of time, independent of time zones
/// and calendars with tick precision. A single tick
/// represents 100 nanoseconds.
pub struct Duration(pub i64)
Closesrust-lang#18166,rust-lang#18416.
At the moment the
Duration
type looks likeAccording to this, one can expect that maximum possible duration value is at least
i64::MAX
seconds. But in fact, the full range that i64 seconds gives us is restricted toi64::MAX
milliseconds (see #16626 for more details).I offer to change the internal representation of
Duration
toSome pros:
struct Duraion
are not exposed. So, we are free to change them.num_milliseconds
etc will return correct i64 values (see libstd: Refactor Duration. #16626).TimeSpan
in .NET andDuration
in Joda-Time types do the same.Some cons:
Duration
will be shorter:i64::MAX
seconds gives us 106751991167300 days. We don't useneedit.i64::MAX
milliseconds gives us 106751991167 days. This is our current choice.i64::MAX
ticks gives us 10675199 days. The range is still long enough, who cares?The text was updated successfully, but these errors were encountered: