AppleScripting Dates > Elapsed Time Calculator
Since Valentine’s Day is this week, I thought I would take this opportunity to share an AppleScript I wrote to calculate how long my wife and I have been married. With this baby, I’ll never be accused of forgetting how long it’s been when our anniversary rolls around. The script determines the elapsed time between now (the current date and time), and a prior date and time (such as our anniversary). It then displays the result in seconds, minutes, hours, days, weeks, months, and years.
Note: If you’re into the whole “traditional anniversary gift” thing (I’m not), you can find a list of gift categories on Wikipedia.
Creating the Script
Note: If you have any trouble following along, you can download the complete script here.
1. Launch AppleScript Editor in /Applications/Utilities and create a new script document.
2. Insert the following code:
Some notes about this script…
* I used some of the number calculation handlers in the Essential Subroutines section of macosxautomation.com, although, I made some slight modifications to them for the script. If you’re interested in learning more about AppleScript, there are some other useful handlers there, as well, and I encourage you to check them out.
* The final display dialog sets as its icon the FavoriteItemsIcon icon file, which is embedded in the CoreTypes bundle in /System/Library/CoreServices. It is, coincidentally enough, a heart.
Using the Script
To use, just run the script within AppleScript Editor, or save it as an application to be launched and run whenever you wish. First, the script asks you to enter a date and, optionally, a time.
Next, the script does its calculations and displays the result. Just take a screenshot of the dialog and send it along to your significant other.
Until next time, Happy Scripting and Happy Valentine’s Day week!
- Download iOS 7.1.1
- How To Jailbreak iOS 7 – 7.1 Untethered On iPhone 5s, 5c, 5, 4s And More With Evasi0n7
- How To Downgrade iOS 7.1-7.1.1 To iOS 6.1.3 / 6.1.2
- How To Downgrade iOS 7 To iOS 6.1.3 / 6.1.4
- How To Jailbreak iOS 6.1.3 On iPhone 4, iPod touch 4 and iPhone 3GS Using Redsn0w
- How To Jailbreak iOS 6.0 to 6.1.2 Untethered On iPhone 4,3GS, iPod touch 4 Using Sn0wbreeze 2.9.11
- How To Jailbreak iOS 6.1.2 Untethered On iPhone 5,4S, iPad, iPod touch Using Evasi0n 1.5
- How To Jailbreak iOS 6 With Official Cydia On iPhone 4, iPhone 3GS And iPod touch 4G Using Redsn0w 0.9.15b1