pub struct Ticks { /* private fields */ }
Expand description
Represents a 64-bit integer used to designate time in STTP. The value represents the number of 100-nanosecond intervals that have elapsed since 12:00:00 midnight, January 1, 0001 UTC, Gregorian calendar.
A single tick represents one hundred nanoseconds, or one ten-millionth of a second. There are 10,000 ticks in a millisecond and 10 million ticks in a second. Only bits 01 to 62 (0x3FFFFFFFFFFFFFFF) are used to represent the timestamp value. Bit 64 (0x8000000000000000) is used to denote leap second, i.e., second 60, where actual second value would remain at 59. Bit 63 (0x4000000000000000) is used to denote leap second direction, 0 for add, 1 for delete.
Implementations§
source§impl Ticks
impl Ticks
sourcepub const PER_SECOND: u64 = 10_000_000u64
pub const PER_SECOND: u64 = 10_000_000u64
Number of Ticks
that occur in a second.
sourcepub const PER_MILLISECOND: u64 = 10_000_000u64
pub const PER_MILLISECOND: u64 = 10_000_000u64
Number of Ticks
that occur in a millisecond.
sourcepub const PER_MICROSECOND: u64 = 10u64
pub const PER_MICROSECOND: u64 = 10u64
Number of Ticks
that occur in a microsecond.
sourcepub const PER_MINUTE: u64 = 600_000_000u64
pub const PER_MINUTE: u64 = 600_000_000u64
Number of Ticks
that occur in a minute.
sourcepub const LEAP_SECOND_FLAG: u64 = 9_223_372_036_854_775_808u64
pub const LEAP_SECOND_FLAG: u64 = 9_223_372_036_854_775_808u64
Flag (64th bit) that marks a Ticks
value as a leap second, i.e., second 60 (one beyond normal second 59).
sourcepub const LEAP_SECOND_DIRECTION: u64 = 4_611_686_018_427_387_904u64
pub const LEAP_SECOND_DIRECTION: u64 = 4_611_686_018_427_387_904u64
Flag (63rd bit) that indicates if leap second is positive or negative; 0 for add, 1 for delete.
sourcepub const VALUE_MASK: u64 = 4_611_686_018_427_387_903u64
pub const VALUE_MASK: u64 = 4_611_686_018_427_387_903u64
All bits (bits 1 to 62) that make up the value portion of a Ticks
that represent time.
sourcepub const UNIX_BASE_OFFSET: u64 = 621_355_968_000_000_000u64
pub const UNIX_BASE_OFFSET: u64 = 621_355_968_000_000_000u64
Ticks
representation of the Unix epoch timestamp starting at January 1, 1970.
sourcepub fn timestamp_value(&self) -> u64
pub fn timestamp_value(&self) -> u64
Gets the timestamp portion of the Ticks
value, i.e.,
the 62-bit time value excluding any leap second flags.
sourcepub fn from_datetime<Tz: TimeZone>(dt: DateTime<Tz>) -> Selfwhere
DateTime<Tz>: From<SystemTime>,
pub fn from_datetime<Tz: TimeZone>(dt: DateTime<Tz>) -> Selfwhere
DateTime<Tz>: From<SystemTime>,
Converts a standard Rust DateTime
value to a Ticks
value.
sourcepub fn from_duration(duration: Duration) -> Self
pub fn from_duration(duration: Duration) -> Self
Converts a standard Rust Duration
value to a Ticks
value.
sourcepub fn to_datetime(&self) -> DateTime<Utc>
pub fn to_datetime(&self) -> DateTime<Utc>
Converts a Ticks
value to standard Rust DateTime
value.
sourcepub fn is_leap_second(&self) -> bool
pub fn is_leap_second(&self) -> bool
Determines if the deserialized Ticks
value represents a leap second, i.e., second 60.
sourcepub fn set_leap_second(&self) -> Self
pub fn set_leap_second(&self) -> Self
Returns a copy of this Ticks
value flagged to represent a leap second, i.e., second 60, before wire serialization.
sourcepub fn apply_leap_second(&mut self)
pub fn apply_leap_second(&mut self)
Updates this Ticks
value to represent a leap second, i.e., second 60, before wire serialization.
sourcepub fn is_negative_leap_second(&self) -> bool
pub fn is_negative_leap_second(&self) -> bool
Determines if the deserialized Ticks
value represents a negative leap second, i.e., checks flag on second 58 to see if second 59 will be missing.
sourcepub fn set_negative_leap_second(&self) -> Self
pub fn set_negative_leap_second(&self) -> Self
Returns a copy of this Ticks
value flagged to represent a negative leap second, i.e., sets flag on second 58 to mark that second 59 will be missing, before wire serialization.
sourcepub fn apply_negative_leap_second(&mut self)
pub fn apply_negative_leap_second(&mut self)
Updates this Ticks
value to represent a negative leap second, i.e., sets flag on second 58 to mark that second 59 will be missing, before wire serialization.
sourcepub fn to_string(&self) -> String
pub fn to_string(&self) -> String
Standard timestamp representation for a Ticks
value, e.g., 2006-01-02 15:04:05.999999999.
sourcepub fn to_short_string(&self) -> String
pub fn to_short_string(&self) -> String
Shows just the timestamp portion of a Ticks
value with milliseconds, e.g., 15:04:05.999.
Trait Implementations§
source§impl Ord for Ticks
impl Ord for Ticks
source§impl PartialEq<Ticks> for Ticks
impl PartialEq<Ticks> for Ticks
source§impl PartialOrd<Ticks> for Ticks
impl PartialOrd<Ticks> for Ticks
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more