pub struct TimeValue(/* private fields */);Expand description
§A single time value (duration)
This time value represent a duration and could be infinite.
Implementations§
Source§impl TimeValue
impl TimeValue
Sourcepub fn from_ticks(t: i64) -> Self
pub fn from_ticks(t: i64) -> Self
Creates a new time value for a number of clock ticks.
A clock tick is the smallest duration of time taken into account by this crate. It is about a nanosecond.
A tick is exactly defined as 1/2^30 seconds
If the given number of ticks is less than -TimeValue::INFINITE
or greater than TimeValue::INFINITE, the time value is
set to infinite.
If you are sure that the number of ticks is within the finite range
value, using the unsafe version Self::from_ticks_unchecked could
be considered
Sourcepub unsafe fn from_ticks_unchecked(t: i64) -> Self
pub unsafe fn from_ticks_unchecked(t: i64) -> Self
Creates a new time value for a number of clock ticks.
A clock tick is the smallest duration of time taken into account by this crate.
§Safety
If the given number of ticks is less than -TimeValue::INFINITE
or greater than TimeValue::INFINITE, the behaviour of the
time value is unpredictable.
For a safety use, consider Self::from_ticks.
Sourcepub fn from_years(years: i64) -> Self
pub fn from_years(years: i64) -> Self
Duration from a number of years
Important note: a year is defined as an average duration of a little less than 365.25 in order to take into account leap years. More precisely, a year is defined as 146097/400 days.
Sourcepub fn from_months(months: i64) -> Self
pub fn from_months(months: i64) -> Self
Duration from a number of months
Important note: a month is defined as one twelfth of a year. It is therefore defined as a duration of just under 30.5 days.
Sourcepub fn from_weeks(weeks: i64) -> Self
pub fn from_weeks(weeks: i64) -> Self
Duration from a number of weeks
A week is defined as a duration of 7 days.
Sourcepub fn from_days(days: i64) -> Self
pub fn from_days(days: i64) -> Self
Duration from a number of days
A day is defined as a duration of 24 hours.
Sourcepub fn from_hours(hours: i64) -> Self
pub fn from_hours(hours: i64) -> Self
Duration from a number of hours
A hour is defined as a duration of 60 minutes (or 3600s).
Sourcepub fn from_mins(mins: i64) -> Self
pub fn from_mins(mins: i64) -> Self
Duration from a number of minutes
A minute is defined as a duration of 60 seconds.
Sourcepub fn from_millis(millis: i64) -> Self
pub fn from_millis(millis: i64) -> Self
Approximate duration from a number of milliseconds
Important note: the fractional part of a second is represented in ticks which is an internal representation close to (but not equal) the nanosecond.
Sourcepub fn from_micros(micros: i64) -> Self
pub fn from_micros(micros: i64) -> Self
Approximate duration from a number of microseconds
Important note: the fractional part of a second is represented in ticks which is an internal representation close to (but not equal) the nanosecond.
Sourcepub fn from_nanos(nanos: i64) -> Self
pub fn from_nanos(nanos: i64) -> Self
Approximate duration from a number of nanoseconds
Important note: the fractional part of a second is represented in ticks which is an internal representation close to (but not equal) the nanosecond.
pub fn as_ticks(&self) -> i64
pub fn as_secs(&self) -> i64
Sourcepub fn subsec_millis(&self) -> i32
pub fn subsec_millis(&self) -> i32
Fractional part of a time value (milliseconds)
Important note: the fractional part of a second is represented in ticks which is an internal representation close to (but not equal) the nanosecond.
Sourcepub fn subsec_micros(&self) -> i32
pub fn subsec_micros(&self) -> i32
Fractional part of a time value (microseconds)
Important note: the fractional part of a second is represented in ticks which is an internal representation close to (but not equal) the nanosecond.
Sourcepub fn subsec_nanos(&self) -> i32
pub fn subsec_nanos(&self) -> i32
Fractional part of the time value (nanoseconds)
Important note: the fractional part of a second is represented in ticks which is an internal representation close to (but not equal) the nanosecond.
pub fn to_duration(&self) -> Duration
pub fn is_zero(&self) -> bool
pub fn is_positive(&self) -> bool
pub fn is_negative(&self) -> bool
pub fn is_strictly_positive(&self) -> bool
pub fn is_strictly_negative(&self) -> bool
pub fn floor(self, period: TimeValue) -> Self
pub fn ceil(self, period: TimeValue) -> Self
Trait Implementations§
Source§impl<T> Add<TimeInterval<T>> for TimeValue
impl<T> Add<TimeInterval<T>> for TimeValue
Source§type Output = TimeInterval<T>
type Output = TimeInterval<T>
+ operator.Source§impl<T> Add<TimeValue> for TimeInterval<T>
impl<T> Add<TimeValue> for TimeInterval<T>
Source§impl<T> AddAssign<TimeValue> for TimeInterval<T>
impl<T> AddAssign<TimeValue> for TimeInterval<T>
Source§fn add_assign(&mut self, other: TimeValue)
fn add_assign(&mut self, other: TimeValue)
+= operation. Read moreSource§impl<T: TimePoint> AddAssign<TimeValue> for TimeSet<T>
impl<T: TimePoint> AddAssign<TimeValue> for TimeSet<T>
Source§fn add_assign(&mut self, t: TimeValue)
fn add_assign(&mut self, t: TimeValue)
+= operation. Read moreSource§impl AddAssign<TimeValue> for Timestamp
impl AddAssign<TimeValue> for Timestamp
Source§fn add_assign(&mut self, other: TimeValue)
fn add_assign(&mut self, other: TimeValue)
+= operation. Read moreSource§impl AddAssign for TimeValue
impl AddAssign for TimeValue
Source§fn add_assign(&mut self, other: TimeValue)
fn add_assign(&mut self, other: TimeValue)
+= operation. Read moreSource§impl DivAssign<f32> for TimeValue
impl DivAssign<f32> for TimeValue
Source§fn div_assign(&mut self, n: f32)
fn div_assign(&mut self, n: f32)
/= operation. Read moreSource§impl DivAssign<f64> for TimeValue
impl DivAssign<f64> for TimeValue
Source§fn div_assign(&mut self, n: f64)
fn div_assign(&mut self, n: f64)
/= operation. Read moreSource§impl DivAssign<i128> for TimeValue
impl DivAssign<i128> for TimeValue
Source§fn div_assign(&mut self, n: i128)
fn div_assign(&mut self, n: i128)
/= operation. Read moreSource§impl DivAssign<i16> for TimeValue
impl DivAssign<i16> for TimeValue
Source§fn div_assign(&mut self, n: i16)
fn div_assign(&mut self, n: i16)
/= operation. Read moreSource§impl DivAssign<i32> for TimeValue
impl DivAssign<i32> for TimeValue
Source§fn div_assign(&mut self, n: i32)
fn div_assign(&mut self, n: i32)
/= operation. Read moreSource§impl DivAssign<i64> for TimeValue
impl DivAssign<i64> for TimeValue
Source§fn div_assign(&mut self, n: i64)
fn div_assign(&mut self, n: i64)
/= operation. Read moreSource§impl DivAssign<i8> for TimeValue
impl DivAssign<i8> for TimeValue
Source§fn div_assign(&mut self, n: i8)
fn div_assign(&mut self, n: i8)
/= operation. Read moreSource§impl DivAssign<isize> for TimeValue
impl DivAssign<isize> for TimeValue
Source§fn div_assign(&mut self, n: isize)
fn div_assign(&mut self, n: isize)
/= operation. Read moreSource§impl DivAssign<u128> for TimeValue
impl DivAssign<u128> for TimeValue
Source§fn div_assign(&mut self, n: u128)
fn div_assign(&mut self, n: u128)
/= operation. Read moreSource§impl DivAssign<u16> for TimeValue
impl DivAssign<u16> for TimeValue
Source§fn div_assign(&mut self, n: u16)
fn div_assign(&mut self, n: u16)
/= operation. Read moreSource§impl DivAssign<u32> for TimeValue
impl DivAssign<u32> for TimeValue
Source§fn div_assign(&mut self, n: u32)
fn div_assign(&mut self, n: u32)
/= operation. Read moreSource§impl DivAssign<u64> for TimeValue
impl DivAssign<u64> for TimeValue
Source§fn div_assign(&mut self, n: u64)
fn div_assign(&mut self, n: u64)
/= operation. Read moreSource§impl DivAssign<u8> for TimeValue
impl DivAssign<u8> for TimeValue
Source§fn div_assign(&mut self, n: u8)
fn div_assign(&mut self, n: u8)
/= operation. Read moreSource§impl DivAssign<usize> for TimeValue
impl DivAssign<usize> for TimeValue
Source§fn div_assign(&mut self, n: usize)
fn div_assign(&mut self, n: usize)
/= operation. Read moreSource§impl IntoTimeValue for TimeValue
impl IntoTimeValue for TimeValue
fn years(self) -> TimeValue
fn months(self) -> TimeValue
fn weeks(self) -> TimeValue
fn days(self) -> TimeValue
fn hours(self) -> TimeValue
fn mins(self) -> TimeValue
fn secs(self) -> TimeValue
fn millis(self) -> TimeValue
fn micros(self) -> TimeValue
fn nanos(self) -> TimeValue
fn ticks(self) -> TimeValue
Source§impl MulAssign<f32> for TimeValue
impl MulAssign<f32> for TimeValue
Source§fn mul_assign(&mut self, n: f32)
fn mul_assign(&mut self, n: f32)
*= operation. Read moreSource§impl MulAssign<f64> for TimeValue
impl MulAssign<f64> for TimeValue
Source§fn mul_assign(&mut self, n: f64)
fn mul_assign(&mut self, n: f64)
*= operation. Read moreSource§impl MulAssign<i128> for TimeValue
impl MulAssign<i128> for TimeValue
Source§fn mul_assign(&mut self, n: i128)
fn mul_assign(&mut self, n: i128)
*= operation. Read moreSource§impl MulAssign<i16> for TimeValue
impl MulAssign<i16> for TimeValue
Source§fn mul_assign(&mut self, n: i16)
fn mul_assign(&mut self, n: i16)
*= operation. Read moreSource§impl MulAssign<i32> for TimeValue
impl MulAssign<i32> for TimeValue
Source§fn mul_assign(&mut self, n: i32)
fn mul_assign(&mut self, n: i32)
*= operation. Read moreSource§impl MulAssign<i64> for TimeValue
impl MulAssign<i64> for TimeValue
Source§fn mul_assign(&mut self, n: i64)
fn mul_assign(&mut self, n: i64)
*= operation. Read moreSource§impl MulAssign<i8> for TimeValue
impl MulAssign<i8> for TimeValue
Source§fn mul_assign(&mut self, n: i8)
fn mul_assign(&mut self, n: i8)
*= operation. Read moreSource§impl MulAssign<isize> for TimeValue
impl MulAssign<isize> for TimeValue
Source§fn mul_assign(&mut self, n: isize)
fn mul_assign(&mut self, n: isize)
*= operation. Read moreSource§impl MulAssign<u128> for TimeValue
impl MulAssign<u128> for TimeValue
Source§fn mul_assign(&mut self, n: u128)
fn mul_assign(&mut self, n: u128)
*= operation. Read moreSource§impl MulAssign<u16> for TimeValue
impl MulAssign<u16> for TimeValue
Source§fn mul_assign(&mut self, n: u16)
fn mul_assign(&mut self, n: u16)
*= operation. Read moreSource§impl MulAssign<u32> for TimeValue
impl MulAssign<u32> for TimeValue
Source§fn mul_assign(&mut self, n: u32)
fn mul_assign(&mut self, n: u32)
*= operation. Read moreSource§impl MulAssign<u64> for TimeValue
impl MulAssign<u64> for TimeValue
Source§fn mul_assign(&mut self, n: u64)
fn mul_assign(&mut self, n: u64)
*= operation. Read moreSource§impl MulAssign<u8> for TimeValue
impl MulAssign<u8> for TimeValue
Source§fn mul_assign(&mut self, n: u8)
fn mul_assign(&mut self, n: u8)
*= operation. Read moreSource§impl MulAssign<usize> for TimeValue
impl MulAssign<usize> for TimeValue
Source§fn mul_assign(&mut self, n: usize)
fn mul_assign(&mut self, n: usize)
*= operation. Read moreSource§impl Ord for TimeValue
impl Ord for TimeValue
Source§impl PartialOrd for TimeValue
impl PartialOrd for TimeValue
Source§impl<T> Sub<TimeInterval<T>> for TimeValue
impl<T> Sub<TimeInterval<T>> for TimeValue
Source§type Output = TimeInterval<T>
type Output = TimeInterval<T>
- operator.Source§impl<T> Sub<TimeValue> for TimeInterval<T>
impl<T> Sub<TimeValue> for TimeInterval<T>
Source§impl<T> SubAssign<TimeValue> for TimeInterval<T>
impl<T> SubAssign<TimeValue> for TimeInterval<T>
Source§fn sub_assign(&mut self, other: TimeValue)
fn sub_assign(&mut self, other: TimeValue)
-= operation. Read moreSource§impl<T: TimePoint> SubAssign<TimeValue> for TimeSet<T>
impl<T: TimePoint> SubAssign<TimeValue> for TimeSet<T>
Source§fn sub_assign(&mut self, t: TimeValue)
fn sub_assign(&mut self, t: TimeValue)
-= operation. Read moreSource§impl SubAssign<TimeValue> for Timestamp
impl SubAssign<TimeValue> for Timestamp
Source§fn sub_assign(&mut self, other: TimeValue)
fn sub_assign(&mut self, other: TimeValue)
-= operation. Read moreSource§impl SubAssign for TimeValue
impl SubAssign for TimeValue
Source§fn sub_assign(&mut self, v: TimeValue)
fn sub_assign(&mut self, v: TimeValue)
-= operation. Read moreSource§impl TimeBounds for TimeValue
impl TimeBounds for TimeValue
Source§fn is_singleton(&self) -> bool
fn is_singleton(&self) -> bool
Source§fn is_bounded(&self) -> bool
fn is_bounded(&self) -> bool
Source§fn is_low_bounded(&self) -> bool
fn is_low_bounded(&self) -> bool
Source§fn is_up_bounded(&self) -> bool
fn is_up_bounded(&self) -> bool
Source§fn lower_bound(&self) -> Self::TimePoint
fn lower_bound(&self) -> Self::TimePoint
Source§fn upper_bound(&self) -> Self::TimePoint
fn upper_bound(&self) -> Self::TimePoint
Source§impl TimePoint for TimeValue
impl TimePoint for TimeValue
Source§const INFINITE: TimeValue
const INFINITE: TimeValue
Source§fn is_future_infinite(&self) -> bool
fn is_future_infinite(&self) -> bool
Source§fn is_past_infinite(&self) -> bool
fn is_past_infinite(&self) -> bool
Source§fn just_after(&self) -> TimeValue
fn just_after(&self) -> TimeValue
Source§fn just_before(&self) -> TimeValue
fn just_before(&self) -> TimeValue
Source§impl TimePointFormat for TimeValue
impl TimePointFormat for TimeValue
fn format_timepoint(self, _timefmt: &str) -> String
Source§impl<I: TimeConvexIterator> TimeTranslation<TimeValue> for I
impl<I: TimeConvexIterator> TimeTranslation<TimeValue> for I
impl Copy for TimeValue
impl Eq for TimeValue
impl StructuralPartialEq for TimeValue
impl TimeConvex for TimeValue
Auto Trait Implementations§
impl Freeze for TimeValue
impl RefUnwindSafe for TimeValue
impl Send for TimeValue
impl Sync for TimeValue
impl Unpin for TimeValue
impl UnwindSafe for TimeValue
Blanket Implementations§
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<TW1, TW2> TimeContaining<TW2> for TW1
impl<TW1, TW2> TimeContaining<TW2> for TW1
Source§impl<TW1, TW2> TimeOverlapping<TW2> for TW1
impl<TW1, TW2> TimeOverlapping<TW2> for TW1
Source§impl<TW> TimeOverlapping<TimeSet<<TW as TimeBounds>::TimePoint>> for TWwhere
TW: TimeConvex,
impl<TW> TimeOverlapping<TimeSet<<TW as TimeBounds>::TimePoint>> for TWwhere
TW: TimeConvex,
Source§impl<TW> TimeSetFormat for TW
impl<TW> TimeSetFormat for TW
fn format_timeset(&self, timefmt: &str) -> String
Source§impl<TW> TimeWindow for TWwhere
TW: TimeConvex,
impl<TW> TimeWindow for TWwhere
TW: TimeConvex,
Source§fn is_convex(&self) -> bool
fn is_convex(&self) -> bool
Checks if the time window is convex or not
A time window is convex if it is a single time interval (or if it is empty)
Source§fn convex_count(&self) -> usize
fn convex_count(&self) -> usize
Gets the number of convex parts of the time window
It returns 0 for empty time windows and 1 for non-empty interval.