pub struct DateTime { /* private fields */ }
Expand description
Date-and-time type shared by multiple ASN.1 types
(e.g. GeneralizedTime
, UTCTime
).
Following conventions from RFC 5280, this type is always Z-normalized
(i.e. represents a UTC time). However, it isn’t named “UTC time” in order
to prevent confusion with ASN.1 UTCTime
.
Implementations§
Source§impl DateTime
impl DateTime
Sourcepub const INFINITY: DateTime = _
pub const INFINITY: DateTime = _
This is the maximum date represented by the DateTime
This corresponds to: 9999-12-31T23:59:59Z
Sourcepub fn new(
year: u16,
month: u8,
day: u8,
hour: u8,
minutes: u8,
seconds: u8,
) -> Result<Self>
pub fn new( year: u16, month: u8, day: u8, hour: u8, minutes: u8, seconds: u8, ) -> Result<Self>
Create a new DateTime
from the given UTC time components.
Sourcepub fn from_unix_duration(unix_duration: Duration) -> Result<Self>
pub fn from_unix_duration(unix_duration: Duration) -> Result<Self>
Sourcepub fn unix_duration(&self) -> Duration
pub fn unix_duration(&self) -> Duration
Compute Duration
since UNIX_EPOCH
from the given calendar date.
Sourcepub fn from_system_time(time: SystemTime) -> Result<Self>
pub fn from_system_time(time: SystemTime) -> Result<Self>
Instantiate from SystemTime
.
Sourcepub fn to_system_time(&self) -> SystemTime
pub fn to_system_time(&self) -> SystemTime
Convert to SystemTime
.
Trait Implementations§
Source§impl<'a> DecodeValue<'a> for DateTime
impl<'a> DecodeValue<'a> for DateTime
Source§impl EncodeValue for DateTime
impl EncodeValue for DateTime
Source§impl From<&DateTime> for GeneralizedTime
impl From<&DateTime> for GeneralizedTime
Source§impl From<&DateTime> for SystemTime
impl From<&DateTime> for SystemTime
Source§fn from(time: &DateTime) -> SystemTime
fn from(time: &DateTime) -> SystemTime
Converts to this type from the input type.
Source§impl From<&GeneralizedTime> for DateTime
impl From<&GeneralizedTime> for DateTime
Source§fn from(utc_time: &GeneralizedTime) -> DateTime
fn from(utc_time: &GeneralizedTime) -> DateTime
Converts to this type from the input type.
Source§impl From<DateTime> for GeneralizedTime
impl From<DateTime> for GeneralizedTime
Source§impl From<DateTime> for SystemTime
impl From<DateTime> for SystemTime
Source§fn from(time: DateTime) -> SystemTime
fn from(time: DateTime) -> SystemTime
Converts to this type from the input type.
Source§impl From<GeneralizedTime> for DateTime
impl From<GeneralizedTime> for DateTime
Source§fn from(utc_time: GeneralizedTime) -> DateTime
fn from(utc_time: GeneralizedTime) -> DateTime
Converts to this type from the input type.
Source§impl Ord for DateTime
impl Ord for DateTime
Source§impl PartialOrd for DateTime
impl PartialOrd for DateTime
Source§impl TryFrom<&SystemTime> for DateTime
impl TryFrom<&SystemTime> for DateTime
Source§impl TryFrom<SystemTime> for DateTime
impl TryFrom<SystemTime> for DateTime
impl Copy for DateTime
impl Eq for DateTime
impl StructuralPartialEq for DateTime
Auto Trait Implementations§
impl Freeze for DateTime
impl RefUnwindSafe for DateTime
impl Send for DateTime
impl Sync for DateTime
impl Unpin for DateTime
impl UnwindSafe for DateTime
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)Source§impl<'a, T> Decode<'a> for Twhere
T: DecodeValue<'a> + FixedTag,
impl<'a, T> Decode<'a> for Twhere
T: DecodeValue<'a> + FixedTag,
Source§impl<T> Encode for Twhere
T: EncodeValue + Tagged,
impl<T> Encode for Twhere
T: EncodeValue + Tagged,
Source§fn encoded_len(&self) -> Result<Length, Error>
fn encoded_len(&self) -> Result<Length, Error>
Compute the length of this value in bytes when encoded as ASN.1 DER.
Source§fn encode(&self, writer: &mut impl Writer) -> Result<(), Error>
fn encode(&self, writer: &mut impl Writer) -> Result<(), Error>
Encode this value as ASN.1 DER using the provided Writer
.
Source§fn encode_to_slice<'a>(&self, buf: &'a mut [u8]) -> Result<&'a [u8]>
fn encode_to_slice<'a>(&self, buf: &'a mut [u8]) -> Result<&'a [u8]>
Encode this value to the provided byte slice, returning a sub-slice
containing the encoded message.