public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-backup 1/4] tools/systemd/parse_time: enable */x syntax for calendar events
@ 2020-09-11  8:35 Dominik Csapak
  2020-09-11  8:35 ` [pbs-devel] [PATCH v2 proxmox-backup 2/4] ui: fix calendarevent examples Dominik Csapak
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Dominik Csapak @ 2020-09-11  8:35 UTC (permalink / raw)
  To: pbs-devel

we support this in pve, so also support it here to have a more
consistent syntax

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/tools/systemd/parse_time.rs | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/src/tools/systemd/parse_time.rs b/src/tools/systemd/parse_time.rs
index d30a1acc..a1e40139 100644
--- a/src/tools/systemd/parse_time.rs
+++ b/src/tools/systemd/parse_time.rs
@@ -161,10 +161,17 @@ fn parse_date_time_comp(max: usize) -> impl Fn(&str) -> IResult<&str, DateTimeVa
     }
 }
 
-fn parse_date_time_comp_list(max: usize) -> impl Fn(&str) -> IResult<&str, Vec<DateTimeValue>> {
+fn parse_date_time_comp_list(start: u32, max: usize) -> impl Fn(&str) -> IResult<&str, Vec<DateTimeValue>> {
     move |i: &str| {
         if i.starts_with("*") {
-            return Ok((&i[1..], Vec::new()));
+            let i = &i[1..];
+            if i.starts_with("/") {
+                let (n, repeat) = parse_time_comp(max)(&i[1..])?;
+                if repeat > 0 {
+                    return Ok((n, vec![DateTimeValue::Repeated(start, repeat)]));
+                }
+            }
+            return Ok((i, Vec::new()));
         }
 
         separated_nonempty_list(tag(","), parse_date_time_comp(max))(i)
@@ -174,9 +181,9 @@ fn parse_date_time_comp_list(max: usize) -> impl Fn(&str) -> IResult<&str, Vec<D
 fn parse_time_spec(i: &str) -> IResult<&str, (Vec<DateTimeValue>, Vec<DateTimeValue>, Vec<DateTimeValue>)> {
 
     let (i, (hour, minute, opt_second)) = tuple((
-        parse_date_time_comp_list(24),
-        preceded(tag(":"), parse_date_time_comp_list(60)),
-        opt(preceded(tag(":"), parse_date_time_comp_list(60))),
+        parse_date_time_comp_list(0, 24),
+        preceded(tag(":"), parse_date_time_comp_list(0, 60)),
+        opt(preceded(tag(":"), parse_date_time_comp_list(0, 60))),
     ))(i)?;
 
     if let Some(second) = opt_second {
@@ -190,14 +197,14 @@ fn parse_date_spec(i: &str) -> IResult<&str, (Vec<DateTimeValue>, Vec<DateTimeVa
 
     // TODO: implement ~ for days (man systemd.time)
     if let Ok((i, (year, month, day))) = tuple((
-        parse_date_time_comp_list(2200), // the upper limit for systemd, stay compatible
-        preceded(tag("-"), parse_date_time_comp_list(13)),
-        preceded(tag("-"), parse_date_time_comp_list(32)),
+        parse_date_time_comp_list(0, 2200), // the upper limit for systemd, stay compatible
+        preceded(tag("-"), parse_date_time_comp_list(1, 13)),
+        preceded(tag("-"), parse_date_time_comp_list(1, 32)),
     ))(i) {
         Ok((i, (year, month, day)))
     } else if let Ok((i, (month, day))) = tuple((
-        parse_date_time_comp_list(13),
-        preceded(tag("-"), parse_date_time_comp_list(32)),
+        parse_date_time_comp_list(1, 13),
+        preceded(tag("-"), parse_date_time_comp_list(1, 32)),
     ))(i) {
         Ok((i, (Vec::new(), month, day)))
     } else {
-- 
2.20.1





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-09-11 10:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-11  8:35 [pbs-devel] [PATCH proxmox-backup 1/4] tools/systemd/parse_time: enable */x syntax for calendar events Dominik Csapak
2020-09-11  8:35 ` [pbs-devel] [PATCH v2 proxmox-backup 2/4] ui: fix calendarevent examples Dominik Csapak
2020-09-11  8:35 ` [pbs-devel] [PATCH proxmox-backup 3/4] docs: add section for calendar events Dominik Csapak
2020-09-11  8:35 ` [pbs-devel] [PATCH proxmox-backup 4/4] ui/docs: add onlineHelp button for syncjobs Dominik Csapak
2020-09-11 10:17 ` [pbs-devel] applied: [PATCH proxmox-backup 1/4] tools/systemd/parse_time: enable */x syntax for calendar events Dietmar Maurer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal