Date calculation

Tags ( | )

My GTD "Update" script calculates next review dates from a column "Recur" in the notebook.

However, sometimes I want to set that date myself. AppleScript provides the "days" and "weeks" constants, which you can use to calcululate future dates, but it does not have "months" and "years", so a script must calculate those dates itself.

Here's a short subroutine that will do this. It is derived from a script in this thread at MacScripter.

The calculation does not 'overflow' dates into the month after the target month; when it's jan 31 and you add 1 month, it returns feb 28, not mar 2. AppleScript 'knows' about leap years, too.
To use with years simply multiply years by 12 before calling the subroutine.

Version:
AttachmentSize
Date calculations.zip2.8 KB