diff options
author | Rich Felker <dalias@aerifal.cx> | 2013-07-17 05:24:50 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2013-07-17 05:24:50 -0400 |
commit | 1cc81f5cb0df2b66a795ff0c26d7bbc4d16e13c6 (patch) | |
tree | d8839fbfd8cb1fb5658394cad6a6a06688ab6a1b /src/time/__tm_to_time.c | |
parent | f1292e3d28309bbc81f61671164843cec4319bfa (diff) | |
download | musl-1cc81f5cb0df2b66a795ff0c26d7bbc4d16e13c6.tar.gz |
the big time handling overhaul
this commit has two major user-visible parts: zoneinfo-format time
zones are now supported, and overflow handling is intended to be
complete in the sense that all functions return a correct result if
and only if the result fits in the destination type, and otherwise
return an error. also, some noticable bugs in the way DST detection
and normalization worked have been fixed, and performance may be
better than before, but it has not been tested.
Diffstat (limited to 'src/time/__tm_to_time.c')
-rw-r--r-- | src/time/__tm_to_time.c | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/src/time/__tm_to_time.c b/src/time/__tm_to_time.c deleted file mode 100644 index 9f11805d..00000000 --- a/src/time/__tm_to_time.c +++ /dev/null @@ -1,33 +0,0 @@ -#include <time.h> - -/* C defines the rounding for division in a nonsensical way */ -#define Q(a,b) ((a)>0 ? (a)/(b) : -(((b)-(a)-1)/(b))) - -time_t __tm_to_time(struct tm *tm) -{ - time_t year = tm->tm_year + -100; - int month = tm->tm_mon; - int day = tm->tm_mday; - int z4, z100, z400; - - /* normalize month */ - if (month >= 12) { - year += month/12; - month %= 12; - } else if (month < 0) { - year += month/12; - month %= 12; - if (month) { - month += 12; - year--; - } - } - z4 = Q(year - (month < 2), 4); - z100 = Q(z4, 25); - z400 = Q(z100, 4); - day += year*365 + z4 - z100 + z400 + - month[(const int []){0,31,59,90,120,151,181,212,243,273,304,334}]; - return (long long)day*86400 - + tm->tm_hour*3600 + tm->tm_min*60 + tm->tm_sec - - -946684800; /* the dawn of time :) */ -} |