IEEE 1003.1 P.55

Moderator, John Quarterman std-unix at ut-sally.UUCP
Wed Oct 1 02:11:06 AEST 1986


From: seismo!elsie!ado (Arthur Olson)
Date: Mon, 29 Sep 86 22:46:41 EDT

A few words regarding the "P.55" time zone proposal.

One thing it lacks is a way of determining the "time zone abbreviation"
("EST" or "EDT" or "EWT", for example) to be used with a particular combination
of time and time zone.  One approach is to declare a global variable such as
	char *	tz_abbr;
and have "localtime" set it to point to the abbreviation for the converted time.
Alternately, some folks have suggested adding either a character pointer or a
character array to the "struct tm" that "localtime" returns as a way of
recording the abbreviation.  The approach used isn't too important;
standardizing the approach is.  (Avoiding changes to the "struct tm" structure
would be desirable if there are applications that have stored such structures
in files.  I don't know of--and can't imagine--applications that do so.)

If the standard *does* end up telling how a caller of localtime can learn the
abbreviation for the converted time, then a change may be needed in the
passage reading

> When called with a null string (p!=0 && *p=='\0'), settz
> shall select no conversion for localtime, making localtime()
> and gmtime() equivalent and ctime() and asctime(gmtime())
> equivalent.

If, for example, "localtime" sets "tz_abbr" as a side effect, but "gmtime"
doesn't, then calling "localtime" and calling "gmtime" can never be equivalent.

It may be simplest to just leave the settz("") case out of the standard
entirely--any application programmer who's interested in getting GMT can
just call gmtime() directly.  (The settz("") case is actually a bone to throw
to speedsters who don't want "ls" to get time conversion information from
disk; while this has some value, the value may well be too small to warrant
standardization.)  But having settz((char *) 0) set things for local time
(regardless, for example, of the state of the environment variable "TZ")
provides a capability that's important to programs such as uucp;
the behavior of settz((char *) 0) *should*, I believe, be documented.

Concretely:  I'd suggest this shortening of section 4.5.3.2:
	4.5.3.2	Description
	The settz() function determines the conversion from GMT
	of the local times returned by localtime() and ctime().
	When called with a null pointer argument (p==0), settz
	shall select the appropriate local time conversion for the
	location of the host machine on which the call is executed.
	When called with a non-null pointer argument (p!=0),
	settz may set the conversion according to that string...

And, perhaps, an addition along these lines to 4.5.4.3 (or wherever):
	As a side effect, both ctime and localtime set the global character
	pointer tz_abbr to point to the time zone abbreviation for the
	converted time and time zone.
--
	UUCP: ..decvax!seismo!elsie!ado   ARPA: elsie!ado at seismo.ARPA
	DEC, VAX, Elsie & Ado are Digital, Borden & Ampex trademarks.

Volume-Number: Volume 7, Number 10



More information about the Mod.std.unix mailing list