]> gitweb.factorcode.org Git - factor.git/commitdiff
crontab: support day=7 for Sunday, non-standard
authorJohn Benediktsson <mrjbq7@gmail.com>
Thu, 6 Apr 2023 04:01:14 +0000 (21:01 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Thu, 6 Apr 2023 04:01:14 +0000 (21:01 -0700)
extra/crontab/crontab-tests.factor
extra/crontab/crontab.factor

index 8a0604e26e9c590036e26cf475c090ff18f40fdc..138c12293f6cf49e2e40fd853f9a4a27870f9470 100644 (file)
@@ -165,3 +165,14 @@ CONSTANT: start-timestamp T{ timestamp
         "Sun, 24 Mar 2019 04:17:00 -0700"
     }
 } [ "5-20/3 4 * * *" next-few-times ] unit-test
+
+! At 04:05 on Sunday.
+{
+    {
+        "Sun, 24 Mar 2019 04:05:00 -0700"
+        "Sun, 31 Mar 2019 04:05:00 -0700"
+        "Sun, 7 Apr 2019 04:05:00 -0700"
+        "Sun, 14 Apr 2019 04:05:00 -0700"
+        "Sun, 21 Apr 2019 04:05:00 -0700"
+    }
+} [ "5 4 * * 7" next-few-times ] unit-test
index b1940c6815c6853794d81c7487122340c6a84f32..b90b69d6986df1180b399ee908d843d9fc9e3b62 100644 (file)
@@ -26,7 +26,7 @@ ERROR: invalid-cronentry value ;
     } cond ; inline recursive
 
 : parse-day ( str -- n )
-    [ string>number ] [
+    [ string>number dup 7 = [ drop 0 ] when ] [
         >lower $[ day-abbreviations3 [ >lower ] map ] index
     ] ?unless ;