pub struct TimeSpan { /* private fields */ }Expand description
A signed time interval with a resolution of 100 nanoseconds.
Implementations§
Source§impl TimeSpan
impl TimeSpan
Sourcepub const TICKS_PER_MILLISECOND: i64 = 10_000
pub const TICKS_PER_MILLISECOND: i64 = 10_000
The number of ticks in one millisecond.
Sourcepub const TICKS_PER_SECOND: i64 = 10_000_000
pub const TICKS_PER_SECOND: i64 = 10_000_000
The number of ticks in one second.
Sourcepub const TICKS_PER_MINUTE: i64 = 600_000_000
pub const TICKS_PER_MINUTE: i64 = 600_000_000
The number of ticks in one minute.
Sourcepub const TICKS_PER_HOUR: i64 = 36_000_000_000
pub const TICKS_PER_HOUR: i64 = 36_000_000_000
The number of ticks in one hour.
Sourcepub const TICKS_PER_DAY: i64 = 864_000_000_000
pub const TICKS_PER_DAY: i64 = 864_000_000_000
The number of ticks in one day.
Sourcepub const fn from_ticks(ticks: i64) -> Self
pub const fn from_ticks(ticks: i64) -> Self
Creates an interval from a number of 100-nanosecond ticks.
Sourcepub fn from_seconds(value: f64) -> Self
pub 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.
Sourcepub fn from_milliseconds(value: f64) -> Self
pub 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.
Sourcepub fn from_minutes(value: f64) -> Self
pub fn from_minutes(value: f64) -> Self
Creates an interval from a number of minutes.
Sourcepub fn total_seconds(self) -> f64
pub fn total_seconds(self) -> f64
The interval in whole and fractional seconds.
Sourcepub fn total_milliseconds(self) -> f64
pub fn total_milliseconds(self) -> f64
The interval in whole and fractional milliseconds.
Sourcepub fn to_duration(self) -> Option<Duration>
pub fn to_duration(self) -> Option<Duration>
The interval as a Duration; None when it is negative.
Source§impl TimeSpan
Members used by the date and time types and the pickers.
impl TimeSpan
Members used by the date and time types and the pickers.
Sourcepub fn from_hms(hours: i32, minutes: i32, seconds: i32) -> Self
pub 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.
Sourcepub fn from_dhms(days: i32, hours: i32, minutes: i32, seconds: i32) -> Self
pub 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.
Sourcepub fn from_dhms_milliseconds(
days: i32,
hours: i32,
minutes: i32,
seconds: i32,
milliseconds: i32,
) -> Self
pub 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.
Sourcepub fn from_hours(value: f64) -> Self
pub fn from_hours(value: f64) -> Self
Creates an interval from a number of hours.
Sourcepub const fn days(self) -> i32
pub const fn days(self) -> i32
The whole days of the interval (negative for a negative interval).
Sourcepub const fn milliseconds(self) -> i32
pub const fn milliseconds(self) -> i32
The milliseconds component, -999..=999.
Sourcepub fn total_days(self) -> f64
pub fn total_days(self) -> f64
The interval in whole and fractional days.
Sourcepub fn total_hours(self) -> f64
pub fn total_hours(self) -> f64
The interval in whole and fractional hours.
Sourcepub fn total_minutes(self) -> f64
pub fn total_minutes(self) -> f64
The interval in whole and fractional minutes.
Sourcepub fn duration(self) -> TimeSpan
pub fn duration(self) -> TimeSpan
The absolute value of the interval. Panics for TimeSpan::MIN_VALUE.
Sourcepub fn to_string_format(self, format: &str) -> String
pub fn to_string_format(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.
Sourcepub fn try_to_string_format(self, format: &str) -> Result<String, FormatError>
pub fn try_to_string_format(self, format: &str) -> Result<String, FormatError>
Like to_string_format, but gives the error
of an invalid format string.
Trait Implementations§
Source§impl Add<TimeSpan> for DateTimeOffset
impl Add<TimeSpan> for DateTimeOffset
Source§type Output = DateTimeOffset
type Output = DateTimeOffset
+ operator.Source§impl AddAssign for TimeSpan
impl AddAssign for TimeSpan
Source§fn add_assign(&mut self, rhs: TimeSpan)
fn add_assign(&mut self, rhs: TimeSpan)
+= operation. Read moreSource§impl AddAssign<TimeSpan> for DateTime
impl AddAssign<TimeSpan> for DateTime
Source§fn add_assign(&mut self, rhs: TimeSpan)
fn add_assign(&mut self, rhs: TimeSpan)
+= operation. Read moreSource§impl AddAssign<TimeSpan> for DateTimeOffset
impl AddAssign<TimeSpan> for DateTimeOffset
Source§fn add_assign(&mut self, rhs: TimeSpan)
fn add_assign(&mut self, rhs: TimeSpan)
+= operation. Read moreimpl Copy for TimeSpan
impl Eq for TimeSpan
Source§impl From<Duration> for TimeSpan
impl From<Duration> for TimeSpan
Source§fn from(value: Duration) -> Self
fn from(value: Duration) -> Self
Converts a duration, truncating to whole ticks and saturating at
TimeSpan::MAX_VALUE.
Source§impl IObservable<TimeSpan> for Clock
impl IObservable<TimeSpan> for Clock
Source§impl IObservable<TimeSpan> for MediaContextClock
impl IObservable<TimeSpan> for MediaContextClock
Source§impl MarkupTyped for TimeSpan
impl MarkupTyped for TimeSpan
Source§const MARKUP: &'static MarkupType
const MARKUP: &'static MarkupType
Source§impl Ord for TimeSpan
impl Ord for TimeSpan
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for TimeSpan
impl PartialOrd for TimeSpan
impl StructuralPartialEq for TimeSpan
Source§impl Sub<TimeSpan> for DateTimeOffset
impl Sub<TimeSpan> for DateTimeOffset
Source§type Output = DateTimeOffset
type Output = DateTimeOffset
- operator.Source§impl SubAssign for TimeSpan
impl SubAssign for TimeSpan
Source§fn sub_assign(&mut self, rhs: TimeSpan)
fn sub_assign(&mut self, rhs: TimeSpan)
-= operation. Read moreSource§impl SubAssign<TimeSpan> for DateTime
impl SubAssign<TimeSpan> for DateTime
Source§fn sub_assign(&mut self, rhs: TimeSpan)
fn sub_assign(&mut self, rhs: TimeSpan)
-= operation. Read moreSource§impl SubAssign<TimeSpan> for DateTimeOffset
impl SubAssign<TimeSpan> for DateTimeOffset
Source§fn sub_assign(&mut self, rhs: TimeSpan)
fn sub_assign(&mut self, rhs: TimeSpan)
-= operation. Read moreAuto Trait Implementations§
impl Freeze for TimeSpan
impl RefUnwindSafe for TimeSpan
impl Send for TimeSpan
impl Sync for TimeSpan
impl Unpin for TimeSpan
impl UnsafeUnpin for TimeSpan
impl UnwindSafe for TimeSpan
Blanket Implementations§
Source§impl<T> AnyValue for Twhere
T: PartialEq + 'static,
impl<T> AnyValue for Twhere
T: PartialEq + 'static,
fn any_value_as_any(&self) -> &(dyn Any + 'static)
fn any_value_eq(&self, other: &(dyn AnyValue + 'static)) -> bool
fn any_value_type_name(&self) -> &'static str
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> ClassDefaults for Twhere
T: ?Sized,
impl<T> ClassDefaults for Twhere
T: ?Sized,
Source§fn static_constructor()
fn static_constructor()
affects_render, metadata
overrides). Read more