Since I plan to live to 100 I want to make sure I make good use of my time. I already have a motivational hashtag: TheNext40, but 40 years is a long time. I thought it could be handy to have something to tell me just how many days that is.
First I created a new Keyboard Maestro macro and assigned it a key command. Then I added a comment to remind me what I was doing and a couple of actions.
I visited the Epoch Unix Time Stamp Converter page and asked it to tell me the Unix timestamp for the last moment of the day I turn 100. That number is how many seconds have elapsed since the start of the Unix Epoch on 01 January 1970.
In Keyboard Maestro I then used an action to subtract NOW from that timestamp and divide the result by 60*60*24 to convert the seconds to days. NOW is a Keyboard Maestro function that gives you the Unix Timestamp for the present moment. I assigned that number to a variable called DaysLeft.
That gave me a result in days with about 5 digits after a decimal point. There are various ways to deal with that. I decided to use a Substring that lops off the decimal point and everything after it, provided the number of days is 10,000 or more. In my case DaysLeft is currently running at 14 and a half thousand, so in about 12 years I’ll need to edit my macro.
Finally I have the macro speak me the number of days and show it in a small window.
This small project was fun, and now I can quickly call up this additional motivation to not waste my time whenever I need a bit of a push.
Note: I’m sure there are a dozen apps and a hundred web pages to tell me how many days are left until…, but I didn’t want an app or to consult a web page. This approach also expanded my knowledge of an app I already use heavily, and was entertaining to create. Next I may make a macro to tell me how long it is until my trip to Spain later this year.
UPDATE: the fine folks at Keyboard Maestro spotted my tweet about this post and said:
@miraz I can give you the epoch with TIME(2055,2,14), & I can truncate an integer with TRUNC, so:
So that means the whole thing can be achieved in 1 step. Magnificent!