Skip to content

Commit 1470eeb

Browse files
committed
Implement scheduling task on last day of month
1 parent dcdb521 commit 1470eeb

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/commands/schedule_tasks.janet

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
(defn- remove-year [formatted-date]
1818
(string/join (drop 1 (string/split "-" formatted-date)) "-"))
1919

20+
(defn- last-day-of-month? [date]
21+
(def tomorrow (date/+days date 1))
22+
(not= (date :month) (tomorrow :month)))
23+
2024
# Public
2125
(defn scheduled-for? [task date]
2226
(def formatted-date (date/format date true))
@@ -27,7 +31,8 @@
2731
"every 3 months" (and (= (date :day) 1)
2832
(index-of (date :month) [1 4 7 10]))
2933
(string "every year on " (remove-year formatted-date)) true
30-
(string "on " formatted-date) true))
34+
(string "on " formatted-date) true
35+
"every last day" (last-day-of-month? date)))
3136

3237
(defn- missed-on-day [plan task date]
3338
(find (fn [day] (and (scheduled-for? task (day :date))

0 commit comments

Comments
 (0)