Date from Typed String Macro (v9.0.4)
This extendable macro, inspired by a recent Gabe Glick solution, can reformat a shorthand date notation in a variety of ways determined by the leading delimiter.
Start the sequence with a grave accent, comma, semi-colon, exclamation point or equals sign, type the month in one or two digits, then the delimiter of your choice followed by either a two-digit day or a single-digit day followed by a space.
A grave accent will present a pick list of nine various formats for the date you typed. To select one, arrow down to it and press Return.
Alternately, you can force the format with the trigger. A few examples:
,2/14 will expand to February 14, 2020
;2/1[space] will expand to 1 February 2020
=2/14 will expand to 2020/02/14
=2-1[space] will expand to 2020-02-01
=2.14 will expand to 2020.02.14
!2.14 will expand to 02.14. 2020
%7/4 will expand to July 4 but %12/25 will expand to Dec. 25
?2/14 will display a Help box for these triggers
Instead of typing a date in numerals, you can use the "td" shortcut to represent today's date. The delimiter for ! is a hyphen but for = it's a period. Here's some examples assuming today is Valentine's Day:
,td will expand to February 14, 2020
!td will expand to 02-13-2020
=td will expand to 2020.02.13
Audio feedback confirms any substitution.
NB: The Switch action can be expanded to include more options, which must also be added to the Trigger Value's first group.
Feb. 17 Update (v1.2a): Added % trigger for abbreviated month names (Feb. 14 and July 4) where appropriate.
Feb. 18 Update (v1.2b): Refined the regex to avoid triggering the macro when typing numbers over 999 (eg: 1,500).
Feb. 19 Update (v1.2c): Fixed paste action for abbreviated month names.
Feb. 24 Update (v2.0a): Added a pick list of date formats when the trigger is the grave accent (`). No need to remember special triggers.
Date from Typed String.kmmacros (33 KB)