Today's Sunrise and Sunset Macro (v11.0.1)

This macro determines your geographic location using a web portal, then sends that information to another web portal to discover your local sunrise and sunset. It then displays that information.

This macro makes use of curl, Execute Shell Script, Search Variable using Regular Expression, a JSON variable, and the function GMTOFFSET().

Possible improvements:
(1) You could potentially use this data to "trigger" a macro to occur at sunrise or sunset, but that's another topic.
(2) You could potentially do the math to adjust the output using GMTOFFSET(). But I wasn't sure of the best way to do this.

Today's Sunrise and Sunset Macro (v11.0.1)

Today's Sunrise and Sunset.kmmacros (6.4 KB)

There's actually another different way to find sunrise and sunset that doesn't use web portals and doesn't use trigonometry. But that's for another day.

2 Likes

Now it can be done by taking advantage of the fact that in Tahoe macOS 26 you can use an automation that triggers at sunrise, and calls a KM macro.

However there's no guarantee what this automation will do if you live at the poles or beyond the polar circles, where there's often no sunset or sunrise. I think I'll try to contact someone who lives at the South Pole and ask them to test this automation. (I've done that before!)

You can also use Shortcuts to get sunrise/sunset times for your current location from the Weather app:

It does require Location Services and the appropriate Privacy & Security settings, so some may prefer your original macro.

2 Likes