%ICUDateTime% format from local

How to replace the second statement Execute AppleScript by pure KM statements?


I try to automate choice of date format from local setting :wink:
Thanks for any hints.
--Alain

Alain, from the Dates and Times [Keyboard Maestro Wiki], I believe the format you want is: %ICUDateTime%dd/MM/yy%

See ICU Date/Time codes for full list of codes.

Sorry perhaps not to be clear enough…

I wish to set variable fmt depending of locale and process token %ICUDateTime%fmt% (with the chosen format).

This should work:

See:
ShortDate (token)
LongDate (token)

1 Like

You can do the same thing natively in Keyboard Maestro by using the Filter Variable action to process the text tokens a second time. Note that you have to carefully double the percentage signs (%) so that only the variable is expanded in the first case.

Keyboard Maestro Actions.kmactions (1.2 KB)

2 Likes

Thank you JMichaelTX pointing out these amazing local tokens.

Your answer leads me to another local token %NumberDate% which is the beginning of a solution (@peternlewis gives me a more generic and complementary one below) :

--Alain

1 Like

Thank you Peter for your generic answer I exactly look for :smiley:

I have already give a try to the Filter Variable action "Process Tokens", but unfortunately use only %% in place of %%% in the specific places: use of %%% is now self evident...

--Alain

Its actually never "%%%" per se.

You have to think through the process Keyboard Maestro will use. You double (%%) the percents you want to save. So for example the sequence of processing the string twice in a row goes from this:

%%ICUDateTime%%%Variable%fmt%%%
%ICUDateTime%dd/MM/yy%
19/04/16

If we code each percent as ①②③④⑤⑥ the doubling can be seen more clearly (I'd use colors, but Discourse does not support colors sensibly).

①①ICUDateTime②②③Variable④fmt⑤⑥⑥
â‘ ICUDateTimeâ‘¡dd/MM/yyâ‘¥
19/04/16

So you can see the percentage characters in the second process need to be doubled initially so they are preserved. That would be the ones labeled â‘ , â‘¡ and â‘¥.

And initially within the format section, you have the variable expansion "%Variable%fmt%".

1 Like

Welcome complementary explanation.

My (very recent) own cooking (guidance) about this such token is to consider # of processing levels which is 2 in the present case + 1 "%" for text field setting...

Fortunately important help (feedback) come from KM Action live result display I call for heavily :wink: