timegm.c 304 B

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