Date Events, a scriptable application which adds the missing «choose date» API

Like System Events there is no UI in Date Events (except the temporary date panel).
It quits automatically after 5 minutes of inactivity.

To choose a date is pretty simple

set theDate to choose date

which shows a graphical interface with date and time.

You can set the style to textual and textual with stepper and there are
a few options for the date and time appearance.

Additionally there are some APIs to convert date to string and vice versa for
custom string format/template and locale, and also some calendar APIs to
get the start of the day or to check if a date is in yesterday, today or tomorrow.

You can add multiple calendars for example the iso8601 calendar and other international calendar types.

See the sample script in the zip archive – or have a look at the dictionary – for the available APIs.

System Requirements:

macOS 10.15 (and higher) Intel or Apple Silicon.
The app is written in Swift – the panel is presented by SwiftUI – it’s sandboxed and notarized.

Critics and suggestions are welcome.

Date Events.zip

3 Likes

I cant seem to find a way to set the default date of the picker.

Also the ‘sdef’ says you cal the picker “picker”
but in actuality you call it “date picker”

Also it would be nice if the date picker had a cancel button.

My bad, now you can set the default date in the date property of the date picker.

Download: DateEvents1.3

picker is the internal class name. The date picker is the instance of the picker.

What is the cancel button supposed to do? Returning false like in choose file?

Yes, that would be preferred. Thanks

Here we go, it took some time to remember how to return two different types :wink::

DateEvents1.4

Damn, your quick.

Thanks!

BTW, what is the command to set the default date?
Its’ not in the sample script

I mentioned it in post #3: Set the date property of date picker.

Also, I can’t seem to open the latest. I get an error, ‘The application “Date Events” can’t be opened’ when I double click it

Or when I run the sample script I get “An error of type -10810 has occurred”

Please delete all old versions of Date Events.
And look also into Activity Monitor.app to quit possibly running instances.

Nope. Could it be that I have to remove some security settings and then re-add it?

No, it’s a straightforward application like System Events

Is it signed/noterized?

Of course, both code-signed and notarized.

Try to do a restart.

Fixed it. I change the owner of it to an Admin account

still need to know how to set the default date?

tell application "Date Events"
	set macIntroductionDate to date "24/1/1984"
	set date of date picker to macIntroductionDate
	set macDate to choose date
end tell

I figured it out. But there is a bug.
If I do this it works…

set mydate to (current date) + 4 * days
tell application "Date Events"
	set quit delay to 120
	tell date picker
		set style to graphical -- textual ot textual with stepper
		set time elements to hour minute second
		set date elements to year month day -- not available in graphical style
	end tell
	set date of date picker to mydate
	set theDate to choose date
end tell

but if I put the set date command inside the tell block like so…

set mydate to (current date) + 4 * days
tell application "Date Events"
	set quit delay to 120
	tell date picker
		set style to graphical -- textual ot textual with stepper
		set time elements to hour minute second
		set date elements to year month day -- not available in graphical style
		set date  to mydate
	end tell
	set theDate to choose date
end tell

it won’t compile, it errors on the set date line.

set its date to mydate

The property date is used in many environments.