timegm.c raw

   1  #define _GNU_SOURCE
   2  #include "time_impl.h"
   3  #include <errno.h>
   4  
   5  time_t timegm(struct tm *tm)
   6  {
   7  	struct tm new;
   8  	long long t = __tm_to_secs(tm);
   9  	if (__secs_to_tm(t, &new) < 0) {
  10  		errno = EOVERFLOW;
  11  		return -1;
  12  	}
  13  	*tm = new;
  14  	tm->tm_isdst = 0;
  15  	tm->__tm_gmtoff = 0;
  16  	tm->__tm_zone = __utc;
  17  	return t;
  18  }
  19