File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2828 (index-of (date :month ) [1 4 7 10 ]))
2929 (string " every year on " (remove-year formatted-date )) true
3030 (string " on " formatted-date ) true
31- " every last day" (date/last-day-of-month? date )))
31+ " every last day" (date/last-day-of-month? date )
32+ " every last Friday" (date/last-friday-of-month? date )))
3233
3334(defn- missed-on-day [plan task date ]
3435 (find (fn [day ] (and (scheduled-for? task (day :date ))
Original file line number Diff line number Diff line change 125125
126126(defn last-day-of-month?
127127 ```
128- Returns true if date is the last day of a month.
128+ Returns true if the date is the last day of a month.
129129 ```
130130 [date ]
131131 (def tomorrow (+days date 1 ))
132132 (not= (date :month ) (tomorrow :month )))
133+
134+ (defn last-friday-of-month?
135+ ```
136+ Returns true if the date is the last friday of a month.
137+ ```
138+ [date ]
139+ (def next-week (+days date 7 ))
140+ (and (= (date :week-day ) " Friday" )
141+ (not= (date :month ) (next-week :month ))))
Original file line number Diff line number Diff line change 8383 (is (scheduled-for? task (d/date 2023 1 31 )))
8484 (is (not (scheduled-for? task (d/date 2022 1 30 )))))
8585
86+ (deftest scheduled-for-last-Friday-of-month
87+ (def task (task/build-scheduled-task " Review logs" " every last Friday" ))
88+ (is (scheduled-for? task (d/date 2022 1 28 )))
89+ (is (scheduled-for? task (d/date 2022 2 25 )))
90+ (is (scheduled-for? task (d/date 2022 3 25 )))
91+ (is (scheduled-for? task (d/date 2022 4 29 )))
92+ (is (scheduled-for? task (d/date 2022 5 27 )))
93+ (is (not (scheduled-for? task (d/date 2022 1 31 )))))
94+
8695# # —————————————————————————————————————————————————————————————————————————————————————————————————
8796# # Test missed?
8897
Original file line number Diff line number Diff line change 8787 (is (d/last-day-of-month? (d/date 2023 1 31 )))
8888 (is (not (d/last-day-of-month? (d/date 2022 1 30 )))))
8989
90+ # # ————————————————————————————————————————————————————————————————————————————————————————————————
91+ # # Test last-Friday-of-month?
92+
93+ (deftest last-friday-of-month?
94+ (is (d/last-friday-of-month? (d/date 2022 1 28 )))
95+ (is (d/last-friday-of-month? (d/date 2022 2 25 )))
96+ (is (d/last-friday-of-month? (d/date 2022 3 25 )))
97+ (is (d/last-friday-of-month? (d/date 2022 4 29 )))
98+ (is (d/last-friday-of-month? (d/date 2022 5 27 )))
99+ (is (not (d/last-friday-of-month? (d/date 2022 1 31 ))))
100+ (is (not (d/last-friday-of-month? (d/date 2022 1 21 ))))
101+ (is (not (d/last-friday-of-month? (d/date 2022 2 11 )))))
90102
91103# # ————————————————————————————————————————————————————————————————————————————————————————————————
92104# # Test +days
You can’t perform that action at this time.
0 commit comments