by ajross · 1y ago · 0 comments
First off, no, locales and wide characters exist. This statement is just laughable.
But even as to time: that seems really unfair. This whole area is a footgun and has been the source of bad implementation after bad implementation, in basically every environment. But among those: The "struct tm" interface is notable for being:
1. Very early, arriving in C89 and the first drafts of POSIX, with working implementations back into the mid 80's.
2. Complete and correct, able to give correct calendar information for arbitrary named time zones in an extensible and maintainable way. LOTS of other attempts got stuff like this wrong.
3. Relatively easy to use, with a straightfoward struct and a linear epoch value, with conversion functions in each direction, and only a few footguns (the mix of 0- and 1-indexing was unfortunate). There are even a few quality of life additions like support for "short" month names, etc...
Really, these routines remain useful even today, especially since their use is guaranteed to integrate with your distro's time zone database which must be constantly updated to track legal changes.
There's stuff to complain about, but... no, I think the premise of the article is dead wrong.
I looked it up. In fact it's much earlier than that. The API arrived in time.h via v7 Unix in 1979.
And it remains, unchanged, pervasively used, and most importantly still used for new code, four and a half decades later. Rather than "legacy cruft", this constitutes one of the most successful utility APIs in human history.
my biggest issue is that the structs and function definitions are pretty opaquely named and make it very hard to learn let alone teach newcomers.
My real question is how you created an account, found this article, presumably read through it, and wrote out multiple comments insulting me all within two minutes.