That was a good catch [@Dave Middleton][at0] (and yes, I did cheat a bit with the embedded DateObject expressions in the post, mostly to make the examples simpler to read). The issue at play is the handling of what an object with TimeZone -> None
both represents, and how it's handled under the hood.
In a function like Sunrise
or Sunset
the standard behavior is to give the next sunrise/sunset, based on the reference date provided (or implied as Now
if one isn't given) at the desired location, as opposed to giving the closest sunrise. When these functions are given an input date, they need to resolve the time zone before figuring out what the starting point will be, and in the case of an input like Today
or DateObject[{2025,6,21}]
the associated time zone is None
:
In[31]:= DateValue[Today, "TimeZone"]
Out[31]= None
What does TimeZone -> None
mean? It ultimately means that a time zone wasn't specified (generally because it's not known, or not necessary for the granularity at which the date is being measured) but for some functions (such as Sunrise
and Sunset
) we need to have a precise moment as which to reference against for determining the next sunrise, and in such cases the Wolfram Language will fall back to the system's current $TimeZone
if no other information is provided, which in this case means "find the next sunrise for Glasgow after Midnight on June 21st, my local time" which introduces an issue if the sun has already risen by that time in Glasgow (which it does for part of the year), and thus the oddity in the first plot you noticed.
There are a couple of things that could be done instead (such as trying to automatically pick out the reference location's time zone, as you've done manually above), but that would introduce behavior that's a bit unique to these functions versus the rest of the Wolfram Language. We do occasionally decide that it's worth having special behavior in cases where the default behavior is counter-intuitive, and I'll bring this point up at the next development group meeting about dates & astro to see what the participants think.