asctime.c

Guy Harris guy at alum.mit.edu
Thu Jul 29 21:56:56 UTC 2004


On Jul 29, 2004, at 11:18 AM, Clive D.W. Feather wrote:

> 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?

If the FreeBSD man page repository is to be believed:

	http://www.freebsd.org/cgi/man.cgi? 
query=ctime&manpath=Unix+Seventh+Edition&format=html

then it said:

	   Ctime converts a time pointed to by clock such as returned  by   
time(2)
        into  ASCII  and returns a pointer to a 26-character string in  
the fol-
        lowing form.  All the fields have constant width.

            Sun Sep 16 01:03:52 1973\n\0

        Localtime and gmtime return pointers to structures containing  
the  bro-
        ken-down  time.  Localtime corrects for the time zone and  
possible day-
        light savings time; gmtime converts directly to GMT, which is  
the  time
        UNIX  uses.  Asctime converts a broken-down time to ASCII and  
returns a
        pointer to a 26-character string.

However, that man page has a large chunk of a BSD include file in it,  
which leads one to suspect that the man page might not be the one from  
V7.

However, if we go to the V7 archives at Bell Labs:

	http://plan9.bell-labs.com/7thEdMan/index.html

and get the section 3 bundle and extract it, we get a "ctime.3" that has

	The structure declaration from the include file is:
	.RS
	.PP
	.nf
	.so /usr/include/time.h
	.fi
	.RE

which suggests that the BSD man page might really *be* the V7 one, as  
the V7 one produces different results on different OSes as it includes  
the OS's "time.h".

In any case, it says the same thing as the one from the FreeBSD site in  
the paragraphs I cited above.

It doesn't *explicitly* say that the 26-character string returned by  
"asctime()" has the same format as the one returned by "ctime()",  
although I think they intended to imply that - at least for a "struct  
tm" generated from a "time()" value.  They probably didn't even think  
about what would or should happen if you handed it a "struct tm" with  
values that couldn't come from a "time()" value.




More information about the tz mailing list