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 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 PartialEq<DateTime> for DateTime
impl PartialEq<DateTime> for DateTime
source§impl PartialOrd<DateTime> for DateTime
impl PartialOrd<DateTime> for DateTime
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§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 StructuralEq for DateTime
impl StructuralPartialEq for DateTime
Auto Trait Implementations§
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<'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 dyn Writer) -> Result<(), Error>
fn encode(&self, writer: &mut dyn 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.