Dan Aloni wrote:Yes, but did you follow the link ( http://www.2038bug.com )?Oh, the "2^31 seconds are enough time for everybody", brought to you by one or more careless UNIX designers who might be lucky enough to be alive and 100+ years old when this bug actually manifests. The specific issue mentioned at the top of the page should celebrate it's 1st birthday this Monday (1<<30 is 15:37:04, Feb 10, 2004 ). Try this one: #include <stdio.h> #include <time.h> char date1[] = "Fri, 7 Jan 2005 20:00:01"; char date2[] = "Fri, 7 Jan 2005 20:00:03"; char timefmt[] = "%a, %d %b %Y %H:%M:%S"; int main(int argc, char *argv[]) { struct tm time; time_t t1,t2,av; strptime(date1,timefmt,&time); t1 = mktime(&time); strptime(date2,timefmt,&time); t2 = mktime(&time); printf("First estimate is %s\n",asctime(gmtime(&t1))); printf("Second estimate is %s\n",asctime(gmtime(&t2))); av = (t1+t2)/2; /* BUG: Should be something like (0.5+t1+t2)/2 */ printf("So, I guess average estimate is %s\n",asctime(gmtime(&av))); } ... British Mandate's back in town ... ;-) I don't recall any such trouble last year, but who knows - it might had actually been fixed before I noticed, and it might still exist in some programs I don't use... |