Date from Typed String Macro (v9.0.4)

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)


Just updated the macro with a new % precede option for abbreviated dates (preserving short month names):

  • %2/14 will expand to Feb. 14
  • %12/25 will expand to Dec. 25

Oops, updated the regexp to avoid triggering the macro when you type a number like 3,500.

Fixed paste action for abbreviated month names.

Thanks for the work on this, but I think you only uploaded the Comment action rather than the updated macro

Fixed! Thanks for catching that (it bites me all the time).

I thought there must be a better user interface than trying to remember (or look up) specific triggers for various date formats.

So I added the grave accent (`) trigger to produce a pick list of all the formats. Nothing to remember but that. And you don't have to leave the keyboard either, just arrow down and hit Return when your preferred format is selected.

(I tested this with a macro that only has the grave accent option. If anyone is interested, I'll upload that as an alternative.)

1 Like