Date Calculation - Creating a date for "next Saturday", etc.
Typinator comes with some great features for date and time calculation, which makes it easy to produce a date 5 days in the future with a few keystrokes. But sometimes you may want to refer to a date on a certain weekday, such as “next Saturday”. On Friday, this would be just one day ahead, but on Monday, you would need to advance the date by five days.
You can do this by combining a few elements of Typinator.
First, you assemble the year, month and day markers to produce the date in the desired format:
{YYYY}-{MM}-{DD}
Of course, you can use any format. Just use the {…} pop-up to insert the building blocks for the desired date format.
Next, you use the Date calculation for advancing the date by a few days. The marker for this is:
{{dayDelta=x}}
Where x is the desired number of days. Put this marker BEFORE the date format, so that the advancement takes place before the date markers are expanded.
Now you need to insert the correct number of days instead of x. On a Friday, this would be 1, on a Saturday 7, on a Sunday 6, on a Monday 5, and so on. For the days Monday through Sunday, the offsets would be: 5, 4, 3, 2, 1, 7, 6. To find the correct offset, you can use the weekday number {DM1}, which starts with 1 for Monday, and use the built-in /Choose function to pick the corresponding offset from a list of 7 numbers, where the numbers must be separated by slashes.
The final expansion for "next Saturday" looks like this:
{{dayDelta={/Choose {DM1}/5/4/3/2/1/7/6/}}}{YYYY}-{MM}-{DD}
To create a similar rule for "next Sunday", just offset the days by one, like this:
{{dayDelta={/Choose {DM1}/6/5/4/3/2/1/7/}}}{YYYY}-{MM}-{DD}
This tip requires Typinator 7.0 or newer, as the built-in /Choose function is not available in older versions of Typinator.