Mail Archives: djgpp/1994/06/21/03:22:24
I wrote the following program to test the gmtime, ctime and localtime
functions:
#include <time.h>
#include <stdio.h>
void main(void) {
time_t a;
struct tm *b, *c;
time(&a);
printf("ctime function returns:\n%s\n",ctime(&a));
b = gmtime(&a);
c = localtime(&a);
printf("gmttime function returns:\n%s\n",asctime(b));
printf("localtime function returns:\n%s\n",asctime(c));
}
And here is the output I got on my PC:
ctime function returns:
Mon Jun 20 11:04:25 1994
gmttime function returns:
Mon Jun 20 16:04:25 1994
localtime function returns:
Mon Jun 20 11:04:25 1994
And the same program run on a Unix system output:
ctime function returns:
Mon Jun 20 11:52:13 1994
gmttime function returns:
Mon Jun 20 11:52:13 1994
localtime function returns:
Mon Jun 20 11:52:13 1994
Both were run close to the same time. The correct time here
now is Mon Jun 20 11:52 1994. My clocks are set 15 mins.
ahead of time, so the actual difference is about 1 hour
slower. But when I run time on my PC I get the correct time.
Is there a bug in the ctime and localtime functions?
MCMIII
Murle Cleveland Meetze III
meetze AT charlie DOT ece DOT scarolina DOT edu
- Raw text -