X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Ftime%2Fmktime.c;h=bad3f0765a089fd9f97e6f0d651b15fd19d949ed;hb=4554f155dd23a65fcdfd39f1d5af8af55ba37694;hp=e38b46191c50b1346cb8cafddfe0b85f5ecd14ac;hpb=1cc81f5cb0df2b66a795ff0c26d7bbc4d16e13c6;p=musl diff --git a/src/time/mktime.c b/src/time/mktime.c index e38b4619..bad3f076 100644 --- a/src/time/mktime.c +++ b/src/time/mktime.c @@ -1,7 +1,5 @@ #include "time_impl.h" #include -#include -#include time_t mktime(struct tm *tm) { @@ -12,19 +10,19 @@ time_t mktime(struct tm *tm) __secs_to_zone(t, 1, &new.tm_isdst, &new.__tm_gmtoff, &opp, &new.__tm_zone); if (tm->tm_isdst>=0 && new.tm_isdst!=tm->tm_isdst) - t += opp - new.__tm_gmtoff; + t -= opp - new.__tm_gmtoff; - t += new.__tm_gmtoff; + t -= new.__tm_gmtoff; if ((time_t)t != t) goto error; __secs_to_zone(t, 0, &new.tm_isdst, &new.__tm_gmtoff, &opp, &new.__tm_zone); - if (__secs_to_tm(t - new.__tm_gmtoff, &new) < 0) goto error; + if (__secs_to_tm(t + new.__tm_gmtoff, &new) < 0) goto error; *tm = new; return t; error: - errno = EINVAL; + errno = EOVERFLOW; return -1; }