mirror of https://git.musl-libc.org/git/musl
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
482 B
24 lines
482 B
#include "time_impl.h"
|
|
|
|
long long __tm_to_secs(const struct tm *tm)
|
|
{
|
|
int is_leap;
|
|
long long year = tm->tm_year;
|
|
int month = tm->tm_mon;
|
|
if (month >= 12 || month < 0) {
|
|
int adj = month / 12;
|
|
month %= 12;
|
|
if (month < 0) {
|
|
adj--;
|
|
month += 12;
|
|
}
|
|
year += adj;
|
|
}
|
|
long long t = __year_to_secs(year, &is_leap);
|
|
t += __month_to_secs(month, is_leap);
|
|
t += 86400LL * (tm->tm_mday-1);
|
|
t += 3600LL * tm->tm_hour;
|
|
t += 60LL * tm->tm_min;
|
|
t += tm->tm_sec;
|
|
return t;
|
|
}
|
|
|