pub struct DateTime {
year: u16,
month: u8,
day: u8,
hour: u8,
minutes: u8,
seconds: u8,
unix_duration: Duration,
}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.
Fields§
§year: u16Full year (e.g. 2000).
Must be >=1970 to permit positive conversions to Unix time.
month: u8Month (1-12)
day: u8Day of the month (1-31)
hour: u8Hour (0-23)
minutes: u8Minutes (0-59)
seconds: u8Seconds (0-59)
unix_duration: DurationDuration since the Unix epoch.
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
Source§impl From<&GeneralizedTime> for DateTime
impl From<&GeneralizedTime> for DateTime
Source§fn from(utc_time: &GeneralizedTime) -> DateTime
fn from(utc_time: &GeneralizedTime) -> 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
Source§impl From<GeneralizedTime> for DateTime
impl From<GeneralizedTime> for DateTime
Source§fn from(utc_time: GeneralizedTime) -> DateTime
fn from(utc_time: GeneralizedTime) -> DateTime
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 OrdIsValueOrd 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.