[comp.lang.c] ANSI standard for difftime

scott@tdpvax.UUCP (07/01/89)

I have a copy of _The Waite Group's Essential Guide to ANSI C_ and it has
difftime() defined as the __elapsed__ time between to time_t values.  It 
declaration is.

double difftime(time_t time2, time_t time1);

and it returns time2 - time1.


My question is can this value be negative?  Since elapsed time is normally
a positive value.  What should difftime do if time1 is greater than time2.  I
tried this under a VMS compiler and it returned a negative value.  So
what is the _OFFICIAL_ ANSI standard say.  Since the arguments for and
against have already been made please don't make them here.  If you have
access to the PANS draft or KNOW the answer please reply.    Thanx.


								Scott King
								trsvax!tdpvax!scott
								trsvax!tdpvax!scott@uxc.cso.uiuc.edu

So when do we get to see Rocky take on the Karate kid.  Or Jason take on Jaws?

gwyn@smoke.BRL.MIL (Doug Gwyn) (07/06/89)

In article <4400002@tdpvax> scott@tdpvax.UUCP writes:
>double difftime(time_t time2, time_t time1);
>and it returns time2 - time1.
>My question is can this value be negative?  Since elapsed time is normally
>a positive value.

The proposed Standard does not talk about "elapsed time".  difftime()
computes the difference between two calendar times.  Obviously the
difference can be negative.