the big time handling overhaul
[musl] / src / time / localtime_r.c
1 #include "time_impl.h"
2 #include <errno.h>
3 #include "libc.h"
4
5 struct tm *__localtime_r(const time_t *restrict t, struct tm *restrict tm)
6 {
7         __secs_to_zone(*t, 0, &tm->tm_isdst, &tm->__tm_gmtoff, 0, &tm->__tm_zone);
8         if (__secs_to_tm((long long)*t - tm->__tm_gmtoff, tm) < 0) {
9                 errno = EINVAL;
10                 return 0;
11         }
12         return tm;
13 }
14
15 weak_alias(__localtime_r, localtime_r);