Richard said:
In Third Edition Unix, it didn't have a linefeed. Nor did it include
the day of the week or the year. The BUGS section of the manual page
says:
The routine must be reassembled for leap year.
Dec 31 is followed by Dec 32 and so on.
I'm not sure how this was supposed to work, since the manual page is
dated 1973, and time() returned seconds since Jan 1 1972. time()'s
BUGS section says:
The time is stored in 32 bits. This guarantees a
crisis every 2.26 years.
I wonder what that means? Seems to me that we have 4,294,967,295
seconds since Jan 1, 1970 to play with (according to POSIX, anyway) and
the C runtime just accepts what it gets from the hosted environment in
terms of seconds since epoch.
Of course, UTC did not exist in its present form until 1972, so values
below 63072000 are not precisely defined.
Still have no idea why the line-feed is added on text representations of
time constructed by ctime() and friends, but my guess is that it was a
convenience for the most common (in English) representation of the
current time.
That is, one should be able to construct any locale-specific string with
or without any trailing whitespace you like using strftime(), while
asctime() and ctime() were kept as reasonable defaults for typical usage.
Just guessing, though.