pub struct Time {
pub seconds: SecondsSinceUnixEpoch,
pub offset: OffsetInSeconds,
pub sign: Sign,
}
Expand description
A timestamp with timezone.
Fields§
§seconds: SecondsSinceUnixEpoch
time in seconds since epoch.
offset: OffsetInSeconds
time offset in seconds, may be negative to match the sign
field.
sign: Sign
the sign of offset
, used to encode -0000
which would otherwise loose sign information.
Implementations§
source§impl Time
impl Time
Instantiation
sourcepub fn new(seconds: SecondsSinceUnixEpoch, offset: OffsetInSeconds) -> Self
pub fn new(seconds: SecondsSinceUnixEpoch, offset: OffsetInSeconds) -> Self
Create a new instance from seconds and offset.
sourcepub fn now_local() -> Option<Self>
pub fn now_local() -> Option<Self>
Return the current local time, or None
if the local time wasn’t available.
sourcepub fn now_local_or_utc() -> Self
pub fn now_local_or_utc() -> Self
Return the current local time, or the one at UTC if the local time wasn’t available.
source§impl Time
impl Time
Serialization with standard git
format
sourcepub fn to_bstring(&self) -> BString
pub fn to_bstring(&self) -> BString
Serialize this instance into memory, similar to what write_to()
would do with arbitrary Write
implementations.
sourcepub fn write_to(&self, out: impl Write) -> Result<()>
pub fn write_to(&self, out: impl Write) -> Result<()>
Serialize this instance to out
in a format suitable for use in header fields of serialized git commits or tags.
sourcepub fn size(&self) -> usize
pub fn size(&self) -> usize
Computes the number of bytes necessary to write it using Time::write_to()
.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Time
impl<'de> Deserialize<'de> for Time
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
source§impl Ord for Time
impl Ord for Time
source§impl PartialEq<Time> for Time
impl PartialEq<Time> for Time
source§impl PartialOrd<Time> for Time
impl PartialOrd<Time> for Time
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