Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!umich!umeecs!sparky.eecs.umich.edu!sevalia From: sevalia@eecs.umich.edu (Piyush B. Sevalia) Newsgroups: comp.unix.misc Subject: A UNIX question.... Message-ID: <1991Apr20.021915.1196@zip.eecs.umich.edu> Date: 20 Apr 91 02:19:15 GMT Sender: usenet@zip.eecs.umich.edu (Mr. News) Organization: University of Michigan EECS Dept. Lines: 65 Originator: sevalia@sparky.eecs.umich.edu Guys and Girls, I have a small question which I hope you will be able to help me with. I am using the following segment of code in my program. The problem is explained after the code. junk = (struct tm *)malloc(sizeof(struct tm)); junk->tm_sec = 0; junk->tm_min = 0; junk->tm_hour = 0; junk->tm_mday = mday; junk->tm_mon = mon - 1; /* 0-11 the range! */ junk->tm_year = year; junk->tm_wday = 0; junk->tm_yday = 0; junk->tm_isdst = isdst; *ptr = timegm(junk); if (*ptr == -1) { printf("Error: Invalid date!\n"); exit(ERROR); } mday is the day of the month mon is the month year is the year isdst is the daylight savings time flag. The problem : The code works fine if the daylight savings time is not in effect. i.e. if the daylight savings time flag isdst is not 1. However if it is one, timegm returns a -1, which is an error condition. Note that ptr is of type int * . Now could someone please tell me why this happens and what should I do to rectify it ? I have checked the SUN man pages (I work on the SUN Sparcstn 1+) and I could not get much info there. This is a slightly desperate situation and I have to demo the program next week. Please email me. I do not read this newsgroup, and it is the end of the semester and I have a lot of projects due. Thanks a lot, Piyush Sevalia Grad. Student University of Michigan Department of Electrical Engineering.