Subject: Wierd mktime and localtime behavior
From: Ravi Chari <[email-masked]>
To: cygwin <[email-masked]>
Date: Tue, 04 Jul 2000 09:26:57 -0400

I recently updated my gcc. mktime doesn't seem to update all the fields
in struct tm and localtime just seems completely broken.
~/draft1 522 > gcc -g -o tt timetest.c
~/draft1 523 > tt 
after mktime: yy = 100 mm = 6  dd = 4  wd = -1
after localtime: yy = 69 mm = 11  dd = 31  wd = 3

~/draft1 524 > gcc -v
Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/2.95.2/specs
gcc version 2.95.2 19991024 (release-2)

At least in Unix, a call to mktime fixes all the the fields in tm. I
first thought this was g++ problem, but this seems to be there in gcc as
well. I have seen frequent references to localtime problems, but they
seem to involve TimeZone problems and appear to have been fixed. Am I
not set up properly or am I doing something wrong? Appreciate any help.
Ravi

Here is the example code:
-------------------
// timetest.c

#include <stdio.h>
#include <time.h>
#include <stdlib.h>

int main(int argc, char **argv){
  struct tm _tm, *_tm1;
  time_t jul;
  _tm.tm_year = 100;
  _tm.tm_mday = 4;
  _tm.tm_mon = 6;
  _tm.tm_wday = -1;
  jul = mktime(&_tm);
  printf("after mktime: yy = %d mm = %d  dd = %d  wd =
%d\n",_tm.tm_year, _tm.tm_mon, _tm.tm_mday, _tm.tm_wday);
  _tm1 = localtime(&jul);
  printf("after localtime: yy = %d mm = %d  dd = %d  wd =
%d\n",_tm1->tm_year, _tm1->tm_mon, _tm1->tm_mday, _tm1->tm_wday);
  return 0;
}

--------------

--
Want to unsubscribe from this list?
Send a message to [email-masked]