time32gm.c 248 B

123456789101112131415
  1. #define _GNU_SOURCE
  2. #include "time32.h"
  3. #include <time.h>
  4. #include <errno.h>
  5. #include <stdint.h>
  6. time32_t __time32gm(struct tm *tm)
  7. {
  8. time_t t = timegm(tm);
  9. if (t < INT32_MIN || t > INT32_MAX) {
  10. errno = EOVERFLOW;
  11. return -1;
  12. }
  13. return t;
  14. }