From be4da1443de1a0ce889dc707251b64b02627ce75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Sat, 14 Sep 2024 13:13:54 -0300 Subject: [PATCH] types: duration: Deal with empty as PT0S MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Patrick José Pereira --- xsd-types/src/types/duration.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/xsd-types/src/types/duration.rs b/xsd-types/src/types/duration.rs index 8ff29a2..ccaffbe 100644 --- a/xsd-types/src/types/duration.rs +++ b/xsd-types/src/types/duration.rs @@ -97,6 +97,11 @@ impl FromStr for Duration { let mut dur: Duration = Default::default(); let mut context = ParsingContext::new(); + + if s.is_empty() { + return Ok(dur); + } + for (i, c) in s.chars().enumerate() { match c { '-' => {