![]() Depending on how you install Python, you may also need to install dateutil. Since Apple no longer includes Python with macOS, you’ll have to install it yourself through the Xcode Command Line Tools, Homebrew, or some other means. The Python script that does the calculations is python:Ħ: day1 = parse(os.environ, dayfirst=False, yearfirst=False)ħ: day2 = parse(os.environ, dayfirst=False, yearfirst=False) It doesn’t take long to build, but you can also download it. Here’s what the Days Between macro looks like. It will handle both hyphens and slashes as separators, it can be configured to handle either month-first or day-first dates, it understands (within some limits) two-digit years, and you don’t need to include the year at all if it’s the current year. There’s a fair amount of flexibility in dateutil’s parse command. Days Between uses Python’s dateutil library to parse the input dates. This is discussed in my earlier post, but it’s worth a mention here, too. At present, the checkbox is unchecked by default I’ll change that if I find myself checking it most of the time. Hence the Copy Answer to Clipboard checkbox, which I can check quickly via the tab and spacebar keys. Sometimes I want to just want to see the answer, sometimes I want the answer on the clipboard so I can paste it somewhere. ![]() The notification window disappears after a few seconds. Why I didn’t think of it years ago is a mystery.Īfter entering a date, say September 23, 2022, for the start date, and pressing the Return key, 2 the input window vanishes and the output appears in a notification window in the upper right corner of the screen. This is a very simple solution to the problem of making a single macro that handles all three cases with the least amount of effort for the user. ![]() I invoke the Days Between macro with ⌃⌘D to bring up this window.ĭays Between needs two dates, but by prefilling both the starting and ending date fields with today’s date, I only have to enter one of those dates if I’m doing a since or til calculation. My new Keyboard Maestro macro, Days Between, uses the logic of between, but its interface is set up so I only have to enter one date if I want to use it like since or til, which are the commands I use most often. 1 between takes two date arguments and returns the number of days between them. til also takes one argument, a date in the future, and returns the number of days from today to that date. since takes one argument, a date in the past, and returns the number of days from that date to today. My three little date commands are since (previously named ago), til, and between. It got me thinking Why the fuck haven’t I turned this into a macro I can call from within any app? Apparently, I had a couple of fucks to give this morning.Īfter a little thought, I realized that a Keyboard Maestro macro with the right kind of user input prompt could incorporate all of my little date commands and would be faster and easier to use than any of them. When the fuck are you going to pay it? I used my ago script, which worked fine, except I needed to switch from Mail to Terminal to run it. This morning, I was composing a nice email to a client, and I needed to know how many days it had been since September 23 of last year: This invoice is 137 days old.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |