[comp.unix.questions] A UNIX question

peter@ficc.uu.net (Peter da Silva) (12/30/88)

I have a question about comp.unix.questions...

Why is it that the only articles left that I don't skip over always seem to
be about MULTICS? How about giving the security/password aging/libraries
stuff a rest?
-- 
Peter da Silva, Xenix Support, Ferranti International Controls Corporation.
Work: uunet.uu.net!ficc!peter, peter@ficc.uu.net, +1 713 274 5180.   `-_-'
Home: bigtex!texbell!sugar!peter, peter@sugar.uu.net.                 'U`
Opinions may not represent the policies of FICC or the Xenix Support group.

sevalia@eecs.umich.edu (Piyush B. Sevalia) (04/20/91)

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.

fidelio@geech.gnu.ai.mit.edu (Rob J. Nauta) (04/21/91)

Hi

Regardless of what your question is, read the beginners document in
news.announce.newusers. One of the items handles picking a decent
subject for your article. If you post to comp.unix.questions, a subject
like "A UNIX question" is about the worst you can imagine, it says
nothing, since the newsgroup name duplicates your subject completely !

Since your question regards C programming, put something like that in
the subject. Also, crossposting to comp.unix.programmer might help too

Rob