Skip to content

Commit 6316b26

Browse files
authored
x509-tsp: impl From<GeneralizedTime> for GeneralizedTimeNanos (#2065)
Hopefully that can smooth out transition to `GeneralizedTimeNanos`
1 parent d5f7ab8 commit 6316b26

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

x509-tsp/src/generalized_time_nanos.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use core::str::FromStr;
22
use core::time::Duration;
33
use der::{
44
DateTime, DecodeValue, EncodeValue, ErrorKind, FixedTag, Header, Length, Reader, Result, Tag,
5-
Writer,
5+
Writer, asn1::GeneralizedTime,
66
};
77

88
/// ASN.1 `GeneralizedTime` type.
@@ -39,6 +39,15 @@ impl GeneralizedTimeNanos {
3939
}
4040
}
4141

42+
impl From<GeneralizedTime> for GeneralizedTimeNanos {
43+
fn from(time: GeneralizedTime) -> Self {
44+
Self {
45+
datetime: time.to_date_time(),
46+
nanoseconds: 0,
47+
}
48+
}
49+
}
50+
4251
/// Decode 2-digit decimal value
4352
#[allow(clippy::arithmetic_side_effects)]
4453
fn decode_decimal(tag: Tag, hi: u8, lo: u8) -> Result<u8> {

0 commit comments

Comments
 (0)