Mail Archives: djgpp/1997/11/24/18:09:08
Quote from the ANSI C Standard *):
7.12.2.2 The difftime function
Synopsis
#include <time.h>
double difftime(time_t time1, time_t time0);
Description
The difftime function computes the difference between two calendar times time1 -
time0.
Returns
The difftime function returns the difference expressed in seconds as a double.
End quote.
From the above quote I would assume that there is no restriction on time0 and time1,
especially the standard doesn't assume that time1 > time0.
Why does difftime() from the DJGPP library produce erronous results if time0 > time1 ??????
difftime() should return a negative result, but actually it returns
(double)(UINT_MAX - d)
where d is the absolute value of the difference of time0 and time1.
E.g. you get a positive difference of about 128 years if you set time1 to 1990 and time0 to 1997.
*) ISO/IEC 9899:1990 p.171
**************************************************************
Dipl.-Ing. Anton HELM *T* mailto:tony AT nt DOT tuwien DOT ac DOT at
Institut fuer *U* http://www.nt.tuwien.ac.at/~tony/
Nachrichtentechnik und *W* http://www.nt.tuwien.ac.at/
Hochfrequenztechnik *I* talkto:tony AT eagle DOT nt DOT tuwien DOT ac DOT at
Guszhausstr. 25/389 *E* phoneto:+43-1-58801-3520
A-1040 Wien, AUSTRIA *N* faxto:+43-1-5870583
**************************************************************
- Raw text -