Working dates is something that I’ve seen come up a couple of times so I took a whirl at creating a drop in solution. I’m sure it’ll come up again, and having this available should make it a little easier/quicker to produce workable solutions.
Working Days
I’ve created a “Working Days” shortcut that is intended as a ‘helper’ shortcut, as in one you don’t run directly but run from other shortcuts. The principle should be pretty straight forward to get. Given a range of dates, the shortcut examines each in turn, figures out if it is a ‘working’ day, and if it is adds it to an accumulating list of dates it returns at the end.
Here’s how it works in a bit more detail.
The shortcut is designed to take an input in two parts - a start date, and an end date. These are taken as inclusive dates. i.e. if you specify 1 March and 3 March, that would be three days it would be checking against.
The shortcut also contains a dictionary of the days of the week. Each entry has a Boolean value. When set as true it is considered a working day and when set as false it is not. People can therefore customise the names of the days and the working days to suit their own needs.
The shortcut iterates over the range of dates, checks if it is a working day, and if it is, adds it to a result variable. This result variable in effect becomes an ordered list of dates in the specified date range which are ‘working dates’. This list is returned by the shortcut at the end to the calling shortcut.
Here’s the shortcut and a testing shortcut to accompany it. The latter calls the former and outputs the results for viewing.
Screenshots of a test run
Grading Shortcut
I’ve modified the existing Grading shortcut to use the Working Days shortcut - consider the Working Days shortcut a prerequisite. The original version is based on iterating over a number of dates and I’ve kept that as is, though given there’s actually a list of dates being passed back to the shortcut, performance could be improved very slightly by iterating over the list directly without counts, etc.; but it seemed so insignificant in reality, and such a fundamental shift in approach I left well alone on this occasion.
The loop now references the date list by index rather than calculating dates (and then having to skip), but otherwise it works the same.
I also added an alert in at the end as, whilst I have Drafts, I’m not a Things users and so the final couple of actions makes no difference for me (and in fact the open in doesn’t list the app for me).
Here’s the amended shortcut - do remember you’ll need the Working Days shortcut from above for it to work.
I’ve included some screenshots of a couple of example runs:
Example Grading Run # 1
Example Grading Run # 2
Hopefully the above matches what to what is required and gives some flexibility for other solutions for other people in the future.