Path: utzoo!utgpu!watmath!clyde!mcdchg!chinet!att!osu-cis!tut.cis.ohio-state.edu!ukma!husc6!cmcl2!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: struct tm -> time_t converter wanted Keywords: C library, time Message-ID: <8797@smoke.BRL.MIL> Date: 29 Oct 88 21:32:23 GMT References: <442@grand.UUCP> <8700@smoke.BRL.MIL> <6964@cdis-1.uucp> <8716@smoke.BRL.MIL> <12418@steinmetz.ge.com> <8754@smoke.BRL.MIL> <13422@cisunx.UUCP> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 32 In article <13422@cisunx.UUCP> cmf@unix.cis.pittsburgh.edu (Carl M. Fongheiser) writes: >In article <8754@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) writes: >>In article <12418@steinmetz.ge.com> davidsen@crdos1.UUCP (bill davidsen) writes: >>>changing the epoch or going to 64 bits would break existing programs. >>Neither will break existing correct programs that don't assume things >>not promised by the specifications. >Excuse me? The last time I checked, the man page for time(3) (time(2) >in the V7 man pages) clearly stated that the return value was the number >of seconds since 00:00:00 GMT, January 1 1970. Not having an SVID handy >(or a POSIX spec, for that matter), I can't say anything authoritative >about them. But if I write a program that knows about that epoch, I'm >violating the rules? For C (without additional requirements imposed by SVID, POSIX, etc.), time_t is just an arithmetic type with the time somehow encoded in it. It is not guaranteed to use the same encoding from one program execution to the next, so it permits moving the Epoch when necessary. There is a macro CLK_TCK for converting between seconds of duration and the difference of two values returned by clock(), but the origin is not specified (it may, for example, be the beginning of program execution). Since this discussion is occurring in the C newsgroup, not the UNIX one, you are definitely outside the scope of the specs for the meaning of time_t if you assume that it means "seconds since the beginning of 1970 AD at Greenwich". IEEE 1003.1-1988 (POSIX) imposes that additional requirement, but they also don't require that time conversion from time_t to/from struct tm be done accurately. In fact POSIX requires that it be done inaccurately whenever a leap second is involved! As far as ANSI C is concerned, that inaccuracy might be considered a (poor) "quality of implementation" issue. Certainly converting future times to/from whatever Congress mandates cannot guarantee accuracy.