What is the origin of the asctime format?

  • A+

Why was the particular character representation that the asctime function returns, i.e. Www Mmm dd hh:mm:ss yyyy/n, chosen and what is its origin? The ordering of the information seems peculiar to me, especially putting the time information in between the date information. Is this (or was this) a common datetime representation in the US?


This come directly from C. Probably the year was added later. Also the /n is strange. Probably a convenience function when building UNIX, and it got standardized by use.

Note: the function is "obsolete", and possibly it will be removed in later version of C. It is replaced by more powerful strftime().

POSIX has no rationale about the choice.

ESR wrote:

In older Unixes the following functions were available to report time and date as a string. They wired in bad design choices (the date string is of unpredictable length and includes a trailing "/n"), are not locale-aware, and have undefined behavior for years before 0 or after 9999.

We have also few information from 7th edition of the manual (1979) see manual pages.

Somebody (Clive D.W. Feather) looked for the same information as you (but directly to C standard group), but I do not find the answer. Just that C99 were corrected because some imprecision email on the same thread.

I think it will be difficult to get more information.


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: