Customize year placeholder from YYYY to YY

I am looking for a solution to either change the current year placeholder from YYYY to YY or use some alternative to get only the short version of the year.

Some background: I use a custom id of the format YYMMDD in markdown files in the yaml header and for other files at the start of the filename. The reason for the custom id is that I am linking files outside of my DEVONthink databases. It is my simplified version of Hook.

Shortening from YYYY to YY reduces all the unused first two Y’s and makes it easier to remember the id (getting older). I know this will cause a problem when the year changes from 2099 to 2100, but by then, I won’t be around to be troubled by this issue

I would be grateful for any help.

Thanks.

What „template“ are you referring to?

I am referring to the markdown template for the DEVONthink annotations. Please see the screenshots.

I’m not at my Mac for some time. Did you check the user manual if it says something about the placeholders in templates?

There is no YY placeholder at this time.

Depending on your workflow, there are a couple of potential solutions. Do you use a text expander tool? The simplest solution could be to configure a snippet there. I use aText, which easily lets me get that format:

If you rely on placeholders for templates… Look in the manual under Appendix > Placeholders > Date Placeholders :

[…] some formats will resolved relative to your geographic location, e.g., Jan 1, 2000 for the medium date would be common in the US.

  • 01/01/2000: The short date format. %shortDate%
  • Jan 1, 2000: The medium date format. %date%.
  • Saturday, Jan 1, 2000: The long date format. %longDate%

These rely on global macOS date formats. Before macOS 13 Ventura they were easy to customize in System Settings through a nice GUI:

For some reason Apple removed this when they redesigned System Settings! A clear downgrade. I was pretty annoyed. Your question prompted me to dig a little.

Apparently they’re still accessible through the Terminal with the defaults command. You could customize one of them into your preferred format and use the corresponding placeholder in your templates. But these are global, system-wide settings, so think for a second about what you’re doing – and if it clashes with how you want dates to display anywhere else. This affects the Finder, Calendar etc.

The full command is:

defaults write NSGlobalDomain AppleICUDateFormatStrings -dict-add "Key" "Format"
Key
Short 1
Medium 2
Long 3
Full 4

The way to write your desired format should be yyMMdd.

Actually, can this default be written to a more specific domain? (like com.devon-technologies.think3?) Hopefully someone more knowledgable can answer that.

Some caution (from the Reddit link below):

Note that as of macOS 13.2, two new things have happened:

Firstly, Apple seems to have added a few more formatting options to the Language & Region page in System Settings.

But, secondly, this settings page now becomes completely inaccessible if you change the settings yourself to any combination that’s not explicitly supported. Clicking on it just does… nothing.

– I haven’t tested it myself, so I don’t know if that has changed.

Links:

You can create a smart template and use your own custom placeholders. Here is a simple example that uses a two digit year and follows the YAML format you mentioned. (You didn’t make it clear what the Annotation file’s name would be, so I used our naming convention.)

Download and unzip the attached ZIP file containing a DEVONthink smart template.
2. Double-click the .templatescriptd file to install it in DEVONthink.
3. Select a document without an Annotation file.
4. Choose Data > New from Template > Custom Annotation — Markdown. This yields a Markdown document in the same group and attaches itself to the selected document as an Annotation file. If an Annotation file already exists, a warning is logged in the Log window or popover.

Custom Annotation — Markdown.templatescriptd.zip (7.8 KB)

You can Control-click .templatescriptd file in the Finder and choose Show Package Contents. In the Contents > Resources you will find the payload containing the Markdown template and the script. Both are editable, as you see fit.

2 Likes

Thanks @troejgaard and @BLUEFROG for your help.

I am using Alfred functionality for date textexpanders. Which is great but doesn’t work for the placeholder in DEVONthink.

Jim’s solution is exactly what I was looking for. Thanks.

1 Like

You’re very welcome :slight_smile: