At 12:06 PM 5/22/00 -0400, Jonathan S. Shapiro wrote:
>I'm saying that I don't know, and I'ld rather not find out *after* I
>release...
>
>> Are you saying that Unix time doesn't?
>
>Actually, I'm not convinced that they all use the same epoch, and note that
>time() is a system call, not a part of the standard C library...
>
>
>shap
The ANSI difftime(time_t t1, time_t t2) seems to allow you to do what you need. The example from Harbison and Steele's "C A Reference Manual" v3 gives the time since April 15, 1990:
#include <time.h>
...
double Secs_Since_Apr_15() {
struct tm Apr_15_struct = {0}; /* Init all fields to zero */ time_t Apr_15_t;
Apr_15_struct.tm_year = 90;
Apr_15_struct.tm_mon = 3;
Apr_15_struct.tm_mday = 15;
Apr_15_t = mktime(&Apr_15_struct);
if (Apr_15_t == (time_t)-1) {
return 0.0; /* error */
} else {
return difftime( time(NULL), Apr_15_t);
}