Date Formats

KM gives long date and short date. What It comes to is I want this sort of date; “2015/01/22 6:53 PM" I do this for sorting purposes using Bean or other text documents.

Is there a way to customize the date format in KM? I am thinking I can research this on the web and figure It out with Applescript (not an expert AS user but if I can learn the base format I can turn It into what I want - usually).

Thanks

SOLVED: I used ICU Format and changed It around a little. Now I have this: %ICUDateTime%yyyy/MM/dd h:mm a%: which yields; 2015/07/27 11:39 AM:.

There may be – I’m not sure.


EDIT Mon, Jul 27, 2015 at 8:36 PM CT

KM can do custom dates easily.
See token/ICUDateTime


IGNORE the below unless you need it for AppleScript.

But you can create just about any custom date format you want using a shell script, which can be put in a KM Script Action.

Here’s the AppleScript version, but you can probably do it directly:

set strDate to do shell script "date '+%b %d, %Y'"
--> Jul 15, 2015 (for example)

For the complete list of date format codes, see:
HowTo Format Date For Display or Use In a Shell Script

Thanks. Just as a follow up question, not sure if It can be done outside of AppleScript or not, can I set the font using KM, on the clipboard text?

Yes. See the Apply Style to Clipboard action

Nice! Thanks.

One more question on this, I have It working but I don’t know if I am not seeing a way to put inserted text directly on the clipboard or not? Its a relatively painless work around as I have It now, Paste or insert the date string, simulate keystroke Option-shift-left arrow to select the just pasted date string, cut, now run styles on the clipboard and paste back to document.

Would be a little more elegant if I could just insert that date string to the clipboard and style It before pasting It. Possible? Not possible? Thanks.

Type the Return Keystroke
Type the Return Keystroke
Type the Up Arrow Keystroke
Type the Up Arrow Keystroke
Insert Styled Text ‘%ICUDateTime%yyyy/MM/dd h:mm a%:’ by Pasting
Type the ⇧⌘Left Arrow Keystroke
Type the ⌘X Keystroke
Apply Style to Clipboard (Color text + Bold)
Type the ⌘V Keystroke
Type the Tab Keystroke
Type the Tab Keystroke
Insert Text ‘a’ by Pasting
Type the ⇧Left Arrow Keystroke
Type the ⌘X Keystroke
Apply Style to Clipboard (Normal text)
Type the ⌘V Keystroke
Type the Delete Keystroke

OK, let’s start at the beginning. :smile:
Do you want to enter the date into a KM macro, or copy the date from a text selection you have made prior to invoking the KM macro?

My goal is to insert a current date in a notes field. I start with the cursor at the top left of the page. Hot Key moves the old text down and moves the cursor back top left. Then enters formatted date, blue, bold. Then tabs and sets non formatted text for start of note entry. All set to Verdana 14 pt.

The result looks like this (date is bold and blue, regular text is black and well, regular):

2015/04/27 6:27 PM: (There is a tab here that is not showing in this forum formatting) This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test.

So, no, I am not copying anything, I am starting fresh. I only copied as I thought that was how I got the format text on clipboard to work.

My example works perfectly but I am open to seeing how to do this differently.

If you want the current date, then you don't need to enter anything.
You don't need the date stuff I previously posted.

The KM token ICUDateTime should do the job.

This should get you started:

See token/ICUDateTime for details.

OK, simpler, thanks. After I do this, tab and then … It still has to be Verdana 14. I can apply to 19 characters instead of the whole string which stops the previous formatting. I will do this and use your example to insert one letter on the clipboard, format that, hit delete and that should do It. Yes?

What app are you using?

I would have separate macros to enter the date and to format other text.

Works perfectly, thanks. I used a single macro to enter the date and start typing notes. The point is to get a system that I can remember so I Start tracking things better that I should be tracking. One keystroke to start taking notes is better than two. :wink:

Type the Return Keystroke
Type the Return Keystroke
Type the Up Arrow Keystroke
Type the Up Arrow Keystroke
Set Clipboard to Styled Text ‘%ICUDateTime%yyyy/MM/dd h:mm a%:’
Apply Style to Clipboard (Blue, Bold, 13 pt. Verdana applied to 18 characters)
Pause for .2 Seconds
Type the ⌘V Keystroke
Type the Tab Keystroke
Type the Tab Keystroke
Set Clipboard to Styled Text ‘a’
Apply Style to Clipboard (Black, Regular, 14 pt. Verdana applied to string)
Pause for .2 Seconds
Type the ⌘V Keystroke
Type the Delete Keystroke

DevonThink Pro

PS - I use two macros for my spell checking. One copies what is highlighted, opens Bean, pastes. I can see errors and what I am writing better in that space. Then, a second macro selects all, quits without saving and pastes over the highlighted text where It came from.

Since you are setting the clipboard to styled text yourself, there is not need to follow it up with the Apply Style action - you can apply the styles in the action itself, and then since you're just pasting it, you can use the Insert styled text by Pasting action, like this:

Note that "HH" means 24 hours time (0-23), and "hh" is 12 hour (1-12) time. You can adjust the time format any way you like of course.

2 Likes

Interesting. Thanks.

Peter, that is awesome! :sunglasses:
I had no idea that you could select the text in this action, and format it using the standard Mac Font and Color tools.

So you replaced my four actions with one!

Thanks.

EDIT: AND, by adding some other text in a different font/style/color, further simplifies @levelbest's task.

1 Like

One action is better than four - but four actions that accomplish the goal are just fine too.

Simplified … Again. Always appreciate learning more. Thanks.

Another related question to this macro please? I have to start with the cursor in the upper left to use this. I am wondering if there is a way to set the insertion point in a text field, an xy parameter? I see that I can choose insert text instead of paste text from styled clipboard and It allows position. But It is not at all clear what that means. It gives me a pipe (%|%) and nothing else. How can I tell the macro to set the text to text position [0,0]? If I could do this I would drop the two up arrows at the start of the macro.

Fumbling about even further, I see that the pipe example places the cursor at the start of whatever line It started in. I need It to go to the upper left or position xy = 0,0 in the text area the cursor is in.

Since you are now well beyond the scope of your original post (Date Formats), may I suggest you start a new topic? It will be easier for you and others to track and focus on.

IAC, could you please post a screen shot of the typical page you are working with? This would help our understanding of your process immensely.

OK (5 characters needed to post)

I tried this and fired it in a Google Doc...and it worked great except that it DID NOT change the font color. Is there something about Google Docs that prevents the font color from changing through automation like this? Or more to the point, IS there a way to us KM to change font color?