From ecb4e36e2a8b4e1fb015c7b2f3c6ad866d04a0a1 Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Tue, 25 Aug 2026 22:12:25 -0700 Subject: [PATCH] x509-tsp: provide a to_datetime for `GeneralizedTimeNanos` This is mostly useful for human-readable messages. --- x509-tsp/src/generalized_time_nanos.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/x509-tsp/src/generalized_time_nanos.rs b/x509-tsp/src/generalized_time_nanos.rs index ec9fba283..2e48863d8 100644 --- a/x509-tsp/src/generalized_time_nanos.rs +++ b/x509-tsp/src/generalized_time_nanos.rs @@ -49,6 +49,14 @@ impl GeneralizedTimeNanos { nanoseconds: unix_duration.subsec_nanos(), }) } + + /// Convert this [`GeneralizedTimeNanos`] into a [`DateTime`]. + /// + /// Note: This looses the nanoseconds precision. + #[must_use] + pub const fn to_date_time(&self) -> DateTime { + self.datetime + } } impl From for GeneralizedTimeNanos {