K
Keith Thompson
You persist in misunderstanding -- that is *not* "the code of the
asctime() function", it is an illustration of the algorithm to be used
by the asctime() function. Yes, it happens to look a lot like C code
since that was the simplest way to describe the algorithm, but no where
is there even a hint that implementations should use that code verbatim.
Yes, but implementations are certainly allowed to use that code
verbatim, and one could argue that there's not much reason not to do
so.
Because asctime() is defined by an algorithm expressed in C, its
behavior is defined by that C code. In particular, its behavior is
well defined in some very odd (and not very useful) cases, and
undefined in some cases that could have been caught as errors. Those
cases can be determined unambiguously by examining the code, but
they're not stated at all clearly.
In my opinion, asctime() is irredeemably ugly; perhaps deprecating it
in favor of strftime() would be better than trying to "fix" it.
[...]