pub struct Timestamp { /* private fields */ }Expand description
Represents a point in time to a specified degree of precision. Unlike chrono’s NaiveDateTime
and DateTime, a Timestamp has variable precision ranging from a year to fractional seconds
of an arbitrary unit.
Implementations§
Source§impl Timestamp
impl Timestamp
Sourcepub fn fractional_seconds_scale(&self) -> Option<i64>
pub fn fractional_seconds_scale(&self) -> Option<i64>
If the precision is TimestampPrecision::Second, returns the Decimal scale of this Timestamp’s fractional seconds; otherwise, returns None.
For example, a Timestamp with 553 milliseconds would return a Decimal scale of 3.
Sourcepub fn with_year(year: u32) -> TimestampBuilder<HasYear>
pub fn with_year(year: u32) -> TimestampBuilder<HasYear>
Creates a TimestampBuilder with the specified year and TimestampPrecision::Year.
Sourcepub fn with_ymd(year: u32, month: u32, day: u32) -> TimestampBuilder<HasDay>
pub fn with_ymd(year: u32, month: u32, day: u32) -> TimestampBuilder<HasDay>
Creates a TimestampBuilder with the specified year, month, and day. Its precision is set to TimestampPrecision::Day.
Sourcepub fn offset(&self) -> Option<i32>
pub fn offset(&self) -> Option<i32>
Returns the offset in minutes that has been specified in the Timestamp. A positive value indicates Eastern Hemisphere, while a negative value indicates Western Hemisphere.
Sourcepub fn precision(&self) -> TimestampPrecision
pub fn precision(&self) -> TimestampPrecision
Returns the precision that has been specified in the Timestamp.
Sourcepub fn month(&self) -> u32
pub fn month(&self) -> u32
Returns the month that has been specified in the Timestamp. Returns the month number starting from 1. The return value ranges from 1 to 12.
Sourcepub fn day(&self) -> u32
pub fn day(&self) -> u32
Returns the day that has been specified in the Timestamp. Returns the day of month starting from 1.
Sourcepub fn hour(&self) -> u32
pub fn hour(&self) -> u32
Returns the hour(s) that has been specified in the Timestamp. Returns the hour number from 0 to 23.
Sourcepub fn minute(&self) -> u32
pub fn minute(&self) -> u32
Returns the minute(s) that has been specified in the Timestamp. Returns the minute number from 0 to 59.
Sourcepub fn second(&self) -> u32
pub fn second(&self) -> u32
Returns the second(s) that has been specified in the Timestamp. Returns the second number from 0 to 59.
Sourcepub fn nanoseconds(&self) -> u32
pub fn nanoseconds(&self) -> u32
Returns this Timestamp’s fractional seconds in nanoseconds
NOTE: This is a potentially lossy operation. A Timestamp with picoseconds would return a
number of nanoseconds, losing precision. If it loses precision then truncation is performed.
(e.g. a timestamp with fractional seconds of 0.000000000999 would return 0)
Sourcepub fn microseconds(&self) -> u32
pub fn microseconds(&self) -> u32
Returns this Timestamp’s fractional seconds in microseconds
NOTE: This is a potentially lossy operation. A Timestamp with picoseconds would return a
number of microseconds, losing precision. If it loses precision then truncation is performed.
(e.g. a timestamp with fractional seconds of 0.000000999 would return 0)
Sourcepub fn milliseconds(&self) -> u32
pub fn milliseconds(&self) -> u32
Returns this Timestamp’s fractional seconds in milliseconds
NOTE: This is a potentially lossy operation. A Timestamp with picoseconds would return a
number of milliseconds, losing precision. If it loses precision then truncation is performed.
(e.g. a timestamp with fractional seconds of 0.000999 would return 0)
Trait Implementations§
impl Eq for Timestamp
Source§impl Ord for Timestamp
impl Ord for Timestamp
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for Timestamp
Two Timestamps are considered equal (though not necessarily IonEq) if they represent the same
instant in time. TimestampPrecision is ignored. Offsets do not have to match as long as the instants
being represented match. Examples:
impl PartialEq for Timestamp
Two Timestamps are considered equal (though not necessarily IonEq) if they represent the same instant in time. TimestampPrecision is ignored. Offsets do not have to match as long as the instants being represented match. Examples:
2022T==2022T-012022T==2022T-01-01T00:00:00.000+00:002022T-05-11T12:00:00.000Z==2022T-05-11T07:00:00.000-05:00
Auto Trait Implementations§
impl Freeze for Timestamp
impl RefUnwindSafe for Timestamp
impl Send for Timestamp
impl Sync for Timestamp
impl Unpin for Timestamp
impl UnsafeUnpin for Timestamp
impl UnwindSafe for Timestamp
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<V> IntoAnnotatedElement for V
impl<V> IntoAnnotatedElement for V
Source§fn with_annotations<I: IntoAnnotations>(self, annotations: I) -> Element
fn with_annotations<I: IntoAnnotations>(self, annotations: I) -> Element
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more