Tagging @peternlewis for what may be a bug in the %ICUDateTimeFor% token’s calculation.
Peter, when calculating the date/time for January 1, 2024 minus 86400 seconds (the equivalent of one day), the result is December 31, 2024. Likely, there is something fundamental I am simply not understanding about this, but it’s had me scratching my head for nearly an hour. Is this perhaps a bug? Should the result not be December 31, 2023? Or is there something wrong with my action(s)?
Attached is a simple macro demonstrating my issue. Any help is appreciated!
So presumably this is either a system bug with selecting the date or some sort of date formatting bug in the time zone.
Coming on the heals of this topic:
It does make me wonder if there are some bugs in Apple’s date formatting or calculation code (or potentially Keyboard Maestro’s code, but I don't immediately see how.
But this is very similar one day (technically 86400 seconds) change to the time resulting in incorrect dates.
@rolian Interesting! At the very least this proves I’m not completely insane and imagining things. Also, I’m just down the road from you near Cleveland.
@peternlewis Thanks for the link. I’ve been somewhat absent from the forum the last month or two and had not seen that post. I’ll look through it.
@ComplexPoint Interesting theory, perhaps if more people chime in and can test, we can see if that might be the case.
And the bug does not seem to occur whatever timezone, east or west of GMT, I set my computers Date & Time settings to. But maybe this timezone setting is operating on some kind of superficial display level, and this bug, whatever it is, is happening at a deeper level?
The ICU documentation on Formatting Dates and Times shows year formats as lowercase. And indeed, changing your YYYY to yyyy also returns the correct result.
This is fascinating, thanks for sharing that! Since the Dates and Times wiki entry doesn’t specify any difference between yyyy and YYYY, perhaps @peternlewis can shed light on the issue here.
FWIW, the following screenshot shows the different results using various tokens and formats. The lowercase yyyy returns the correct year, whereas the uppercase YYYY does not.
Variable Inspector Screenshot (click to expand/collapse)
As an aside, I marked @mrpasini’s comment as the solution, since it solved the issue with my macro. Still interested in hearing more about the difference between yyyy and YYYY for anybody who is more knowledgeable on the subject.
UPDATE: From a Google search, it appears that yyyy corresponds to the calendar year, and YYYY corresponds to the year of the week.
Peter, thanks so much for the info and pointing out that warning on the wiki page. I missed that completely.
Oddly enough, I’ve been using KM for about 6 years now, always using Y, and this is the first time I’ve had any problems. It just goes to show I should never be overconfident about my abilities, or in this case, lack thereof.