pub struct Timestamp { /* private fields */ }Expand description
The representation for a timestamp used by the TZif implementation.
We don’t use Timestamp from the root of this crate
because TZif data doesn’t require nanosecond resolution. Instead, this
representation uses only second resolution. This makes for a more compact
sequence of transitions, which means more data fits into cache and thus
faster binary search.
Implementations§
Source§impl Timestamp
impl Timestamp
Sourcepub const UNIX_EPOCH: Timestamp
pub const UNIX_EPOCH: Timestamp
The zero value for a timestamp, which also corresponds to the Unix
epoch (1970-01-01T00:00:00Z).
Sourcepub const fn new(ts: Timestamp) -> Timestamp
pub const fn new(ts: Timestamp) -> Timestamp
Creates a new TZif timestamp from jiff-core’s standard timestamp type.
Note that this completely ignores any subsecond component of the provided timestamp.
Sourcepub const fn from_second(second: i64) -> Result<Timestamp, RangeError>
pub const fn from_second(second: i64) -> Result<Timestamp, RangeError>
Creates a new Timestamp from a Unix timestamp integer value.
This returns an error if the value is not in the legal bounds for this type.
Sourcepub const fn as_second(self) -> i64
pub const fn as_second(self) -> i64
Returns the second value of this timestamp.
It is the number of seconds since the Unix epoch
(1970-01-01T00:00:00Z). Timestamps prior to the Unix epoch are
negative. Timestamps are the Unix epoch are 0.
Sourcepub const fn to_datetime(self, offset: Offset) -> DateTime
pub const fn to_datetime(self, offset: Offset) -> DateTime
Converts this timestamp to a civil datetime for the offset given.
Sourcepub const fn to_standard_timestamp(self) -> Timestamp
pub const fn to_standard_timestamp(self) -> Timestamp
Converts this timestamp back to the “standard” timestamp.
Note that the timestamp returned here always has its nanosecond
component set to 0.