asctime.c
Paul Eggert
eggert at CS.UCLA.EDU
Thu Jul 29 23:12:35 UTC 2004
"Clive D.W. Feather" <clive at demon.net> writes:
> Robert Elz said:
>> The original asctime() specified exactly what the out buffer would
>> contain.
>
> Did it? How? That is, what did old manual pages actually say?
The Unix Version 7 manuals say that the output of ctime and asctime
contain exactly 26 characters (including the trailing newline and
null), and that all fields have constant width. When a
currently-conforming C implementation prints a year like 999 as "999",
without a leading space or blank, it does not conform to the original
specification.
I should mention again that the V7 implementation was buggy, in that
years before 1900 and after 2099 were not rendered correctly.
However, even with the bugs, the output was always exactly 26 bytes
long and included a trailing newline and null, so that part of the V7
specification was adhered to and applications can and did rely on this
property.
> I'm not convinced that there has actually been a change.
Well, here's a quote from the horse's mouth
<http://cm.bell-labs.com/7thEdMan/vol1/man3.bun>
(in the ctime.3 man page section, in in troff input form).
It's quite clear that the output is fixed-width.
.I Ctime
converts a time pointed to by
.I clock
such as returned by
.IR time (2)
into ASCII
and returns a pointer to a
26-character string
in the following form.
All the fields have constant width.
.PP
Sun Sep 16 01:03:52 1973\\n\\0
...
.I Asctime
converts a broken-down time to ASCII and returns a pointer
to a 26-character string.
More information about the tz
mailing list