Date: Mon, 15 Nov 1999 18:01:49 +0100 From: Hans-Bernhard Broeker Message-Id: <199911151701.SAA24259@acp3bf.physik.rwth-aachen.de> To: co273 AT freenet DOT buffalo DOT edu (Kev) Cc: djgpp AT delorie DOT com Subject: Re: time() frequency Newsgroups: comp.os.msdos.djgpp Organization: RWTH Aachen, III. physikalisches Institut B X-Newsreader: TIN [version 1.2 PL2] Reply-To: djgpp AT delorie DOT com In article you wrote: > I have a question concerning the DJGPP time() function. Actually, though you don't know it, your question is not really about the DJGPP time() function. time() is an ANSI standard function, and thus its behaviour is defined elsewhere, already. DJGPP just implements that 'god-given' behaviour. > Can you tell me the frequency in which time() returns the time... I could, but that'd be pointless. The answer is that whatever the unit might be, it's none of your business. time() returns a value of type time_t. Which, in turn, is defined as 'arithmetic type capable of representing times' (that's the very word of the ANSI/ISO C language description, on this). And that's all you *really* need to know about time() itself, already. time_t is a 'no user-serviceable parts inside' thingy. The only welldefined applications of the value returned by time() are: 1) storing it in a variable of type time_t 2) passing it to functions taking a time_t argument, like some of those declared in the Standard Header. difftime(), ctime() or gmtime(), e.g. 3) casting it to another numeric type (explicitly or implicitly). In case 3), however, you may *not* make any assumptions about what number might come out of it. It's effectively random. > Is it 1 second increments? I'm trying to settle an argument with a > co-worker, who argued that it is in Microsecond increments. In principle, it could be either of those, or any arbitrary other thing. ... Well, curiosity will kill you otherwise, probably, so I'll tell you nevertheless: DJGPP follows Unix (POSIX) conventions and counts time_t as an integer number of seconds since 1970. But *don't* you dare rely on that! Next release, we could decide to change to 1e-10 of a month, instead, and that only if pure ANSI (non-POSIX) mode, be it just for the perverse fun of confusing lots of incorrect programs ;-> -- Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de) Even if all the snow were burnt, ashes would remain.