From fafdce7eb5d71203e68861b064b5035f1f97215e Mon Sep 17 00:00:00 2001 From: Julien Enoch Date: Tue, 2 Jul 2024 09:50:56 +0200 Subject: [PATCH] Remove rfc3339 methods for no_std --- src/ntp64.rs | 7 +++---- src/timestamp.rs | 2 ++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/ntp64.rs b/src/ntp64.rs index 2d395c1..7cb8d6e 100644 --- a/src/ntp64.rs +++ b/src/ntp64.rs @@ -118,14 +118,13 @@ impl NTP64 { /// Convert to a RFC3339 time representation with nanoseconds precision. /// e.g.: `"2024-07-01T13:51:12.129693000Z"`` + #[cfg(feature = "std")] pub fn to_string_rfc3339(&self) -> String { - #[cfg(feature = "std")] - return format_rfc3339_nanos(self.to_system_time()).to_string(); - #[cfg(not(feature = "std"))] - return self.0.to_string(); + format_rfc3339_nanos(self.to_system_time()).to_string() } /// Parse a RFC3339 time representation into a NTP64. + #[cfg(feature = "std")] pub fn parse_rfc3339(s: &str) -> Result { match humantime::parse_rfc3339(s) { Ok(time) => time diff --git a/src/timestamp.rs b/src/timestamp.rs index 50ff323..95135df 100644 --- a/src/timestamp.rs +++ b/src/timestamp.rs @@ -64,6 +64,7 @@ impl Timestamp { /// Convert to a RFC3339 time representation with nanoseconds precision. /// e.g.: `"2024-07-01T13:51:12.129693000Z/33"`` + #[cfg(feature = "std")] pub fn to_string_rfc3339(&self) -> String { #[cfg(feature = "std")] return format!("{:#}", self); @@ -72,6 +73,7 @@ impl Timestamp { } /// Parse a RFC3339 time representation into a NTP64. + #[cfg(feature = "std")] pub fn parse_rfc3339(s: &str) -> Result { match s.find('/') { Some(i) => {