pub struct Time {
pub seconds: SecondsSinceUnixEpoch,
pub offset: OffsetInSeconds,
pub sign: Sign,
}
Expand description
A timestamp with timezone.
Fields§
§seconds: SecondsSinceUnixEpoch
The seconds that passed since UNIX epoch. This makes it UTC, or <seconds>+0000
.
offset: OffsetInSeconds
The time’s offset in seconds, which may be negative to match the sign
field.
sign: Sign
the sign of offset
, used to encode -0000
which would otherwise lose 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.
§Panics
If the underlying call fails as this instance can’t be represented, typically due to an invalid offset.
sourcepub fn write_to(&self, out: &mut dyn Write) -> Result<()>
pub fn write_to(&self, out: &mut dyn 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 for Time
impl PartialEq for Time
source§impl PartialOrd for Time
impl PartialOrd 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 moreimpl Copy for Time
impl Eq for Time
impl StructuralPartialEq for Time
Auto Trait Implementations§
impl Freeze for Time
impl RefUnwindSafe for Time
impl Send for Time
impl Sync for Time
impl Unpin for Time
impl UnwindSafe for Time
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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)