Jump to content

Date arithmetic


Recommended Posts

Do you sometimes want to know:

  • the exact date a 21 day notice period will expire; or
  • how many days you'll have to wait until you can add another candle to your birthday cake?

 

Yes? Then this is the workflow for you!

 

Introduction

This workflow allows you to do two things. You can either calculate:

  • the offset from a specified date calculated in days (for example, plus 24 days or minus 320 days); or
  • the number of days between two given dates.

 

Defaultconfigdialog.thumb.png.345124860b0dbbac74478b55f14fb73d.png

Important note

In the configuration of this workflow you can choose to use the European date format (dd/mm/yyyy)—which is the default—or, by un-checking the checkbox, choose to use the US date format (mm/dd/yyyy).

For this workflow to work properly these must match:

  • the date format you choose in configuration of the workflow; and
  • the format of your computer's date in System Settings > Language & Region > Date format.


The workflow will not work properly if those settings do not match.

Usage: calculating the offset from a given date

When prompted type the date—following the format set in the User Configuration—and press ⏎. Choose Calculate offset from the dialog which is then displayed and type the offset (i.e., plus or minus the number of days) you want followed by ⏎.

Note: You simply have to type -5, +230, -4034, etc. Don't use any spaces, don't use commas within numbers and don't use any characters (like `d`) after the numbers.

A dialog similar to this will be displayed:

Offsetresult.thumb.png.e2b25d034de7fb8424cc3c44a971477d.png

Usage: calculating the days between two dates

Start the workflow exactly as before: when prompted type the date—following the format set in the User Configuration—and press ⏎. Choose Calculate days between 2 dates from the dialog which is then displayed and then type the second date (again following the format set in the User Configuration) followed by ⏎.

Note: It does not matter if the first date is later than the second: the workflow will take account of that.

A dialog similar to this will be displayed:

Daysresult.png.0403d23ca842b7b301fb569929ecb3a0.png

The workflow uses some AppleScript and an Automation Task but there are no other dependencies.

 

GitHub download link

 

Stephen

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...