Stamp: Open date in Calendar.app

This code opens Calendar.app to the day of an date-type attribute.

You may need to change the locale to your locale.

// Open date in Calendar.app //

locale("de_DE");
var theDate=$MyDate.format("W, d MM y");
var theAppleScript='tell application "Calendar" to view calendar at date "'+theDate+'"';
var theShellCommand="osascript -e '"+theAppleScript+"'";
runCommand(theShellCommand);

(Not sure whether the format dot operator needs to be adjusted. I guess AppleScript uses the same format in every language. If you need to change it see @mwra’s Date Formats)

2 Likes

You’re probably better off using the local date format .format("l"). Your solution will work on US systems, but might fail on a system using German or Chinese.

Testing this

var theDate=$MyDate.format("l");
$Text=theDate;

I get 1/24/23.

But AppleScript expects a date in the macOS’s locale (i.e. the primary locale set in System Preferences), in my case Mittwoch, 25. Januar 2023.

(While writing the code I already wondered why Tinderbox doesn’t use my macOS’s locale (de_DE) by default. Didn’t ask because I found the locale() operator.)

format('l') gives the locale’s short format. For the longer format, use .format("L")

Tinderbox does use the system locale, though it’s easy enough to set with locale().

1/24/23 is not the german short format:

Tinderbox seems to use the US locale on my system although german is the primary language