diff options
Diffstat (limited to 'src/options.rs')
-rw-r--r-- | src/options.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/options.rs b/src/options.rs index dc2d186..4e6f1cd 100644 --- a/src/options.rs +++ b/src/options.rs @@ -248,3 +248,17 @@ impl Display for RRuleParseError { } impl Error for RRuleParseError {} + + +pub fn weekday_from_str(val: &str) -> Result<Weekday, String> { + match val { + "MO" => Ok(Weekday::Mon), + "TU" => Ok(Weekday::Tue), + "WE" => Ok(Weekday::Wed), + "TH" => Ok(Weekday::Thu), + "FR" => Ok(Weekday::Fri), + "SA" => Ok(Weekday::Sat), + "SU" => Ok(Weekday::Sun), + _ => Err(format!("Invalid weekday: {}", val)), + } +}
\ No newline at end of file |