I’ve updated the natural language date Service again, adding a few things that I’d personally been wishing for.
This is an OS X System Service that lets you select a string of text in a “natural language” format and convert it in place to a full date in various formats. That part is the same as it was in the beginning, so you can reference the original post for basic usage.
In a nutshell, a string like “short next tuesday at 5pm” will give you “Tue, Jun 4th, 2013 5:00 PM.” It keeps you from having to look at the calendar and saves you typing time by turning loosely-formatted strings into nice-looking dates.
- Ordinal days
- The “long” and “short” date formats now have ordinal day numbers, so “June 13” comes out as “June 13th.” “July 21” is “July 21st,” and so on. This only applies to formats that have the month name (not a number) in them. If you’re customizing a date string, use “%%o” to insert the ordinal version of the day number.
- ISO 8601 format
- There’s a new format called “iso.” It’s the ISO 8601 (Gregorian Big-endian, if you want to be like that) format that’s used in most file-naming systems and in blogging platforms like Jekyll: year, month, day (24-hour, minutes). Typing
iso tomorrow 8amwill give you a date like
- Smarter zero padding
- Zero-padding (in this case) is the prefixed “0” on single-digit numbers. Previously you had to go all or nothing with removing zero-padding. Now it can be a little smarter, with certain formats excluded from the process. If you’re customizing, you can use
%0Ito force a zero in 12-hour time.
- Meridiem casing
- If there’s no space between time and meridiem in the format string, it will automatically make the “am” or “pm” lower case. This is just a personal preference on my part, but I think it makes sense.
- Improved syntax handling
- The Service now handles an array of additional date formats and is smarter about handling time strings. See the next section for examples.
To control the format, you can make the first word of the string any of the following (I used “‘prefix’ tomorrow 5pm” for these examples):
'date' => slashed: 06/02/13 5:00 PM 'local' => localized: 2013-06-02 5:00 PM 'short' => abbreviated full date: Sun, Jun 2nd, 2013 5:00 PM 'long' => long full date: Sunday, June 2nd, 2013 at 5:00pm 'iso' => ISO 8601 date: 2013-06-02 17:00
long tue gives me “Tuesday, June 4th, 2013” (that’s the next Tuesday after the day of this writing) at the press of a hotkey. If you don’t add a time to the end of the string, it will omit that part from the output (e.g. “short friday” creates “Fri, Jun 7th, 2013”).
You can now include “at” or “@” when specifying a time string. It’s optional, but I find that when I want to type in “natural language” I do it somewhat automatically. It handles a variety of formats:
at 8am @ 13:30 tomorrow@3p fri@5p tue @ 5pm
+# operator can still be used to increment “#” days from the current day. It can be combined with the above syntax to make really short snippets:
+5@10 +7 10am
AM and PM can be specified with just the first letter, so
10a becomes “2013-06-01 10:00 AM.” Notice that without a day in the string, the date is set to the current day.
You can also specify times in 24-hour format, and it will convert that to 12-hour time with merideim if the chosen output format calls for it.
short tomorrow 14:40 gives me “Sun, Jun 2nd, 2013 2:40 PM.”
Convert Date - Natural Language Date Service v1.3
Make A Date 2 for TextExpander
I’ve also made a new “Make A Date” snippet for TextExpander based on this Service. In addition to all the new syntax, it adds a pop-up menu in the fill-in to select a date format. You can just type your string in the first box, then hit tab and use arrows or type the first letter of the format you want, then hit enter.
Rather than overwrite the current
,,mad snippet, I’m putting it in its own group for the time being. It will eventually supersede the one in the Tools collection, but is currently housed in “Other Tools”. You can subscribe to it on that page to get updates, or download the
.textexpander file to install it yourself and be able to edit the script and shortcuts.
See the snippet in the TE-Snippets tool.