From 956295cefe9ba06262ee22fe6bd1409adff4a3ca Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Tue, 21 Jul 2020 13:24:48 +0200 Subject: [PATCH] parse_calendar_event: support the weekly special expression While we do not yet support the date specs for CalendarEvent the left out "weekly" special expression[0] dies not requires that support. It is specified to be equivalent with `Mon *-*-* 00:00:00` [0] and this can be implemented with the weekday and time support we already have. [0]: https://www.freedesktop.org/software/systemd/man/systemd.time.html#Calendar%20Events Signed-off-by: Thomas Lamprecht --- src/tools/systemd/parse_time.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/tools/systemd/parse_time.rs b/src/tools/systemd/parse_time.rs index b1cbc38d..93657b21 100644 --- a/src/tools/systemd/parse_time.rs +++ b/src/tools/systemd/parse_time.rs @@ -219,7 +219,16 @@ fn parse_calendar_event_incomplete(mut i: &str) -> IResult<&str, CalendarEvent> ..Default::default() })); } - "monthly" | "weekly" | "yearly" | "quarterly" | "semiannually" => { + "weekly" => { + return Ok(("", CalendarEvent { + hour: vec![DateTimeValue::Single(0)], + minute: vec![DateTimeValue::Single(0)], + second: vec![DateTimeValue::Single(0)], + days: WeekDays::MONDAY, + ..Default::default() + })); + } + "monthly" | "yearly" | "quarterly" | "semiannually" => { return Err(parse_error(i, "unimplemented date or time specification")); } _ => { /* continue */ }