SignedDuration
struct · ferroui-base · v0.5.0
struct SignedDuration
A signed time interval with a resolution of 100 nanoseconds.
Members
TICKS_PER_MILLISECONDTICKS_PER_SECONDTICKS_PER_MINUTETICKS_PER_HOURTICKS_PER_DAYZEROMAX_VALUEMIN_VALUEfrom_ticksfrom_secondsfrom_millisecondsfrom_minutestickstotal_secondstotal_millisecondsto_durationparsefrom_hmsfrom_dhmsfrom_dhms_millisecondsfrom_hoursfrom_daysdayshoursminutessecondsmillisecondstotal_daystotal_hourstotal_minutesdurationto_string_formattry_to_string_format
TICKS_PER_MILLISECOND
const TICKS_PER_MILLISECOND: i64
The number of ticks in one millisecond.
TICKS_PER_SECOND
const TICKS_PER_SECOND: i64
The number of ticks in one second.
TICKS_PER_MINUTE
const TICKS_PER_MINUTE: i64
The number of ticks in one minute.
TICKS_PER_HOUR
const TICKS_PER_HOUR: i64
The number of ticks in one hour.
TICKS_PER_DAY
const TICKS_PER_DAY: i64
The number of ticks in one day.
ZERO
const ZERO: SignedDuration
The zero interval.
MAX_VALUE
const MAX_VALUE: SignedDuration
The largest interval.
MIN_VALUE
const MIN_VALUE: SignedDuration
The smallest (most negative) interval.
from_ticks
const fn from_ticks(ticks: i64) -> Self
Creates an interval from a number of 100-nanosecond ticks.
from_seconds
fn from_seconds(value: f64) -> Self
Creates an interval from a number of seconds, rounded to the nearest tick. Panics if the value is not a number or out of range.
from_milliseconds
fn from_milliseconds(value: f64) -> Self
Creates an interval from a number of milliseconds, rounded to the nearest tick. Panics if the value is not a number or out of range.
from_minutes
fn from_minutes(value: f64) -> Self
Creates an interval from a number of minutes.
ticks
const fn ticks(self: Self) -> i64
The number of ticks.
total_seconds
fn total_seconds(self: Self) -> f64
The interval in whole and fractional seconds.
total_milliseconds
fn total_milliseconds(self: Self) -> f64
The interval in whole and fractional milliseconds.
to_duration
fn to_duration(self: Self) -> Option<Duration>
The interval as a Duration; None when it is negative.
parse
fn parse(s: &str) -> Result<SignedDuration, FormatError>
Parses an interval in the invariant format
[-]{ d | [d.]hh:mm[:ss[.fffffff]] | d:hh:mm:ss[.fffffff] }.
from_hms
fn from_hms(hours: i32, minutes: i32, seconds: i32) -> Self
The interval of the given hours, minutes and seconds (the C#
constructor TimeSpan(int, int, int)). Panics on overflow.
from_dhms
fn from_dhms(days: i32, hours: i32, minutes: i32, seconds: i32) -> Self
The interval of the given days, hours, minutes and seconds (the C#
constructor TimeSpan(int, int, int, int)). Panics on overflow.
from_dhms_milliseconds
fn from_dhms_milliseconds(days: i32, hours: i32, minutes: i32, seconds: i32, milliseconds: i32) -> Self
The interval of the given days, hours, minutes, seconds and
milliseconds (the C# constructor TimeSpan(int, int, int, int, int)).
Panics on overflow.
from_hours
fn from_hours(value: f64) -> Self
Creates an interval from a number of hours.
from_days
fn from_days(value: f64) -> Self
Creates an interval from a number of days.
days
const fn days(self: Self) -> i32
The whole days of the interval (negative for a negative interval).
hours
const fn hours(self: Self) -> i32
The hours component, -23..=23.
minutes
const fn minutes(self: Self) -> i32
The minutes component, -59..=59.
seconds
const fn seconds(self: Self) -> i32
The seconds component, -59..=59.
milliseconds
const fn milliseconds(self: Self) -> i32
The milliseconds component, -999..=999.
total_days
fn total_days(self: Self) -> f64
The interval in whole and fractional days.
total_hours
fn total_hours(self: Self) -> f64
The interval in whole and fractional hours.
total_minutes
fn total_minutes(self: Self) -> f64
The interval in whole and fractional minutes.
duration
fn duration(self: Self) -> SignedDuration
The absolute value of the interval. Panics for TimeSpan::MIN_VALUE.
to_string_format
fn to_string_format(self: Self, format: &str) -> String
Formats with a standard (c, t, T, g, G) or custom .NET
TimeSpan format string; an empty format is c. Panics when the
format string is invalid (.NET throws FormatException).
The g and G formats always use . as the decimal separator; .NET
uses the one of the culture.
try_to_string_format
fn try_to_string_format(self: Self, format: &str) -> Result<String, FormatError>
Like to_string_format, but gives the error
of an invalid format string.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeResourceKeyObjectPropertyValueAnyValueClassDefaultsBorrow<T>BorrowMut<T>CloneToUninitInto<U>From<T>TryInto<U>TryFrom<U>AnyToOwnedToStringErasedDestructorIntoEitherIObservable<SignedDuration>CloneCopyDebugDefaultStructuralPartialEqPartialEqEqPartialOrdOrdHashFrom<Duration>TryFrom<SignedDuration>FromStrDisplayAddSubAddAssignSubAssignNegMul<f64>Add<SignedDuration>Sub<SignedDuration>AddAssign<SignedDuration>SubAssign<SignedDuration>MarkupTypedValueTypeRegistration
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.