mktime32.c 264 B

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