From 29644ca85e5423e149a5ebc8742f99ba4dc4fbab Mon Sep 17 00:00:00 2001 From: itohatweb Date: Fri, 27 Dec 2024 22:18:32 +0000 Subject: [PATCH] feat: support plural --- src/unit.rs | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/unit.rs b/src/unit.rs index 8fa88e3..34623e2 100644 --- a/src/unit.rs +++ b/src/unit.rs @@ -73,18 +73,17 @@ impl FromStr for TimeUnit { fn from_str(s: &str) -> Result { match &*s.to_lowercase() { - "y" | "year" => Ok(TimeUnit::Year), - "mon" | "month" => Ok(TimeUnit::Month), - "w" | "week" => Ok(TimeUnit::Week), - "d" | "day" => Ok(TimeUnit::Day), - "h" | "hour" | "hr" => Ok(TimeUnit::Hour), - "m" | "min" | "minute" => Ok(TimeUnit::Minute), - "s" | "sec" | "second" => Ok(TimeUnit::Second), - "ms" | "msec" | "millisecond" => Ok(TimeUnit::MilliSecond), - "µs" | "µsec" | "µsecond" | "us" | "usec" | "usecond" | "microsecond" => { - Ok(TimeUnit::MicroSecond) - } - "ns" | "nsec" | "nanosecond" => Ok(TimeUnit::NanoSecond), + "y" | "year" | "years" => Ok(TimeUnit::Year), + "mon" | "month" | "months" => Ok(TimeUnit::Month), + "w" | "week" | "weeks" => Ok(TimeUnit::Week), + "d" | "day" | "days" => Ok(TimeUnit::Day), + "h" | "hr" | "hour" | "hours" => Ok(TimeUnit::Hour), + "m" | "min" | "minute" | "minutes" => Ok(TimeUnit::Minute), + "s" | "sec" | "second" | "seconds" => Ok(TimeUnit::Second), + "ms" | "msec" | "millisecond" | "milliseconds" => Ok(TimeUnit::MilliSecond), + "µs" | "µsec" | "µsecond" | "us" | "usec" | "usecond" | "microsecond" + | "microseconds" => Ok(TimeUnit::MicroSecond), + "ns" | "nsec" | "nanosecond" | "nanoseconds" => Ok(TimeUnit::NanoSecond), _ => Err(DError::ParseError(Self::expect_err(s))), } }