Yesterday was time change in the U. S. of A. I pulled out my iPod Touch to update a Numbers spreadsheet, and hit the "today" button to put the current date in the date column. But when I did that I got not the current date but 11 PM the previous day. Today it works as advertised.

Now, I am not privy to the internals here, but this behavior would be explained if "today" were implemented by the Objective C (or Swift, or whatever) equivalent of the following Perl:

my $date = time + $zone_offset; $date -= $date % 86400;

This code is clean, simple, obvious ... and subtly wrong because on time change day, after the change, midnight has a different offset than the current time. This is a bug that manifests only 44 hours in every year. I think that when I want the local day I round-trip through localtime and Time::Local::timelocal. But do I really? Always? And would the above snippet be valid for UTC?