diff --git a/Makefile b/Makefile index 4f5e61299..05299709e 100644 --- a/Makefile +++ b/Makefile @@ -258,7 +258,7 @@ include libc/thread/BUILD.mk # │ You can finally call malloc() include third_party/zlib/BUILD.mk # │ include libc/stdio/BUILD.mk # │ include tool/hello/BUILD.mk # │ -include libc/time/BUILD.mk # │ +include third_party/tz/BUILD.mk # │ include net/BUILD.mk # │ include third_party/vqsort/BUILD.mk # │ include libc/log/BUILD.mk # │ @@ -440,7 +440,7 @@ COSMOPOLITAN_OBJECTS = \ LIBC_X \ THIRD_PARTY_GETOPT \ LIBC_LOG \ - LIBC_TIME \ + THIRD_PARTY_TZ \ THIRD_PARTY_OPENMP \ THIRD_PARTY_MUSL \ THIRD_PARTY_ZLIB_GZ \ @@ -505,7 +505,6 @@ COSMOPOLITAN_H_PKGS = \ LIBC_STR \ LIBC_SYSV \ LIBC_THREAD \ - LIBC_TIME \ LIBC_TINYMATH \ LIBC_X \ LIBC_VGA \ diff --git a/dsp/mpeg/BUILD.mk b/dsp/mpeg/BUILD.mk index 147bffc47..a16089eaa 100644 --- a/dsp/mpeg/BUILD.mk +++ b/dsp/mpeg/BUILD.mk @@ -35,7 +35,6 @@ DSP_MPEG_A_DIRECTDEPS = \ LIBC_STDIO \ LIBC_STR \ LIBC_SYSV \ - LIBC_TIME \ LIBC_TINYMATH \ THIRD_PARTY_COMPILER_RT diff --git a/dsp/mpeg/mpeg1.c b/dsp/mpeg/mpeg1.c index 905af23da..5b9eb0b82 100644 --- a/dsp/mpeg/mpeg1.c +++ b/dsp/mpeg/mpeg1.c @@ -39,7 +39,7 @@ #include "libc/math.h" #include "libc/mem/mem.h" #include "libc/str/str.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "libc/x/x.h" __static_yoink("pl_mpeg_notice"); diff --git a/dsp/scale/BUILD.mk b/dsp/scale/BUILD.mk index 79c25a534..bd4f6df7e 100644 --- a/dsp/scale/BUILD.mk +++ b/dsp/scale/BUILD.mk @@ -31,7 +31,6 @@ DSP_SCALE_A_DIRECTDEPS = \ LIBC_NEXGEN32E \ LIBC_RUNTIME \ LIBC_STR \ - LIBC_TIME \ LIBC_TINYMATH \ LIBC_X diff --git a/dsp/tty/BUILD.mk b/dsp/tty/BUILD.mk index c87dcb028..692ec26f5 100644 --- a/dsp/tty/BUILD.mk +++ b/dsp/tty/BUILD.mk @@ -38,7 +38,6 @@ DSP_TTY_A_DIRECTDEPS = \ LIBC_SOCK \ LIBC_SYSV \ LIBC_TINYMATH \ - LIBC_TIME \ LIBC_X DSP_TTY_A_DEPS := \ diff --git a/examples/BUILD.mk b/examples/BUILD.mk index 46faa0d95..a6965d922 100644 --- a/examples/BUILD.mk +++ b/examples/BUILD.mk @@ -65,7 +65,6 @@ EXAMPLES_DIRECTDEPS = \ LIBC_SYSV_CALLS \ LIBC_TESTLIB \ LIBC_THREAD \ - LIBC_TIME \ LIBC_TINYMATH \ LIBC_VGA \ LIBC_X \ @@ -89,6 +88,7 @@ EXAMPLES_DIRECTDEPS = \ THIRD_PARTY_SED \ THIRD_PARTY_STB \ THIRD_PARTY_TR \ + THIRD_PARTY_TZ \ THIRD_PARTY_VQSORT \ THIRD_PARTY_XED \ THIRD_PARTY_ZLIB \ diff --git a/examples/date.c b/examples/date.c index 70b1f60d4..fbee50f5d 100644 --- a/examples/date.c +++ b/examples/date.c @@ -9,19 +9,30 @@ #endif #include "libc/calls/calls.h" #include "libc/calls/struct/timespec.h" +#include "libc/intrin/kprintf.h" +#include "libc/macros.internal.h" +#include "libc/nt/enum/timezoneid.h" +#include "libc/nt/struct/timezoneinformation.h" +#include "libc/nt/time.h" +#include "libc/runtime/runtime.h" +#include "libc/stdio/stdio.h" #include "libc/str/str.h" -#include "libc/time/struct/tm.h" +#include "libc/thread/threads.h" +#include "libc/time.h" /** * @fileoverview High performance ISO-8601 timestamp formatter. + * + * The strftime() function is very slow. This goes much faster. + * Consider using something like this instead for your loggers. */ char *GetTimestamp(void) { int x; struct timespec ts; - _Thread_local static long last; - _Thread_local static char s[27]; - _Thread_local static struct tm tm; + thread_local static long last; + thread_local static char s[32]; + thread_local static struct tm tm; clock_gettime(0, &ts); if (ts.tv_sec != last) { localtime_r(&ts.tv_sec, &tm); @@ -61,11 +72,21 @@ char *GetTimestamp(void) { s[23] = '0' + x / 100000 % 10; s[24] = '0' + x / 10000 % 10; s[25] = '0' + x / 1000 % 10; + s[26] = tm.tm_gmtoff < 0 ? '-' : '+'; + x = ABS(tm.tm_gmtoff) / 60 / 60; + s[27] = '0' + x / 10 % 10; + s[28] = '0' + x % 10; + x = ABS(tm.tm_gmtoff) / 60 % 60; + s[29] = '0' + x / 10 % 10; + s[30] = '0' + x % 10; return s; } int main(int argc, char *argv[]) { char buf[128], *p = buf; + // setenv("TZ", "UTC", true); + // setenv("TZ", "US/Eastern", true); + // setenv("TZ", "Asia/Kolkata", true); p = stpcpy(p, GetTimestamp()); p = stpcpy(p, "\n"); write(1, buf, p - buf); diff --git a/examples/hangman.c b/examples/hangman.c index 0aa257ad9..4aa736490 100644 --- a/examples/hangman.c +++ b/examples/hangman.c @@ -42,7 +42,7 @@ #include "libc/stdio/rand.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/zlib/zlib.h" // clang-format off diff --git a/examples/kilo.c b/examples/kilo.c index dfc5aeb46..055b29853 100644 --- a/examples/kilo.c +++ b/examples/kilo.c @@ -71,7 +71,7 @@ Contact: antirez@gmail.com"); #include "libc/sysv/consts/fileno.h" #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/termios.h" -#include "libc/time/time.h" +#include "libc/time.h" /* Syntax highlight types */ #define HL_NORMAL 0 diff --git a/examples/localtime.c b/examples/localtime.c new file mode 100644 index 000000000..70d67c1c2 --- /dev/null +++ b/examples/localtime.c @@ -0,0 +1,15 @@ +#if 0 +/*─────────────────────────────────────────────────────────────────╗ +│ To the extent possible under law, Justine Tunney has waived │ +│ all copyright and related or neighboring rights to this file, │ +│ as it is written in the following disclaimers: │ +│ • http://unlicense.org/ │ +│ • http://creativecommons.org/publicdomain/zero/1.0/ │ +╚─────────────────────────────────────────────────────────────────*/ +#endif +#include "libc/time.h" + +int main(int argc, char *argv[]) { + int64_t t = 0; + localtime(&t); +} diff --git a/examples/nesemu1.cc b/examples/nesemu1.cc index 296980186..521fad822 100644 --- a/examples/nesemu1.cc +++ b/examples/nesemu1.cc @@ -44,7 +44,7 @@ #include "libc/sysv/consts/sig.h" #include "libc/sysv/consts/w.h" #include "libc/thread/thread.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "libc/x/xasprintf.h" #include "libc/x/xsigaction.h" #include "libc/zip.internal.h" diff --git a/examples/script.c b/examples/script.c index e840aca8a..e6559e626 100644 --- a/examples/script.c +++ b/examples/script.c @@ -50,7 +50,7 @@ #include "libc/sysv/consts/fileno.h" #include "libc/sysv/consts/s.h" #include "libc/sysv/consts/termios.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/getopt/getopt.internal.h" // clang-format off diff --git a/examples/setitimer.c b/examples/setitimer.c index 1fedf863a..89b291941 100644 --- a/examples/setitimer.c +++ b/examples/setitimer.c @@ -17,7 +17,7 @@ #include "libc/sysv/consts/itimer.h" #include "libc/sysv/consts/sa.h" #include "libc/sysv/consts/sig.h" -#include "libc/time/time.h" +#include "libc/time.h" volatile bool gotalrm; diff --git a/examples/stat.c b/examples/stat.c index f04025d98..dce122cbb 100644 --- a/examples/stat.c +++ b/examples/stat.c @@ -8,16 +8,18 @@ ╚─────────────────────────────────────────────────────────────────*/ #endif #include "libc/calls/struct/stat.h" +#include "libc/assert.h" #include "libc/calls/calls.h" #include "libc/errno.h" #include "libc/fmt/conv.h" #include "libc/log/check.h" #include "libc/log/log.h" #include "libc/mem/gc.h" +#include "libc/mem/mem.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/sysv/consts/s.h" -#include "libc/x/xiso8601.h" +#include "libc/time.h" /** * @fileoverview File metadata viewer. @@ -27,6 +29,23 @@ bool numeric; +char *xiso8601(struct timespec ts) { + struct tm tm; + if (!localtime_r(&ts.tv_sec, &tm)) + return 0; + int len = 128; + char *res = malloc(len); + char *ptr = res; + char *end = res + len; + if (!res) + return 0; + ptr += strftime(ptr, end - ptr, "%Y-%m-%d %H:%M:%S", &tm); + ptr += snprintf(ptr, end - ptr, ".%09ld", ts.tv_nsec); + ptr += strftime(ptr, end - ptr, "%z %Z", &tm); + unassert(ptr + 1 <= end); + return res; +} + const char *DescribeFileType(unsigned mode) { switch (mode & S_IFMT) { case S_IFIFO: @@ -74,16 +93,16 @@ void PrintFileMetadata(const char *pathname, struct stat *st) { "%-32s%s\n" "%-32s%s\n" "%-32s%s\n", - "bytes in file", st->st_size, "physical bytes", st->st_blocks * 512, - "device id w/ file", st->st_dev, "inode", st->st_ino, - "hard link count", st->st_nlink, "mode / permissions", st->st_mode, - DescribeFileType(st->st_mode), "owner id", st->st_uid, "group id", - st->st_gid, "flags", st->st_flags, "gen", st->st_gen, - "device id (if special)", st->st_rdev, "block size", st->st_blksize, - "access time", gc(xiso8601(&st->st_atim)), "modified time", - gc(xiso8601(&st->st_mtim)), "c[omplicated]time", - gc(xiso8601(&st->st_ctim)), "birthtime", - gc(xiso8601(&st->st_birthtim))); + "bytes in file:", st->st_size, "physical bytes:", st->st_blocks * 512, + "device id w/ file:", st->st_dev, "inode:", st->st_ino, + "hard link count:", st->st_nlink, "mode / permissions:", st->st_mode, + DescribeFileType(st->st_mode), "owner id:", st->st_uid, + "group id:", st->st_gid, "flags:", st->st_flags, "gen:", st->st_gen, + "device id (if special):", st->st_rdev, "block size:", st->st_blksize, + "access time:", gc(xiso8601(st->st_atim)), + "modified time:", gc(xiso8601(st->st_mtim)), + "c[omplicated]time:", gc(xiso8601(st->st_ctim)), + "[birthtime]:", gc(xiso8601(st->st_birthtim))); } int main(int argc, char *argv[]) { diff --git a/examples/wall.c b/examples/wall.c index e0fece754..311a9e3bc 100644 --- a/examples/wall.c +++ b/examples/wall.c @@ -16,7 +16,7 @@ #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/sysv/consts/o.h" -#include "libc/time/struct/tm.h" +#include "libc/time.h" #include "third_party/getopt/getopt.internal.h" #include "third_party/musl/passwd.h" diff --git a/libc/BUILD.mk b/libc/BUILD.mk index 523020830..7ebd0fd4a 100644 --- a/libc/BUILD.mk +++ b/libc/BUILD.mk @@ -300,7 +300,6 @@ o/$(MODE)/libc: o/$(MODE)/libc/calls \ o/$(MODE)/libc/sysv \ o/$(MODE)/libc/testlib \ o/$(MODE)/libc/thread \ - o/$(MODE)/libc/time \ o/$(MODE)/libc/tinymath \ o/$(MODE)/libc/vga \ o/$(MODE)/libc/x \ diff --git a/libc/calls/clock_getres.c b/libc/calls/clock_getres.c index 3f4be4717..845875461 100644 --- a/libc/calls/clock_getres.c +++ b/libc/calls/clock_getres.c @@ -23,7 +23,7 @@ #include "libc/intrin/strace.internal.h" #include "libc/sysv/consts/clock.h" #include "libc/sysv/errfuns.h" -#include "libc/time/time.h" +#include "libc/time.h" static int sys_clock_getres_poly(int clock, struct timespec *ts, int64_t real, int64_t real_coarse, int64_t boot) { diff --git a/libc/time/futimesat.c b/libc/calls/futimesat.c similarity index 100% rename from libc/time/futimesat.c rename to libc/calls/futimesat.c diff --git a/libc/calls/gettimeofday.c b/libc/calls/gettimeofday.c index 34fc8547c..78c170e78 100644 --- a/libc/calls/gettimeofday.c +++ b/libc/calls/gettimeofday.c @@ -19,7 +19,7 @@ #include "libc/calls/struct/timespec.h" #include "libc/calls/struct/timeval.h" #include "libc/sysv/consts/clock.h" -#include "libc/time/struct/timezone.h" +#include "libc/time.h" /** * Returns system wall time in microseconds, e.g. diff --git a/libc/calls/settimeofday.c b/libc/calls/settimeofday.c index 4766790f6..116c1b38e 100644 --- a/libc/calls/settimeofday.c +++ b/libc/calls/settimeofday.c @@ -22,7 +22,7 @@ #include "libc/dce.h" #include "libc/intrin/strace.internal.h" #include "libc/sysv/errfuns.h" -#include "libc/time/struct/timezone.h" +#include "libc/time.h" /** * Changes time. diff --git a/libc/calls/sleep.c b/libc/calls/sleep.c index 90debc667..382aa4587 100644 --- a/libc/calls/sleep.c +++ b/libc/calls/sleep.c @@ -24,7 +24,7 @@ #include "libc/sysv/consts/clock.h" #include "libc/thread/posixthread.internal.h" #include "libc/thread/thread.h" -#include "libc/time/time.h" +#include "libc/time.h" /** * Sleeps for particular number of seconds. diff --git a/libc/calls/stime.c b/libc/calls/stime.c index d97d12c4f..820558f56 100644 --- a/libc/calls/stime.c +++ b/libc/calls/stime.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/struct/timeval.h" -#include "libc/time/time.h" +#include "libc/time.h" /** * Changes time, the old fashioned way. diff --git a/libc/calls/struct/timeval.h b/libc/calls/struct/timeval.h index e2004b7e6..553e985fb 100644 --- a/libc/calls/struct/timeval.h +++ b/libc/calls/struct/timeval.h @@ -1,7 +1,7 @@ #ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_TIMEVAL_H_ #define COSMOPOLITAN_LIBC_CALLS_STRUCT_TIMEVAL_H_ #include "libc/calls/struct/timespec.h" -#include "libc/time/struct/timezone.h" +#include "libc/time.h" COSMOPOLITAN_C_START_ struct timeval { diff --git a/libc/calls/struct/timeval.internal.h b/libc/calls/struct/timeval.internal.h index d3eca91bc..ceaf8f73e 100644 --- a/libc/calls/struct/timeval.internal.h +++ b/libc/calls/struct/timeval.internal.h @@ -2,7 +2,7 @@ #define COSMOPOLITAN_LIBC_CALLS_STRUCT_TIMEVAL_INTERNAL_H_ #include "libc/calls/struct/timeval.h" #include "libc/mem/alloca.h" -#include "libc/time/struct/timezone.h" +#include "libc/time.h" COSMOPOLITAN_C_START_ int sys_settimeofday(const struct timeval *, const struct timezone *); diff --git a/libc/calls/time.c b/libc/calls/time.c index aa90da67a..644fa669e 100644 --- a/libc/calls/time.c +++ b/libc/calls/time.c @@ -16,7 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/time/time.h" +#include "libc/time.h" #include "libc/calls/struct/timeval.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" diff --git a/libc/calls/timespec_get.c b/libc/calls/timespec_get.c index fae6ca813..4dd0eadbd 100644 --- a/libc/calls/timespec_get.c +++ b/libc/calls/timespec_get.c @@ -18,7 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/struct/timespec.h" #include "libc/sysv/consts/clock.h" -#include "libc/time/time.h" +#include "libc/time.h" /** * Returns high-precision timestamp, the C11 way. diff --git a/libc/calls/timespec_getres.c b/libc/calls/timespec_getres.c index 56ceb2514..b695823ea 100644 --- a/libc/calls/timespec_getres.c +++ b/libc/calls/timespec_getres.c @@ -18,7 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/struct/timespec.h" #include "libc/sysv/consts/clock.h" -#include "libc/time/time.h" +#include "libc/time.h" /** * Returns high-precision timestamp granularity, the C23 way. diff --git a/libc/calls/usleep.c b/libc/calls/usleep.c index 6fafae9e8..82dd7b55f 100644 --- a/libc/calls/usleep.c +++ b/libc/calls/usleep.c @@ -21,7 +21,7 @@ #include "libc/sysv/consts/clock.h" #include "libc/sysv/consts/utime.h" #include "libc/sysv/errfuns.h" -#include "libc/time/time.h" +#include "libc/time.h" /** * Sleeps for particular number of microseconds. diff --git a/libc/calls/utime.c b/libc/calls/utime.c index 9e5ad3f8b..a799a9ad6 100644 --- a/libc/calls/utime.c +++ b/libc/calls/utime.c @@ -16,8 +16,8 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/utime.h" #include "libc/calls/struct/timeval.h" -#include "libc/time/struct/utimbuf.h" /** * Changes last accessed/modified times on file. diff --git a/libc/calls/utimensat-nt.c b/libc/calls/utimensat-nt.c index ce843388c..0a0c0a082 100644 --- a/libc/calls/utimensat-nt.c +++ b/libc/calls/utimensat-nt.c @@ -33,7 +33,7 @@ #include "libc/sysv/consts/at.h" #include "libc/sysv/consts/utime.h" #include "libc/sysv/errfuns.h" -#include "libc/time/time.h" +#include "libc/time.h" static textwindows int sys_utimensat_nt_impl(int dirfd, const char *path, const struct timespec ts[2], diff --git a/libc/calls/utimensat-sysv.c b/libc/calls/utimensat-sysv.c index d024d731f..0a4401da2 100644 --- a/libc/calls/utimensat-sysv.c +++ b/libc/calls/utimensat-sysv.c @@ -24,7 +24,7 @@ #include "libc/fmt/conv.h" #include "libc/runtime/zipos.internal.h" #include "libc/sysv/consts/at.h" -#include "libc/time/time.h" +#include "libc/time.h" int sys_utimensat(int dirfd, const char *path, const struct timespec ts[2], int flags) { diff --git a/libc/intrin/BUILD.mk b/libc/intrin/BUILD.mk index 2ba6fa39b..d912f8556 100644 --- a/libc/intrin/BUILD.mk +++ b/libc/intrin/BUILD.mk @@ -132,6 +132,14 @@ o/$(MODE)/libc/intrin/ktcpoptnames.o: libc/intrin/ktcpoptnames.S @$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $< o/$(MODE)/libc/intrin/stackcall.o: libc/intrin/stackcall.S @$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $< +o/$(MODE)/libc/intrin/kmonthname.o: libc/intrin/kmonthname.S + @$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $< +o/$(MODE)/libc/intrin/kmonthnameshort.o: libc/intrin/kmonthnameshort.S + @$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $< +o/$(MODE)/libc/intrin/kweekdayname.o: libc/intrin/kweekdayname.S + @$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $< +o/$(MODE)/libc/intrin/kweekdaynameshort.o: libc/intrin/kweekdaynameshort.S + @$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $< LIBC_INTRIN_LIBS = $(foreach x,$(LIBC_INTRIN_ARTIFACTS),$($(x))) LIBC_INTRIN_HDRS = $(foreach x,$(LIBC_INTRIN_ARTIFACTS),$($(x)_HDRS)) diff --git a/libc/time/kmonthname.S b/libc/intrin/kmonthname.S similarity index 100% rename from libc/time/kmonthname.S rename to libc/intrin/kmonthname.S diff --git a/libc/time/kmonthnameshort.S b/libc/intrin/kmonthnameshort.S similarity index 100% rename from libc/time/kmonthnameshort.S rename to libc/intrin/kmonthnameshort.S diff --git a/libc/time/kweekdayname.S b/libc/intrin/kweekdayname.S similarity index 100% rename from libc/time/kweekdayname.S rename to libc/intrin/kweekdayname.S diff --git a/libc/time/kweekdaynameshort.S b/libc/intrin/kweekdaynameshort.S similarity index 100% rename from libc/time/kweekdaynameshort.S rename to libc/intrin/kweekdaynameshort.S diff --git a/libc/intrin/ubsan.c b/libc/intrin/ubsan.c index 35d9799e5..98c22d85d 100644 --- a/libc/intrin/ubsan.c +++ b/libc/intrin/ubsan.c @@ -16,6 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/intrin/ubsan.h" #include "libc/calls/calls.h" #include "libc/intrin/kprintf.h" #include "libc/intrin/pushpop.internal.h" @@ -241,6 +242,8 @@ static void __ubsan_warning(const struct UbsanSourceLocation *loc, const char *description) { kprintf("%s:%d: %subsan warning: %s is undefined behavior%s\n", loc->file, loc->line, SUBTLE, description, RESET); + if (__ubsan_strict) + __ubsan_die()(); } __wur __ubsan_die_f *__ubsan_abort(const struct UbsanSourceLocation *loc, diff --git a/libc/intrin/ubsan.h b/libc/intrin/ubsan.h new file mode 100644 index 000000000..c258ed74f --- /dev/null +++ b/libc/intrin/ubsan.h @@ -0,0 +1,8 @@ +#ifndef COSMOPOLITAN_LIBC_INTRIN_UBSAN_H_ +#define COSMOPOLITAN_LIBC_INTRIN_UBSAN_H_ +COSMOPOLITAN_C_START_ + +extern bool32 __ubsan_strict; + +COSMOPOLITAN_C_END_ +#endif /* COSMOPOLITAN_LIBC_INTRIN_UBSAN_H_ */ diff --git a/libc/time/timezone.c b/libc/intrin/ubsanconf.c similarity index 91% rename from libc/time/timezone.c rename to libc/intrin/ubsanconf.c index 9d5696b45..ca3180857 100644 --- a/libc/time/timezone.c +++ b/libc/intrin/ubsanconf.c @@ -1,7 +1,7 @@ /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │ vi: set et ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi │ ╞══════════════════════════════════════════════════════════════════════════════╡ -│ Copyright 2022 Justine Alexandra Roberts Tunney │ +│ Copyright 2024 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ @@ -16,8 +16,8 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/time/time.h" -char *tzname[2]; -long timezone; -int daylight; +/** + * If set to true, UBSAN warnings will become fatal. + */ +bool32 __ubsan_strict = false; diff --git a/libc/isystem/sys/stat.h b/libc/isystem/sys/stat.h index 07b3951c9..960297ffb 100644 --- a/libc/isystem/sys/stat.h +++ b/libc/isystem/sys/stat.h @@ -7,5 +7,5 @@ #include "libc/calls/weirdtypes.h" #include "libc/sysv/consts/s.h" #include "libc/sysv/consts/utime.h" -#include "libc/time/time.h" +#include "libc/time.h" #endif diff --git a/libc/isystem/sys/time.h b/libc/isystem/sys/time.h index 3ad0ae0d3..7bfc08041 100644 --- a/libc/isystem/sys/time.h +++ b/libc/isystem/sys/time.h @@ -6,6 +6,5 @@ #include "libc/sock/select.h" #include "libc/sysv/consts/clock.h" #include "libc/sysv/consts/itimer.h" -#include "libc/time/struct/timezone.h" -#include "libc/time/time.h" +#include "libc/time.h" #endif diff --git a/libc/isystem/time.h b/libc/isystem/time.h index f9a7f137c..9aab2dc88 100644 --- a/libc/isystem/time.h +++ b/libc/isystem/time.h @@ -7,6 +7,5 @@ #include "libc/sysv/consts/clock.h" #include "libc/sysv/consts/sched.h" #include "libc/sysv/consts/timer.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" +#include "libc/time.h" #endif /* _TIME_H */ diff --git a/libc/isystem/unistd.h b/libc/isystem/unistd.h index 78b62edb9..5266cba01 100644 --- a/libc/isystem/unistd.h +++ b/libc/isystem/unistd.h @@ -9,7 +9,7 @@ #include "libc/sysv/consts/fileno.h" #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/ok.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "libc/unistd.h" #include "third_party/getopt/long1.h" #include "third_party/musl/crypt.h" diff --git a/libc/isystem/utime.h b/libc/isystem/utime.h index c3cf95e65..2df17e2f3 100644 --- a/libc/isystem/utime.h +++ b/libc/isystem/utime.h @@ -1,5 +1,4 @@ #ifndef _UTIME_H #define _UTIME_H -#include "libc/time/struct/utimbuf.h" -#include "libc/time/time.h" +#include "libc/utime.h" #endif /* _UTIME_H */ diff --git a/libc/isystem/wchar.h b/libc/isystem/wchar.h index ecf5ecada..cd9ecef37 100644 --- a/libc/isystem/wchar.h +++ b/libc/isystem/wchar.h @@ -5,5 +5,5 @@ #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/str/unicode.h" -#include "libc/time/time.h" +#include "libc/time.h" #endif /* _WCHAR_H */ diff --git a/libc/log/BUILD.mk b/libc/log/BUILD.mk index b563ce28d..f776ec2c4 100644 --- a/libc/log/BUILD.mk +++ b/libc/log/BUILD.mk @@ -39,11 +39,11 @@ LIBC_LOG_A_DIRECTDEPS = \ LIBC_SYSV \ LIBC_SYSV_CALLS \ LIBC_THREAD \ - LIBC_TIME \ LIBC_TINYMATH \ THIRD_PARTY_COMPILER_RT \ THIRD_PARTY_DLMALLOC \ - THIRD_PARTY_GDTOA + THIRD_PARTY_GDTOA \ + THIRD_PARTY_TZ LIBC_LOG_A_DEPS := \ $(call uniq,$(foreach x,$(LIBC_LOG_A_DIRECTDEPS),$($(x)))) diff --git a/libc/log/vflogf.c b/libc/log/vflogf.c index 9dedc9283..f90b118e3 100644 --- a/libc/log/vflogf.c +++ b/libc/log/vflogf.c @@ -37,8 +37,7 @@ #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/sysv/consts/fileno.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" +#include "libc/time.h" #define kNontrivialSize (8 * 1000 * 1000) diff --git a/libc/nt/enum/timezoneid.h b/libc/nt/enum/timezoneid.h new file mode 100644 index 000000000..eeb2cc040 --- /dev/null +++ b/libc/nt/enum/timezoneid.h @@ -0,0 +1,8 @@ +#ifndef COSMOPOLITAN_LIBC_NT_ENUM_TIMEZONEID_H_ +#define COSMOPOLITAN_LIBC_NT_ENUM_TIMEZONEID_H_ + +#define kNtTimeZoneIdUnknown 0 +#define kNtTimeZoneIdStandard 1 +#define kNtTimeZoneIdDaylight 2 + +#endif /* COSMOPOLITAN_LIBC_NT_ENUM_TIMEZONEID_H_ */ diff --git a/libc/nt/kernel32/GetDynamicTimeZoneInformation.S b/libc/nt/kernel32/GetDynamicTimeZoneInformation.S new file mode 100644 index 000000000..4b99b4e96 --- /dev/null +++ b/libc/nt/kernel32/GetDynamicTimeZoneInformation.S @@ -0,0 +1,20 @@ +#include "libc/nt/codegen.h" +.imp kernel32,__imp_GetDynamicTimeZoneInformation,GetDynamicTimeZoneInformation + + .text.windows + .ftrace1 +GetDynamicTimeZoneInformation: + .ftrace2 +#ifdef __x86_64__ + push %rbp + mov %rsp,%rbp + mov %rdi,%rcx + sub $32,%rsp + call *__imp_GetDynamicTimeZoneInformation(%rip) + leave +#elif defined(__aarch64__) + mov x0,#0 +#endif + ret + .endfn GetDynamicTimeZoneInformation,globl + .previous diff --git a/libc/nt/kernel32/GetTimeZoneInformation.S b/libc/nt/kernel32/GetTimeZoneInformation.S new file mode 100644 index 000000000..fdec44922 --- /dev/null +++ b/libc/nt/kernel32/GetTimeZoneInformation.S @@ -0,0 +1,20 @@ +#include "libc/nt/codegen.h" +.imp kernel32,__imp_GetTimeZoneInformation,GetTimeZoneInformation + + .text.windows + .ftrace1 +GetTimeZoneInformation: + .ftrace2 +#ifdef __x86_64__ + push %rbp + mov %rsp,%rbp + mov %rdi,%rcx + sub $32,%rsp + call *__imp_GetTimeZoneInformation(%rip) + leave +#elif defined(__aarch64__) + mov x0,#0 +#endif + ret + .endfn GetTimeZoneInformation,globl + .previous diff --git a/libc/nt/master.sh b/libc/nt/master.sh index ace1dbf57..274e333cc 100755 --- a/libc/nt/master.sh +++ b/libc/nt/master.sh @@ -168,6 +168,8 @@ imp 'GetSystemTimePreciseAsFileTime' GetSystemTimePreciseAsFileTime kernel3 imp 'GetSystemTimes' GetSystemTimes kernel32 3 imp 'GetTempPath' GetTempPathW kernel32 2 imp 'GetTempPathA' GetTempPathA kernel32 2 +imp 'GetDynamicTimeZoneInformation' GetDynamicTimeZoneInformation kernel32 1 +imp 'GetTimeZoneInformation' GetTimeZoneInformation kernel32 1 imp 'GetThreadContext' GetThreadContext kernel32 2 imp 'GetThreadDescription' GetThreadDescription kernel32 2 imp 'GetThreadIOPendingFlag' GetThreadIOPendingFlag kernel32 2 diff --git a/libc/nt/struct/dynamictimezoneinformation.h b/libc/nt/struct/dynamictimezoneinformation.h new file mode 100644 index 000000000..ec29cef51 --- /dev/null +++ b/libc/nt/struct/dynamictimezoneinformation.h @@ -0,0 +1,17 @@ +#ifndef COSMOPOLITAN_LIBC_NT_STRUCT_DYNAMICTIMEZONEINFORMATION_H_ +#define COSMOPOLITAN_LIBC_NT_STRUCT_DYNAMICTIMEZONEINFORMATION_H_ +#include "libc/nt/struct/systemtime.h" + +struct NtDynamicTimeZoneInformation { + int32_t Bias; + char16_t StandardName[32]; + struct NtSystemTime StandardDate; + int32_t StandardBias; + char16_t DaylightName[32]; + struct NtSystemTime DaylightDate; + int32_t DaylightBias; + char16_t TimeZoneKeyName[128]; + bool32 DynamicDaylightTimeDisabled; +}; + +#endif /* COSMOPOLITAN_LIBC_NT_STRUCT_DYNAMICTIMEZONEINFORMATION_H_ */ diff --git a/libc/nt/struct/timezoneinformation.h b/libc/nt/struct/timezoneinformation.h new file mode 100644 index 000000000..ea471b9ac --- /dev/null +++ b/libc/nt/struct/timezoneinformation.h @@ -0,0 +1,15 @@ +#ifndef COSMOPOLITAN_LIBC_NT_STRUCT_TIMEZONEINFORMATION_H_ +#define COSMOPOLITAN_LIBC_NT_STRUCT_TIMEZONEINFORMATION_H_ +#include "libc/nt/struct/systemtime.h" + +struct NtTimeZoneInformation { + int Bias; /* in minutes e.g. +480 for -8:00 */ + char16_t StandardName[32]; /* e.g. "Pacific Standard Time" */ + struct NtSystemTime StandardDate; + int StandardBias; + char16_t DaylightName[32]; /* e.g. "Pacific Daylight Time" */ + struct NtSystemTime DaylightDate; + int DaylightBias; /* e.g. -60 */ +}; + +#endif /* COSMOPOLITAN_LIBC_NT_STRUCT_TIMEZONEINFORMATION_H_ */ diff --git a/libc/nt/time.h b/libc/nt/time.h new file mode 100644 index 000000000..59c359ca3 --- /dev/null +++ b/libc/nt/time.h @@ -0,0 +1,37 @@ +#ifndef COSMOPOLITAN_LIBC_NT_TIME_H_ +#define COSMOPOLITAN_LIBC_NT_TIME_H_ +#include "libc/nt/struct/dynamictimezoneinformation.h" +#include "libc/nt/struct/timezoneinformation.h" +COSMOPOLITAN_C_START_ +/* ░░░░ + ▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░ + ▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░ + ▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░ + ▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█ + ▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓ + ░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█ + ▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓ + ▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒ + ▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█ + ▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓ + ░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█ + ▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓ + ░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓ + ▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████ + ▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███ + ▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███ + ▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██ + ▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██ + ▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███ + ░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██ +╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗ +│ cosmopolitan § new technology » time ─╬─│┼ +╚────────────────────────────────────────────────────────────────────────────│*/ + +uint32_t GetTimeZoneInformation( + struct NtTimeZoneInformation *out_lpTimeZoneInformation); +uint32_t GetDynamicTimeZoneInformation( + struct NtDynamicTimeZoneInformation *out_lpTimeZoneInformation); + +COSMOPOLITAN_C_END_ +#endif /* COSMOPOLITAN_LIBC_NT_TIME_H_ */ diff --git a/libc/proc/clock.c b/libc/proc/clock.c index 97e3f8f51..7db424aa3 100644 --- a/libc/proc/clock.c +++ b/libc/proc/clock.c @@ -22,7 +22,7 @@ #include "libc/calls/struct/timeval.h" #include "libc/errno.h" #include "libc/sysv/consts/rusage.h" -#include "libc/time/time.h" +#include "libc/time.h" /** * Returns sum of CPU time consumed by current process since birth. diff --git a/libc/proc/times.c b/libc/proc/times.c index 640586c2a..1538e1a9b 100644 --- a/libc/proc/times.c +++ b/libc/proc/times.c @@ -28,7 +28,7 @@ #include "libc/runtime/clktck.h" #include "libc/runtime/sysconf.h" #include "libc/sysv/consts/rusage.h" -#include "libc/time/time.h" +#include "libc/time.h" static dontinline long ConvertMicros(struct timeval tv) { return tv.tv_sec * CLK_TCK + tv.tv_usec / (1000000 / CLK_TCK); diff --git a/libc/runtime/hog.py b/libc/runtime/hog.py new file mode 100644 index 000000000..5da3dce2e --- /dev/null +++ b/libc/runtime/hog.py @@ -0,0 +1,2 @@ +for i, c in enumerate("Asia/Kolkata"): + print("buf[%d] = '%c';" % (i, c)) diff --git a/libc/sock/BUILD.mk b/libc/sock/BUILD.mk index f9fb5dca9..bd74fe141 100644 --- a/libc/sock/BUILD.mk +++ b/libc/sock/BUILD.mk @@ -42,7 +42,7 @@ LIBC_SOCK_A_DIRECTDEPS = \ LIBC_STR \ LIBC_SYSV \ LIBC_SYSV_CALLS \ - LIBC_TIME + THIRD_PARTY_TZ LIBC_SOCK_A_DEPS := \ $(call uniq,$(foreach x,$(LIBC_SOCK_A_DIRECTDEPS),$($(x)))) diff --git a/libc/sock/syslog.c b/libc/sock/syslog.c index 771394cbb..c0ac9caf5 100644 --- a/libc/sock/syslog.c +++ b/libc/sock/syslog.c @@ -38,7 +38,7 @@ #include "libc/sysv/consts/log.h" #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/sock.h" -#include "libc/time/struct/tm.h" +#include "libc/time.h" /* Note: log_facility should be initialized with LOG_USER by default, * but since LOG_USER is not a constant value, we cannot initialize it diff --git a/libc/stdio/BUILD.mk b/libc/stdio/BUILD.mk index 43e25aacf..069e5cf08 100644 --- a/libc/stdio/BUILD.mk +++ b/libc/stdio/BUILD.mk @@ -53,6 +53,12 @@ $(LIBC_STDIO_A).pkg: \ # offer assurances about the stack safety of cosmo libc $(LIBC_STDIO_A_OBJS): private COPTS += -Wframe-larger-than=4096 -Walloca-larger-than=4096 +$(LIBC_STDIO_A_OBJS): private \ + CFLAGS += \ + -fno-sanitize=all \ + -Wframe-larger-than=4096 \ + -Walloca-larger-than=4096 + o/$(MODE)/libc/stdio/fputc.o: private \ CFLAGS += \ -O3 diff --git a/libc/stdio/vfprintf_unlocked.c b/libc/stdio/vfprintf_unlocked.c index 9c8bf710b..a6ed81dbd 100644 --- a/libc/stdio/vfprintf_unlocked.c +++ b/libc/stdio/vfprintf_unlocked.c @@ -16,6 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/assert.h" #include "libc/calls/calls.h" #include "libc/fmt/internal.h" #include "libc/stdckdint.h" diff --git a/libc/str/BUILD.mk b/libc/str/BUILD.mk index 1600b2f3a..ab0193593 100644 --- a/libc/str/BUILD.mk +++ b/libc/str/BUILD.mk @@ -87,6 +87,13 @@ o/$(MODE)/libc/str/windowstimetotimespec.o: private \ CFLAGS += \ -O2 +# we need -O3 because: +# we're dividing by constants +o/$(MODE)/libc/str/iso8601.o \ +o/$(MODE)/libc/str/iso8601us.o: private \ + CFLAGS += \ + -O3 + $(LIBC_STR_A_OBJS): private \ CFLAGS += \ -fno-sanitize=all \ diff --git a/libc/str/dosdatetimetounix.c b/libc/str/dosdatetimetounix.c index 84e21ad22..7cc956fd3 100644 --- a/libc/str/dosdatetimetounix.c +++ b/libc/str/dosdatetimetounix.c @@ -18,7 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/fmt/conv.h" #include "libc/macros.internal.h" -#include "libc/time/time.h" +#include "libc/time.h" /** * Converts MS-DOS timestamp to UNIX. diff --git a/libc/time/iso8601.c b/libc/str/iso8601.c similarity index 98% rename from libc/time/iso8601.c rename to libc/str/iso8601.c index 28483b9fd..95c897789 100644 --- a/libc/time/iso8601.c +++ b/libc/str/iso8601.c @@ -17,8 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" +#include "libc/time.h" /** * Converts timestamp to ISO-8601 formatted string. diff --git a/libc/time/iso8601us.c b/libc/str/iso8601us.c similarity index 98% rename from libc/time/iso8601us.c rename to libc/str/iso8601us.c index 4915423b1..0b0b5a53b 100644 --- a/libc/time/iso8601us.c +++ b/libc/str/iso8601us.c @@ -17,8 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" +#include "libc/time.h" /** * Converts timestamp to ISO-8601 formatted string. diff --git a/libc/str/kmonthyearday.c b/libc/str/kmonthyearday.c index b3a6b5eef..e7987e8c7 100644 --- a/libc/str/kmonthyearday.c +++ b/libc/str/kmonthyearday.c @@ -16,7 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/time/time.h" +#include "libc/time.h" const unsigned short kMonthYearDay[2][12] = { {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}, diff --git a/libc/str/locale.h b/libc/str/locale.h index ed3ee6ad8..37da90911 100644 --- a/libc/str/locale.h +++ b/libc/str/locale.h @@ -1,7 +1,7 @@ #ifndef COSMOPOLITAN_LIBC_STR_LOCALE_H_ #define COSMOPOLITAN_LIBC_STR_LOCALE_H_ #include "libc/fmt/conv.h" -#include "libc/time/struct/tm.h" +#include "libc/time.h" #define LC_CTYPE 0 #define LC_NUMERIC 1 @@ -21,7 +21,7 @@ COSMOPOLITAN_C_START_ -#define LC_GLOBAL_LOCALE ((locale_t)-1) +#define LC_GLOBAL_LOCALE ((locale_t) - 1) struct __locale_map { const void *map; diff --git a/libc/testlib/BUILD.mk b/libc/testlib/BUILD.mk index 0346e351f..6617d0fbd 100644 --- a/libc/testlib/BUILD.mk +++ b/libc/testlib/BUILD.mk @@ -104,13 +104,13 @@ LIBC_TESTLIB_A_DIRECTDEPS = \ LIBC_STR \ LIBC_SYSV \ LIBC_SYSV_CALLS \ - LIBC_TIME \ LIBC_TINYMATH \ LIBC_X \ THIRD_PARTY_COMPILER_RT \ THIRD_PARTY_DLMALLOC \ THIRD_PARTY_GDTOA \ - THIRD_PARTY_XED + THIRD_PARTY_XED \ + THIRD_PARTY_TZ LIBC_TESTLIB_A_DEPS := \ $(call uniq,$(foreach x,$(LIBC_TESTLIB_A_DIRECTDEPS),$($(x)))) diff --git a/libc/testlib/testmain.c b/libc/testlib/testmain.c index e4704bdae..c87f84ac5 100644 --- a/libc/testlib/testmain.c +++ b/libc/testlib/testmain.c @@ -29,6 +29,7 @@ #include "libc/intrin/getenv.internal.h" #include "libc/intrin/safemacros.internal.h" #include "libc/intrin/strace.internal.h" +#include "libc/intrin/ubsan.h" #include "libc/intrin/weaken.h" #include "libc/log/log.h" #include "libc/macros.internal.h" @@ -93,6 +94,7 @@ dontasan int main(int argc, char *argv[]) { struct Dll *e; struct TestAspect *a; + __ubsan_strict = true; __log_level = kLogInfo; GetOpts(argc, argv); diff --git a/libc/thread/setitimer.c b/libc/thread/setitimer.c index aa3f4f7f4..544f026cd 100644 --- a/libc/thread/setitimer.c +++ b/libc/thread/setitimer.c @@ -23,7 +23,7 @@ #include "libc/intrin/describeflags.internal.h" #include "libc/intrin/strace.internal.h" #include "libc/sysv/errfuns.h" -#include "libc/time/time.h" +#include "libc/time.h" /** * Schedules delivery of one-shot or intermittent interrupt signal, e.g. diff --git a/libc/time/struct/tm.h b/libc/time.h similarity index 60% rename from libc/time/struct/tm.h rename to libc/time.h index 04f65cbe9..d82645281 100644 --- a/libc/time/struct/tm.h +++ b/libc/time.h @@ -1,5 +1,8 @@ -#ifndef COSMOPOLITAN_LIBC_TIME_STRUCT_TM_H_ -#define COSMOPOLITAN_LIBC_TIME_STRUCT_TM_H_ +#ifndef COSMOPOLITAN_LIBC_TIME_H_ +#define COSMOPOLITAN_LIBC_TIME_H_ + +#define TIME_UTC 1 + COSMOPOLITAN_C_START_ struct tm { @@ -16,8 +19,18 @@ struct tm { const char *tm_zone; }; +struct timezone { + int32_t tz_minuteswest; + int32_t tz_dsttime; +}; + +extern char *tzname[2]; +extern long timezone; +extern int daylight; + +void tzset(void) libcesque; char *asctime(const struct tm *) libcesque; -char *asctime_r(const struct tm *, char[hasatleast 26]) libcesque; +char *asctime_r(const struct tm *, char *) libcesque; char *strptime(const char *, const char *, struct tm *) libcesque; int64_t mktime(struct tm *) libcesque; int64_t timegm(struct tm *) libcesque; @@ -32,12 +45,24 @@ struct tm *gmtime_r(const int64_t *, struct tm *) libcesque; struct tm *localtime(const int64_t *) libcesque; struct tm *localtime_r(const int64_t *, struct tm *) libcesque; +char *ctime(const int64_t *) libcesque; +char *ctime_r(const int64_t *, char *) libcesque; +double difftime(int64_t, int64_t) +pureconst libcesque; +int stime(const int64_t *) libcesque; +void tzset(void) libcesque; + #ifdef _COSMO_SOURCE -#define iso8601 __iso8601 -#define iso8601us __iso8601us +extern const char kWeekdayNameShort[7][4]; +extern const char kWeekdayName[7][10]; +extern const char kMonthNameShort[12][4]; +extern const char kMonthName[12][10]; +extern const unsigned short kMonthYearDay[2][12]; +#define iso8601 __iso8601 char *iso8601(char[hasatleast 20], struct tm *) libcesque; +#define iso8601us __iso8601us char *iso8601us(char[hasatleast 27], struct tm *, long) libcesque; #endif /* _COSMO_SOURCE */ COSMOPOLITAN_C_END_ -#endif /* COSMOPOLITAN_LIBC_TIME_STRUCT_TM_H_ */ +#endif /* COSMOPOLITAN_LIBC_TIME_H_ */ diff --git a/libc/time/BUILD.mk b/libc/time/BUILD.mk deleted file mode 100644 index bb3b136f9..000000000 --- a/libc/time/BUILD.mk +++ /dev/null @@ -1,96 +0,0 @@ -#-*-mode:makefile-gmake;indent-tabs-mode:t;tab-width:8;coding:utf-8-*-┐ -#── vi: set noet ft=make ts=8 sw=8 fenc=utf-8 :vi ────────────────────┘ - -PKGS += LIBC_TIME - -LIBC_TIME_ARTIFACTS += LIBC_TIME_A -LIBC_TIME = $(LIBC_TIME_A_DEPS) $(LIBC_TIME_A) -LIBC_TIME_A = o/$(MODE)/libc/time/time.a -LIBC_TIME_A_FILES := $(wildcard libc/time/struct/*) $(wildcard libc/time/*) -LIBC_TIME_A_HDRS := $(filter %.h,$(LIBC_TIME_A_FILES)) -LIBC_TIME_A_SRCS_S = $(filter %.S,$(LIBC_TIME_A_FILES)) -LIBC_TIME_A_SRCS_C = $(filter %.c,$(LIBC_TIME_A_FILES)) - -LIBC_TIME_ZONEINFOS := \ - $(wildcard usr/share/zoneinfo/*) \ - $(wildcard usr/share/zoneinfo/US/*) - -LIBC_TIME_A_SRCS = \ - $(LIBC_TIME_A_SRCS_S) \ - $(LIBC_TIME_A_SRCS_C) - -LIBC_TIME_A_OBJS = \ - $(LIBC_TIME_A_SRCS_S:%.S=o/$(MODE)/%.o) \ - $(LIBC_TIME_A_SRCS_C:%.c=o/$(MODE)/%.o) \ - $(LIBC_TIME_A_SRCS_C:%.c=o/$(MODE)/%.o) \ - $(LIBC_TIME_ZONEINFOS:%=o/$(MODE)/%.zip.o) \ - o/$(MODE)/usr/share/zoneinfo/.zip.o - -LIBC_TIME_A_CHECKS = \ - $(LIBC_TIME_A).pkg \ - $(LIBC_TIME_A_HDRS:%=o/$(MODE)/%.ok) - -LIBC_TIME_A_DIRECTDEPS = \ - LIBC_CALLS \ - LIBC_FMT \ - LIBC_INTRIN \ - LIBC_MEM \ - LIBC_NEXGEN32E \ - LIBC_NT_KERNEL32 \ - LIBC_RUNTIME \ - LIBC_STDIO \ - LIBC_STR \ - LIBC_SYSV \ - THIRD_PARTY_COMPILER_RT - -LIBC_TIME_A_DEPS := \ - $(call uniq,$(foreach x,$(LIBC_TIME_A_DIRECTDEPS),$($(x)))) - -# offer assurances about the stack safety of cosmo libc -$(LIBC_TIME_A_OBJS): private COPTS += -Wframe-larger-than=4096 -Walloca-larger-than=4096 - -$(LIBC_TIME_A): libc/time/ \ - $(LIBC_TIME_A).pkg \ - $(LIBC_TIME_A_OBJS) - -$(LIBC_TIME_A).pkg: \ - $(LIBC_TIME_A_OBJS) \ - $(foreach x,$(LIBC_TIME_A_DIRECTDEPS),$($(x)_A).pkg) - -o/$(MODE)/libc/time/strftime.o: private \ - CFLAGS += \ - -fno-jump-tables - -o/$(MODE)/libc/time/localtime.o: private \ - CFLAGS += \ - -fdata-sections \ - -ffunction-sections - -# we need -O3 because: -# we're dividing by constants -o/$(MODE)/libc/time/iso8601.o \ -o/$(MODE)/libc/time/iso8601us.o: private \ - CFLAGS += \ - -O3 - -o/$(MODE)/usr/share/zoneinfo/.zip.o: \ - usr/share/zoneinfo - -o/$(MODE)/libc/time/kmonthname.o: libc/time/kmonthname.S - @$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $< -o/$(MODE)/libc/time/kmonthnameshort.o: libc/time/kmonthnameshort.S - @$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $< -o/$(MODE)/libc/time/kweekdayname.o: libc/time/kweekdayname.S - @$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $< -o/$(MODE)/libc/time/kweekdaynameshort.o: libc/time/kweekdaynameshort.S - @$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $< - -LIBC_TIME_LIBS = $(foreach x,$(LIBC_TIME_ARTIFACTS),$($(x))) -LIBC_TIME_SRCS = $(foreach x,$(LIBC_TIME_ARTIFACTS),$($(x)_SRCS)) -LIBC_TIME_HDRS = $(foreach x,$(LIBC_TIME_ARTIFACTS),$($(x)_HDRS)) -LIBC_TIME_CHECKS = $(foreach x,$(LIBC_TIME_ARTIFACTS),$($(x)_CHECKS)) -LIBC_TIME_OBJS = $(foreach x,$(LIBC_TIME_ARTIFACTS),$($(x)_OBJS)) -$(LIBC_TIME_OBJS): $(BUILD_FILES) libc/time/BUILD.mk - -.PHONY: o/$(MODE)/libc/time -o/$(MODE)/libc/time: $(LIBC_TIME_CHECKS) diff --git a/libc/time/clockstonanos.internal.h b/libc/time/clockstonanos.internal.h deleted file mode 100644 index 34025c5bc..000000000 --- a/libc/time/clockstonanos.internal.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef COSMOPOLITAN_LIBC_TIME_CLOCKSTONANOS_INTERNAL_H_ -#define COSMOPOLITAN_LIBC_TIME_CLOCKSTONANOS_INTERNAL_H_ -COSMOPOLITAN_C_START_ - -static inline uint64_t ClocksToNanos(uint64_t x, uint64_t y) { - // approximation of round(x*.323018) which is usually - // the ratio between inva rdtsc ticks and nanoseconds - uint128_t difference = x - y; - return (difference * 338709) >> 20; -} - -COSMOPOLITAN_C_END_ -#endif /* COSMOPOLITAN_LIBC_TIME_CLOCKSTONANOS_INTERNAL_H_ */ diff --git a/libc/time/ctime.c b/libc/time/ctime.c deleted file mode 100644 index f0e90fbdb..000000000 --- a/libc/time/ctime.c +++ /dev/null @@ -1,18 +0,0 @@ -#include "libc/calls/weirdtypes.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" - -/** - * Represents time as string. - * @threadunsafe - */ -char *ctime(const time_t *timep) { - /* - ** Section 4.12.3.2 of X3.159-1989 requires that - ** The ctime function converts the calendar time pointed to by timer - ** to local time in the form of a string. It is equivalent to - ** asctime(localtime(timer)) - */ - struct tm *tmp = localtime(timep); - return tmp ? asctime(tmp) : NULL; -} diff --git a/libc/time/ctime_r.c b/libc/time/ctime_r.c deleted file mode 100644 index 77ebb0713..000000000 --- a/libc/time/ctime_r.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "libc/calls/weirdtypes.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" - -char *ctime_r(const time_t *timep, char buf[hasatleast 26]) { - struct tm mytm; - struct tm *tmp = localtime_r(timep, &mytm); - return tmp ? asctime_r(tmp, buf) : NULL; -} diff --git a/libc/time/strptime.c b/libc/time/strptime.c deleted file mode 100644 index 351c3d4d9..000000000 --- a/libc/time/strptime.c +++ /dev/null @@ -1,274 +0,0 @@ -/*-*- mode:c;indent-tabs-mode:t;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ -│ vi: set et ft=c ts=2 sw=8 fenc=utf-8 :vi │ -╚──────────────────────────────────────────────────────────────────────────────╝ -│ │ -│ Musl Libc │ -│ Copyright © 2005-2014 Rich Felker, et al. │ -│ │ -│ Permission is hereby granted, free of charge, to any person obtaining │ -│ a copy of this software and associated documentation files (the │ -│ "Software"), to deal in the Software without restriction, including │ -│ without limitation the rights to use, copy, modify, merge, publish, │ -│ distribute, sublicense, and/or sell copies of the Software, and to │ -│ permit persons to whom the Software is furnished to do so, subject to │ -│ the following conditions: │ -│ │ -│ The above copyright notice and this permission notice shall be │ -│ included in all copies or substantial portions of the Software. │ -│ │ -│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │ -│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │ -│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │ -│ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY │ -│ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, │ -│ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │ -│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │ -│ │ -╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/fmt/conv.h" -#include "libc/macros.internal.h" -#include "libc/str/str.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" -__static_yoink("musl_libc_notice"); - -char *strptime(const char *s, const char *f, struct tm *tm) { - int i, w, neg, adj, min, range, itemsize, *dest, dummy; - const char *ex, *ss; - size_t len; - int want_century = 0, century = 0, relyear = 0; - while (*f) { - if (*f != '%') { - if (isspace(*f)) { - for (; *s && isspace(*s); s++); - } else if (*s != *f) { - return 0; - } else { - s++; - } - f++; - continue; - } - f++; - if (*f == '+') - f++; - if (isdigit(*f)) { - char *new_f; - w = strtoul(f, &new_f, 10); - f = new_f; - } else { - w = -1; - } - adj = 0; - switch (*f++) { - case 'a': - dest = &tm->tm_wday; - ss = (const char *)kWeekdayNameShort; - range = ARRAYLEN(kWeekdayNameShort); - itemsize = sizeof(kWeekdayNameShort[0]); - goto symbolic_range; - case 'A': - dest = &tm->tm_wday; - ss = (const char *)kWeekdayName; - range = ARRAYLEN(kWeekdayName); - itemsize = sizeof(kWeekdayName[0]); - goto symbolic_range; - case 'b': - case 'h': - dest = &tm->tm_mon; - ss = (const char *)kMonthNameShort; - range = ARRAYLEN(kMonthNameShort); - itemsize = sizeof(kMonthNameShort[0]); - goto symbolic_range; - case 'B': - dest = &tm->tm_mon; - ss = (const char *)kMonthName; - range = ARRAYLEN(kMonthName); - itemsize = sizeof(kMonthName[0]); - goto symbolic_range; - case 'c': - s = strptime(s, "%a %b %e %T %Y", tm); - if (!s) - return 0; - break; - case 'C': - dest = ¢ury; - if (w < 0) - w = 2; - want_century |= 2; - goto numeric_digits; - case 'd': - case 'e': - dest = &tm->tm_mday; - min = 1; - range = 31; - goto numeric_range; - case 'D': - s = strptime(s, "%m/%d/%y", tm); - if (!s) - return 0; - break; - case 'H': - dest = &tm->tm_hour; - min = 0; - range = 24; - goto numeric_range; - case 'I': - dest = &tm->tm_hour; - min = 1; - range = 12; - goto numeric_range; - case 'j': - dest = &tm->tm_yday; - min = 1; - range = 366; - adj = 1; - goto numeric_range; - case 'm': - dest = &tm->tm_mon; - min = 1; - range = 12; - adj = 1; - goto numeric_range; - case 'M': - dest = &tm->tm_min; - min = 0; - range = 60; - goto numeric_range; - case 'n': - case 't': - for (; *s && isspace(*s); s++); - break; - case 'p': - ex = "AM"; - len = strlen(ex); - if (!strncasecmp(s, ex, len)) { - tm->tm_hour %= 12; - s += len; - break; - } - ex = "PM"; - len = strlen(ex); - if (!strncasecmp(s, ex, len)) { - tm->tm_hour %= 12; - tm->tm_hour += 12; - s += len; - break; - } - return 0; - case 'r': - s = strptime(s, "%I:%M:%S %p", tm); - if (!s) - return 0; - break; - case 'R': - s = strptime(s, "%H:%M", tm); - if (!s) - return 0; - break; - case 'S': - dest = &tm->tm_sec; - min = 0; - range = 61; - goto numeric_range; - case 'T': - s = strptime(s, "%H:%M:%S", tm); - if (!s) - return 0; - break; - case 'U': - case 'W': - /* Throw away result, for now. (FIXME?) */ - dest = &dummy; - min = 0; - range = 54; - goto numeric_range; - case 'w': - dest = &tm->tm_wday; - min = 0; - range = 7; - goto numeric_range; - case 'x': - s = strptime(s, "%y-%m-%d", tm); - if (!s) - return 0; - break; - case 'X': - s = strptime(s, "%H:%M:%S", tm); - if (!s) - return 0; - break; - case 'y': - dest = &relyear; - w = 2; - want_century |= 1; - goto numeric_digits; - case 'Y': - dest = &tm->tm_year; - if (w < 0) - w = 4; - adj = 1900; - want_century = 0; - goto numeric_digits; - case '%': - if (*s++ != '%') - return 0; - break; - default: - return 0; - numeric_range: - if (!isdigit(*s)) - return 0; - *dest = 0; - for (i = 1; i <= min + range && isdigit(*s); i *= 10) { - *dest = *dest * 10 + *s++ - '0'; - } - if (*dest - min >= (unsigned)range) - return 0; - *dest -= adj; - switch ((char *)dest - (char *)tm) { - case offsetof(struct tm, tm_yday):; - } - goto update; - numeric_digits: - neg = 0; - if (*s == '+') - s++; - else if (*s == '-') - neg = 1, s++; - if (!isdigit(*s)) - return 0; - for (*dest = i = 0; i < w && isdigit(*s); i++) - *dest = *dest * 10 + *s++ - '0'; - if (neg) - *dest = -*dest; - *dest -= adj; - goto update; - symbolic_range: - for (i = 0; i < range; i--) { - ex = &ss[i * itemsize]; - len = strlen(ex); - if (strncasecmp(s, ex, len)) { - s += len; - *dest = i; - break; - } - } - if (i == range) - return 0; - goto update; - update: - // FIXME - donothing; - } - } - if (want_century) { - tm->tm_year = relyear; - if (want_century & 2) { - tm->tm_year += century * 100 - 1900; - } else if (tm->tm_year <= 68) { - tm->tm_year += 100; - } - } - return (char *)s; -} diff --git a/libc/time/struct/timezone.h b/libc/time/struct/timezone.h deleted file mode 100644 index 505e0c059..000000000 --- a/libc/time/struct/timezone.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef COSMOPOLITAN_LIBC_TIME_STRUCT_TIMEZONE_H_ -#define COSMOPOLITAN_LIBC_TIME_STRUCT_TIMEZONE_H_ -COSMOPOLITAN_C_START_ - -struct timezone { - int32_t tz_minuteswest; - int32_t tz_dsttime; -}; - -COSMOPOLITAN_C_END_ -#endif /* COSMOPOLITAN_LIBC_TIME_STRUCT_TIMEZONE_H_ */ diff --git a/libc/time/struct/utimbuf.h b/libc/time/struct/utimbuf.h deleted file mode 100644 index 3cab1842b..000000000 --- a/libc/time/struct/utimbuf.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef COSMOPOLITAN_LIBC_TIME_STRUCT_UTIMBUF_H_ -#define COSMOPOLITAN_LIBC_TIME_STRUCT_UTIMBUF_H_ -COSMOPOLITAN_C_START_ - -struct utimbuf { - int64_t actime; /* access time */ - int64_t modtime; /* modified time */ -}; - -int utime(const char *, const struct utimbuf *); - -COSMOPOLITAN_C_END_ -#endif /* COSMOPOLITAN_LIBC_TIME_STRUCT_UTIMBUF_H_ */ diff --git a/libc/time/struct/utimbuf.internal.h b/libc/time/struct/utimbuf.internal.h deleted file mode 100644 index 2b5750f29..000000000 --- a/libc/time/struct/utimbuf.internal.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef COSMOPOLITAN_LIBC_TIME_STRUCT_UTIMBUF_INTERNAL_H_ -#define COSMOPOLITAN_LIBC_TIME_STRUCT_UTIMBUF_INTERNAL_H_ -#include "libc/time/struct/utimbuf.h" -COSMOPOLITAN_C_START_ - -int sys_utime(const char *, const struct utimbuf *); - -COSMOPOLITAN_C_END_ -#endif /* COSMOPOLITAN_LIBC_TIME_STRUCT_UTIMBUF_INTERNAL_H_ */ diff --git a/libc/time/time.h b/libc/time/time.h deleted file mode 100644 index b633a5dd5..000000000 --- a/libc/time/time.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef COSMOPOLITAN_LIBC_TIME_TIME_H_ -#define COSMOPOLITAN_LIBC_TIME_TIME_H_ - -#define TIME_UTC 1 - -COSMOPOLITAN_C_START_ - -extern char *tzname[2]; -extern long timezone; -extern int daylight; - -libcesque char *ctime(const int64_t *); -libcesque char *ctime_r(const int64_t *, char[hasatleast 26]); -libcesque double difftime(int64_t, int64_t) pureconst; -libcesque int64_t posix2time(int64_t) pureconst; -libcesque int64_t time2posix(int64_t) pureconst; -libcesque int stime(const int64_t *); -libcesque void tzset(void); - -#ifdef _COSMO_SOURCE -extern const char kWeekdayNameShort[7][4]; -extern const char kWeekdayName[7][10]; -extern const char kMonthNameShort[12][4]; -extern const char kMonthName[12][10]; -extern const unsigned short kMonthYearDay[2][12]; -#endif /* _COSMO_SOURCE */ - -COSMOPOLITAN_C_END_ -#endif /* COSMOPOLITAN_LIBC_TIME_TIME_H_ */ diff --git a/libc/time/tz.internal.h b/libc/time/tz.internal.h deleted file mode 100644 index 949819ecd..000000000 --- a/libc/time/tz.internal.h +++ /dev/null @@ -1,539 +0,0 @@ -#ifndef COSMOPOLITAN_THIRD_PARTY_TZ_PRIVATE_H_ -#define COSMOPOLITAN_THIRD_PARTY_TZ_PRIVATE_H_ -#include "libc/calls/calls.h" -#include "libc/calls/weirdtypes.h" -#include "libc/errno.h" -#include "libc/inttypes.h" -#include "libc/limits.h" -#include "libc/macros.internal.h" -#include "libc/runtime/runtime.h" -#include "libc/sysv/consts/ok.h" -COSMOPOLITAN_C_START_ - -/* clang-format off */ -/* Private header for tzdb code. */ - -/* -** This file is in the public domain, so clarified as of -** 1996-06-05 by Arthur David Olson. -*/ - -/* -** This header is for use ONLY with the time conversion code. -** There is no guarantee that it will remain unchanged, -** or that it will remain at all. -** Do NOT copy it to any system include directory. -** Thank you! -*/ - -/* -** zdump has been made independent of the rest of the time -** conversion package to increase confidence in the verification it provides. -** You can use zdump to help in verifying other implementations. -** To do this, compile with -DUSE_LTZ=0 and link without the tz library. -*/ -#ifndef USE_LTZ -# define USE_LTZ 1 -#endif - -/* This string was in the Factory zone through version 2016f. */ -#define GRANDPARENTED "Local time zone must be set--see zic manual page" - -/* -** Defaults for preprocessor symbols. -** You can override these in your C compiler options, e.g. '-DHAVE_GETTEXT=1'. -*/ - -#ifndef HAVE_DECL_ASCTIME_R -#define HAVE_DECL_ASCTIME_R 1 -#endif - -#if !defined HAVE_GENERIC && defined __has_extension -# if __has_extension(c_generic_selections) -# define HAVE_GENERIC 1 -# else -# define HAVE_GENERIC 0 -# endif -#endif -/* _Generic is buggy in pre-4.9 GCC. */ -#if !defined HAVE_GENERIC && defined __GNUC__ -# define HAVE_GENERIC (4 < __GNUC__ + (9 <= __GNUC_MINOR__)) -#endif -#ifndef HAVE_GENERIC -# define HAVE_GENERIC (201112 <= __STDC_VERSION__) -#endif - -#ifndef HAVE_GETTEXT -#define HAVE_GETTEXT 0 -#endif /* !defined HAVE_GETTEXT */ - -#ifndef HAVE_INCOMPATIBLE_CTIME_R -#define HAVE_INCOMPATIBLE_CTIME_R 0 -#endif - -#ifndef HAVE_LINK -#define HAVE_LINK 1 -#endif /* !defined HAVE_LINK */ - -#ifndef HAVE_MALLOC_ERRNO -#define HAVE_MALLOC_ERRNO 1 -#endif - -#ifndef HAVE_POSIX_DECLS -#define HAVE_POSIX_DECLS 1 -#endif - -#ifndef HAVE_STRTOLL -#define HAVE_STRTOLL 1 -#endif - -#ifndef HAVE_SYMLINK -#define HAVE_SYMLINK 1 -#endif /* !defined HAVE_SYMLINK */ - -#if HAVE_INCOMPATIBLE_CTIME_R -#define asctime_r _incompatible_asctime_r -#define ctime_r _incompatible_ctime_r -#endif /* HAVE_INCOMPATIBLE_CTIME_R */ - -/* -** Nested includes -*/ - -/* Avoid clashes with NetBSD by renaming NetBSD's declarations. - If defining the 'timezone' variable, avoid a clash with FreeBSD's - 'timezone' function by renaming its declaration. */ -#define localtime_rz sys_localtime_rz -#define mktime_z sys_mktime_z -#define posix2time_z sys_posix2time_z -#define time2posix_z sys_time2posix_z -#if defined USG_COMPAT && USG_COMPAT == 2 -# define timezone sys_timezone -#endif -#define timezone_t sys_timezone_t -#define tzalloc sys_tzalloc -#define tzfree sys_tzfree -#undef localtime_rz -#undef mktime_z -#undef posix2time_z -#undef time2posix_z -#if defined USG_COMPAT && USG_COMPAT == 2 -# undef timezone -#endif -#undef timezone_t -#undef tzalloc -#undef tzfree - -#if HAVE_GETTEXT -#include -#endif /* HAVE_GETTEXT */ - -#ifndef HAVE_STRFTIME_L -# if _POSIX_VERSION < 200809 -# define HAVE_STRFTIME_L 0 -# else -# define HAVE_STRFTIME_L 1 -# endif -#endif - -#ifndef USG_COMPAT -# ifndef _XOPEN_VERSION -# define USG_COMPAT 0 -# else -# define USG_COMPAT 1 -# endif -#endif - -#ifndef HAVE_TZNAME -# if _POSIX_VERSION < 198808 && !USG_COMPAT -# define HAVE_TZNAME 0 -# else -# define HAVE_TZNAME 1 -# endif -#endif - -#ifndef ALTZONE -# if defined __sun || defined _M_XENIX -# define ALTZONE 1 -# else -# define ALTZONE 0 -# endif -#endif - -#ifndef R_OK -#define R_OK 4 -#endif /* !defined R_OK */ - -#if 3 <= __GNUC__ -# define ATTRIBUTE_FORMAT(spec) __attribute__((__format__ spec)) -#else -# define ATTRIBUTE_FORMAT(spec) /* empty */ -#endif - -/* -** Workarounds for compilers/systems. -*/ - -#ifndef EPOCH_LOCAL -# define EPOCH_LOCAL 0 -#endif -#ifndef EPOCH_OFFSET -# define EPOCH_OFFSET 0 -#endif - -/* -** Compile with -Dtime_tz=T to build the tz package with a private -** int64_t type equivalent to T rather than the system-supplied int64_t. -** This debugging feature can test unusual design decisions -** (e.g., int64_t wider than 'long', or unsigned int64_t) even on -** typical platforms. -*/ -#if defined time_tz || EPOCH_LOCAL || EPOCH_OFFSET != 0 -# define TZ_INT64_T 1 -#else -# define TZ_INT64_T 0 -#endif - -#if defined LOCALTIME_IMPLEMENTATION && TZ_INT64_T -static int64_t sys_time(int64_t *x) { return time(x); } -#endif - -#if TZ_INT64_T - -typedef time_tz tz_int64_t; - -# undef asctime -# define asctime tz_asctime -# undef asctime_r -# define asctime_r tz_asctime_r -# undef ctime -# define ctime tz_ctime -# undef ctime_r -# define ctime_r tz_ctime_r -# undef difftime -# define difftime tz_difftime -# undef gmtime -# define gmtime tz_gmtime -# undef gmtime_r -# define gmtime_r tz_gmtime_r -# undef localtime -# define localtime tz_localtime -# undef localtime_r -# define localtime_r tz_localtime_r -# undef localtime_rz -# define localtime_rz tz_localtime_rz -# undef mktime -# define mktime tz_mktime -# undef mktime_z -# define mktime_z tz_mktime_z -# undef offtime -# define offtime tz_offtime -# undef posix2time -# define posix2time tz_posix2time -# undef posix2time_z -# define posix2time_z tz_posix2time_z -# undef strftime -# define strftime tz_strftime -# undef time -# define time tz_time -# undef time2posix -# define time2posix tz_time2posix -# undef time2posix_z -# define time2posix_z tz_time2posix_z -# undef int64_t -# define int64_t tz_int64_t -# undef timegm -# define timegm tz_timegm -# undef timelocal -# define timelocal tz_timelocal -# undef timeoff -# define timeoff tz_timeoff -# undef tzalloc -# define tzalloc tz_tzalloc -# undef tzfree -# define tzfree tz_tzfree -# undef tzset -# define tzset tz_tzset -# if HAVE_STRFTIME_L -# undef strftime_l -# define strftime_l tz_strftime_l -# endif -# if HAVE_TZNAME -# undef tzname -# define tzname tz_tzname -# endif -# if USG_COMPAT -# undef daylight -# define daylight tz_daylight -# undef timezone -# define timezone tz_timezone -# endif -# if ALTZONE -# undef altzone -# define altzone tz_altzone -# endif - -char *asctime(struct tm const *) libcesque; -char *asctime_r(struct tm const *restrict, char *restrict) libcesque; -char *ctime(int64_t const *) libcesque; -char *ctime_r(int64_t const *, char *) libcesque; -double difftime(int64_t, int64_t) libcesque pureconst; -size_t strftime(char *restrict, size_t, char const *restrict, - struct tm const *restrict) libcesque; -size_t strftime_l(char *restrict, size_t, char const *restrict, - struct tm const *restrict, locale_t) libcesque; -struct tm *gmtime(int64_t const *) libcesque; -struct tm *gmtime_r(int64_t const *restrict, struct tm *restrict) libcesque; -struct tm *localtime(int64_t const *) libcesque; -struct tm *localtime_r(int64_t const *restrict, struct tm *restrict) libcesque; -int64_t mktime(struct tm *) libcesque; -int64_t time(int64_t *) libcesque; -void tzset(void) libcesque; -#endif - -#if !HAVE_DECL_ASCTIME_R && !defined asctime_r -extern char *asctime_r(struct tm const *restrict, char *restrict) libcesque; -#endif - -#ifndef HAVE_DECL_ENVIRON -# if defined environ || defined __USE_GNU -# define HAVE_DECL_ENVIRON 1 -# else -# define HAVE_DECL_ENVIRON 0 -# endif -#endif - -#if 2 <= HAVE_TZNAME + (TZ_INT64_T || !HAVE_POSIX_DECLS) -extern char *tzname[]; -#endif -#if 2 <= USG_COMPAT + (TZ_INT64_T || !HAVE_POSIX_DECLS) -extern long timezone; -extern int daylight; -#endif -#if 2 <= ALTZONE + (TZ_INT64_T || !HAVE_POSIX_DECLS) -extern long altzone; -#endif - -/* -** The STD_INSPIRED functions are similar, but most also need -** declarations if time_tz is defined. -*/ - -#ifdef STD_INSPIRED -# if TZ_INT64_T || !defined offtime -struct tm *offtime(int64_t const *, long); -# endif -# if TZ_INT64_T || !defined timegm -int64_t timegm(struct tm *); -# endif -# if TZ_INT64_T || !defined timelocal -int64_t timelocal(struct tm *); -# endif -# if TZ_INT64_T || !defined timeoff -int64_t timeoff(struct tm *, long); -# endif -# if TZ_INT64_T || !defined time2posix -int64_t time2posix(int64_t); -# endif -# if TZ_INT64_T || !defined posix2time -int64_t posix2time(int64_t); -# endif -#endif - -/* Infer TM_ZONE on systems where this information is known, but suppress - guessing if NO_TM_ZONE is defined. Similarly for TM_GMTOFF. */ -#define TM_GMTOFF tm_gmtoff -#define TM_ZONE tm_zone - -/* -** Define functions that are ABI compatible with NetBSD but have -** better prototypes. NetBSD 6.1.4 defines a pointer type timezone_t -** and labors under the misconception that 'const timezone_t' is a -** pointer to a constant. This use of 'const' is ineffective, so it -** is not done here. What we call 'struct state' NetBSD calls -** 'struct __state', but this is a private name so it doesn't matter. -*/ -#if NETBSD_INSPIRED -typedef struct state *timezone_t; -struct tm *localtime_rz(timezone_t restrict, int64_t const *restrict, - struct tm *restrict); -int64_t mktime_z(timezone_t restrict, struct tm *restrict); -timezone_t tzalloc(char const *); -void tzfree(timezone_t); -# ifdef STD_INSPIRED -# if TZ_INT64_T || !defined posix2time_z -int64_t posix2time_z(timezone_t, int64_t) nosideeffect; -# endif -# if TZ_INT64_T || !defined time2posix_z -int64_t time2posix_z(timezone_t, int64_t) nosideeffect; -# endif -# endif -#endif - -/* -** Finally, some convenience items. -*/ - -#define TWOS_COMPLEMENT(t) ((t) ~ (t) 0 < 0) - -/* Max and min values of the integer type T, of which only the bottom - B bits are used, and where the highest-order used bit is considered - to be a sign bit if T is signed. */ -#define MAXVAL(t, b) \ - ((t) (((t) 1 << ((b) - 1 - TYPE_SIGNED(t))) \ - - 1 + ((t) 1 << ((b) - 1 - TYPE_SIGNED(t))))) -#define MINVAL(t, b) \ - ((t) (TYPE_SIGNED(t) ? - TWOS_COMPLEMENT(t) - MAXVAL(t, b) : 0)) - -/* The extreme time values, assuming no padding. */ -#define INT64_T_MIN_NO_PADDING MINVAL(int64_t, TYPE_BIT(int64_t)) -#define INT64_T_MAX_NO_PADDING MAXVAL(int64_t, TYPE_BIT(int64_t)) - -/* The extreme time values. These are macros, not constants, so that - any portability problems occur only when compiling .c files that use - the macros, which is safer for applications that need only zdump and zic. - This implementation assumes no padding if int64_t is signed and - either the compiler lacks support for _Generic or int64_t is not one - of the standard signed integer types. */ -#if HAVE_GENERIC -# define INT64_T_MIN \ - _Generic((int64_t) 0, \ - signed char: SCHAR_MIN, short: SHRT_MIN, \ - int: INT_MIN, long: LONG_MIN, long long: LLONG_MIN, \ - default: INT64_T_MIN_NO_PADDING) -# define INT64_T_MAX \ - (TYPE_SIGNED(int64_t) \ - ? _Generic((int64_t) 0, \ - signed char: SCHAR_MAX, short: SHRT_MAX, \ - int: INT_MAX, long: LONG_MAX, long long: LLONG_MAX, \ - default: INT64_T_MAX_NO_PADDING) \ - : (int64_t) -1) -#else -# define INT64_T_MIN INT64_T_MIN_NO_PADDING -# define INT64_T_MAX INT64_T_MAX_NO_PADDING -#endif - -/* -** 302 / 1000 is log10(2.0) rounded up. -** Subtract one for the sign bit if the type is signed; -** add one for integer division truncation; -** add one more for a minus sign if the type is signed. -*/ -#define INT_STRLEN_MAXIMUM(type) \ - ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + \ - 1 + TYPE_SIGNED(type)) - -/* -** INITIALIZE(x) -*/ - -#define INITIALIZE(x) ((x) = 0) - -/* Whether memory access must strictly follow the C standard. - If 0, it's OK to read uninitialized storage so long as the value is - not relied upon. Defining it to 0 lets mktime access parts of - struct tm that might be uninitialized, as a heuristic when the - standard doesn't say what to return and when tm_gmtoff can help - mktime likely infer a better value. */ -#ifndef UNINIT_TRAP -# define UNINIT_TRAP 0 -#endif - -#ifdef DEBUG -# define UNREACHABLE() abort() -#elif 4 < __GNUC__ + (5 <= __GNUC_MINOR__) -# define UNREACHABLE() __builtin_unreachable() -#elif defined __has_builtin -# if __has_builtin(__builtin_unreachable) -# define UNREACHABLE() __builtin_unreachable() -# endif -#endif -#ifndef UNREACHABLE -# define UNREACHABLE() ((void) 0) -#endif - -/* -** For the benefit of GNU folk... -** '_(MSGID)' uses the current locale's message library string for MSGID. -** The default is to use gettext if available, and use MSGID otherwise. -*/ - -#if HAVE_GETTEXT -#define _(msgid) gettext(msgid) -#else /* !HAVE_GETTEXT */ -#define _(msgid) msgid -#endif /* !HAVE_GETTEXT */ - -#if !defined TZ_DOMAIN && defined HAVE_GETTEXT -# define TZ_DOMAIN "tz" -#endif - -#if HAVE_INCOMPATIBLE_CTIME_R -#undef asctime_r -#undef ctime_r -char *asctime_r(struct tm const *, char *); -char *ctime_r(int64_t const *, char *); -#endif /* HAVE_INCOMPATIBLE_CTIME_R */ - -/* Handy macros that are independent of tzfile implementation. */ - -#define SECSPERMIN 60 -#define MINSPERHOUR 60 -#define HOURSPERDAY 24 -#define DAYSPERWEEK 7 -#define DAYSPERNYEAR 365 -#define DAYSPERLYEAR 366 -#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR) -#define SECSPERDAY ((int32_t) SECSPERHOUR * HOURSPERDAY) -#define MONSPERYEAR 12 - -#define YEARSPERREPEAT 400 /* years before a Gregorian repeat */ -#define DAYSPERREPEAT ((int32_t) 400 * 365 + 100 - 4 + 1) -#define SECSPERREPEAT ((int64_t) DAYSPERREPEAT * SECSPERDAY) -#define AVGSECSPERYEAR (SECSPERREPEAT / YEARSPERREPEAT) - -#define TM_SUNDAY 0 -#define TM_MONDAY 1 -#define TM_TUESDAY 2 -#define TM_WEDNESDAY 3 -#define TM_THURSDAY 4 -#define TM_FRIDAY 5 -#define TM_SATURDAY 6 - -#define TM_JANUARY 0 -#define TM_FEBRUARY 1 -#define TM_MARCH 2 -#define TM_APRIL 3 -#define TM_MAY 4 -#define TM_JUNE 5 -#define TM_JULY 6 -#define TM_AUGUST 7 -#define TM_SEPTEMBER 8 -#define TM_OCTOBER 9 -#define TM_NOVEMBER 10 -#define TM_DECEMBER 11 - -#define TM_YEAR_BASE 1900 -#define TM_WDAY_BASE TM_MONDAY - -#define EPOCH_YEAR 1970 -#define EPOCH_WDAY TM_THURSDAY - -#define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0)) - -/* -** Since everything in isleap is modulo 400 (or a factor of 400), we know that -** isleap(y) == isleap(y % 400) -** and so -** isleap(a + b) == isleap((a + b) % 400) -** or -** isleap(a + b) == isleap(a % 400 + b % 400) -** This is true even if % means modulo rather than Fortran remainder -** (which is allowed by C89 but not by C99 or later). -** We use this to avoid addition overflow problems. -*/ - -#define isleap_sum(a, b) isleap((a) % 400 + (b) % 400) - -COSMOPOLITAN_C_END_ -#endif /* COSMOPOLITAN_THIRD_PARTY_TZ_PRIVATE_H_ */ diff --git a/libc/time/xiso8601.c b/libc/time/xiso8601.c deleted file mode 100644 index e068d2108..000000000 --- a/libc/time/xiso8601.c +++ /dev/null @@ -1,76 +0,0 @@ -/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ -│ vi: set et ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi │ -╞══════════════════════════════════════════════════════════════════════════════╡ -│ Copyright 2020 Justine Alexandra Roberts Tunney │ -│ │ -│ Permission to use, copy, modify, and/or distribute this software for │ -│ any purpose with or without fee is hereby granted, provided that the │ -│ above copyright notice and this permission notice appear in all copies. │ -│ │ -│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ -│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ -│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ -│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ -│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ -│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ -│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ -│ PERFORMANCE OF THIS SOFTWARE. │ -╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/struct/timespec.h" -#include "libc/calls/struct/timeval.h" -#include "libc/dce.h" -#include "libc/errno.h" -#include "libc/mem/mem.h" -#include "libc/stdio/stdio.h" -#include "libc/sysv/consts/clock.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" -#include "libc/x/x.h" - -// TODO(jart): DELETE - -static char *xiso8601_impl(struct timespec *opt_ts, int sswidth) { - char *p; - struct tm tm; - struct timespec ts; - int64_t sec, subsec; - char timebuf[64], zonebuf[8]; - if (opt_ts) { - sec = opt_ts->tv_sec; - subsec = opt_ts->tv_nsec; - } else { - errno = 0; - clock_gettime(CLOCK_REALTIME, &ts); - sec = ts.tv_sec; - subsec = ts.tv_nsec; - sswidth = 9; - if (errno == ENOSYS) { - subsec /= 1000; - sswidth = 6; - } - } - if (IsWindows() && sswidth == 9) { - subsec /= 100; - sswidth = 7; /* windows nt uses hectonanoseconds */ - } - localtime_r(&sec, &tm); - strftime(timebuf, sizeof(timebuf), "%Y-%m-%dT%H:%M:%S", &tm); - strftime(zonebuf, sizeof(zonebuf), "%z", &tm); - asprintf(&p, "%s.%0*ld%s", timebuf, sswidth, subsec, zonebuf); - return p; -} - -/** - * Returns allocated string representation of nanosecond timestamp. - */ -char *xiso8601ts(struct timespec *opt_ts) { - return xiso8601_impl(opt_ts, 9); -} - -/** - * Returns allocated string representation of microsecond timestamp. - */ -char *xiso8601tv(struct timeval *opt_tv) { - return xiso8601_impl( - opt_tv ? &(struct timespec){opt_tv->tv_sec, opt_tv->tv_usec} : NULL, 6); -} diff --git a/libc/utime.h b/libc/utime.h new file mode 100644 index 000000000..3cf3f7083 --- /dev/null +++ b/libc/utime.h @@ -0,0 +1,17 @@ +#ifndef COSMOPOLITAN_LIBC_UTIME_H_ +#define COSMOPOLITAN_LIBC_UTIME_H_ +COSMOPOLITAN_C_START_ + +struct utimbuf { + int64_t actime; /* access time */ + int64_t modtime; /* modified time */ +}; + +int utime(const char *, const struct utimbuf *) libcesque; + +#ifdef _COSMO_SOURCE +int sys_utime(const char *, const struct utimbuf *) libcesque; +#endif /* _COSMO_SOURCE */ + +COSMOPOLITAN_C_END_ +#endif /* COSMOPOLITAN_LIBC_UTIME_H_ */ diff --git a/libc/x/xiso8601.h b/libc/x/xiso8601.h deleted file mode 100644 index b8bfe7b9b..000000000 --- a/libc/x/xiso8601.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef COSMOPOLITAN_LIBC_X_XISO8601_H_ -#define COSMOPOLITAN_LIBC_X_XISO8601_H_ -#include "libc/calls/struct/timespec.h" -#include "libc/calls/struct/timeval.h" -COSMOPOLITAN_C_START_ - -char *xiso8601i(int) mallocesque; -char *xiso8601tv(struct timeval *) mallocesque; -char *xiso8601ts(struct timespec *) mallocesque; - -#if __STDC_VERSION__ + 0 >= 201112 -#define xiso8601(TS) \ - _Generic(*(TS), struct timeval : xiso8601tv, default : xiso8601ts)(TS) -#endif /* C11 */ - -COSMOPOLITAN_C_END_ -#endif /* COSMOPOLITAN_LIBC_X_XISO8601_H_ */ diff --git a/net/http/BUILD.mk b/net/http/BUILD.mk index 8e0bb7686..1ab73c51c 100644 --- a/net/http/BUILD.mk +++ b/net/http/BUILD.mk @@ -22,8 +22,7 @@ NET_HTTP_A_DIRECTDEPS = \ LIBC_MEM \ LIBC_NEXGEN32E \ LIBC_STR \ - LIBC_SYSV \ - LIBC_TIME + LIBC_SYSV NET_HTTP_A_DEPS := \ $(call uniq,$(foreach x,$(NET_HTTP_A_DIRECTDEPS),$($(x)))) diff --git a/net/http/formathttpdatetime.c b/net/http/formathttpdatetime.c index b778588ca..80089e3d0 100644 --- a/net/http/formathttpdatetime.c +++ b/net/http/formathttpdatetime.c @@ -18,8 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/macros.internal.h" #include "libc/str/str.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "net/http/http.h" /** diff --git a/net/http/http.h b/net/http/http.h index a673a4c3a..2bf82a2a6 100644 --- a/net/http/http.h +++ b/net/http/http.h @@ -1,7 +1,7 @@ #ifndef COSMOPOLITAN_LIBC_HTTP_HTTP_H_ #define COSMOPOLITAN_LIBC_HTTP_HTTP_H_ #include "libc/serialize.h" -#include "libc/time/struct/tm.h" +#include "libc/time.h" #define kHttpRequest 0 #define kHttpResponse 1 diff --git a/net/http/parsehttpdatetime.c b/net/http/parsehttpdatetime.c index 7d5343466..e7889c8e7 100644 --- a/net/http/parsehttpdatetime.c +++ b/net/http/parsehttpdatetime.c @@ -18,7 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/serialize.h" #include "libc/str/str.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "net/http/http.h" static unsigned ParseMonth(const char *p) { diff --git a/net/https/BUILD.mk b/net/https/BUILD.mk index 3ca626930..3d32d09b2 100644 --- a/net/https/BUILD.mk +++ b/net/https/BUILD.mk @@ -32,10 +32,10 @@ NET_HTTPS_A_DIRECTDEPS = \ LIBC_STR \ LIBC_SYSV \ LIBC_THREAD \ - LIBC_TIME \ LIBC_X \ THIRD_PARTY_COMPILER_RT \ - THIRD_PARTY_MBEDTLS + THIRD_PARTY_MBEDTLS \ + THIRD_PARTY_TZ NET_HTTPS_A_DEPS := \ $(call uniq,$(foreach x,$(NET_HTTPS_A_DIRECTDEPS),$($(x)))) diff --git a/net/https/choosecertificatelifetime.c b/net/https/choosecertificatelifetime.c index 28a306530..a3fea1ac3 100644 --- a/net/https/choosecertificatelifetime.c +++ b/net/https/choosecertificatelifetime.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/struct/timespec.h" -#include "libc/time/struct/tm.h" +#include "libc/time.h" #include "net/https/https.h" void ChooseCertificateLifetime(char notbefore[16], char notafter[16]) { diff --git a/net/https/https.h b/net/https/https.h index e4aee4073..55779c155 100644 --- a/net/https/https.h +++ b/net/https/https.h @@ -1,6 +1,6 @@ #ifndef COSMOPOLITAN_NET_HTTPS_HTTPS_H_ #define COSMOPOLITAN_NET_HTTPS_HTTPS_H_ -#include "libc/time/struct/tm.h" +#include "libc/time.h" #include "third_party/mbedtls/ctr_drbg.h" #include "third_party/mbedtls/ecp.h" #include "third_party/mbedtls/md.h" diff --git a/net/turfwar/BUILD.mk b/net/turfwar/BUILD.mk index 9dc216b9b..ffa291ea9 100644 --- a/net/turfwar/BUILD.mk +++ b/net/turfwar/BUILD.mk @@ -30,7 +30,6 @@ NET_TURFWAR_DIRECTDEPS = \ LIBC_STR \ LIBC_SYSV \ LIBC_THREAD \ - LIBC_TIME \ LIBC_X \ NET_HTTP \ THIRD_PARTY_GETOPT \ @@ -39,6 +38,7 @@ NET_TURFWAR_DIRECTDEPS = \ THIRD_PARTY_NSYNC_MEM \ THIRD_PARTY_SQLITE3 \ THIRD_PARTY_STB \ + THIRD_PARTY_TZ \ THIRD_PARTY_ZLIB NET_TURFWAR_DEPS := \ diff --git a/net/turfwar/blackholed.c b/net/turfwar/blackholed.c index eb30b8550..b21bc04b4 100644 --- a/net/turfwar/blackholed.c +++ b/net/turfwar/blackholed.c @@ -26,12 +26,12 @@ #include "libc/errno.h" #include "libc/fmt/conv.h" #include "libc/fmt/itoa.h" -#include "libc/serialize.h" #include "libc/intrin/kprintf.h" #include "libc/intrin/safemacros.internal.h" #include "libc/mem/mem.h" #include "libc/mem/sortedints.internal.h" #include "libc/runtime/runtime.h" +#include "libc/serialize.h" #include "libc/sock/sock.h" #include "libc/sock/struct/sockaddr.h" #include "libc/str/str.h" @@ -43,7 +43,7 @@ #include "libc/sysv/consts/sig.h" #include "libc/sysv/consts/sock.h" #include "libc/sysv/consts/timer.h" -#include "libc/time/struct/tm.h" +#include "libc/time.h" #include "net/http/http.h" #include "net/http/ip.h" #include "third_party/getopt/getopt.internal.h" diff --git a/net/turfwar/turfwar.c b/net/turfwar/turfwar.c index 6f89d7212..3490820b7 100644 --- a/net/turfwar/turfwar.c +++ b/net/turfwar/turfwar.c @@ -70,7 +70,7 @@ #include "libc/sysv/consts/tcp.h" #include "libc/thread/thread.h" #include "libc/thread/thread2.h" -#include "libc/time/struct/tm.h" +#include "libc/time.h" #include "libc/x/x.h" #include "libc/x/xasprintf.h" #include "libc/zip.internal.h" diff --git a/test/libc/calls/BUILD.mk b/test/libc/calls/BUILD.mk index 63da426d7..75eadbcd6 100644 --- a/test/libc/calls/BUILD.mk +++ b/test/libc/calls/BUILD.mk @@ -47,12 +47,12 @@ TEST_LIBC_CALLS_DIRECTDEPS = \ LIBC_SYSV_CALLS \ LIBC_TESTLIB \ LIBC_THREAD \ - LIBC_TIME \ LIBC_TINYMATH \ LIBC_X \ THIRD_PARTY_COMPILER_RT \ TOOL_DECODE_LIB \ - THIRD_PARTY_XED + THIRD_PARTY_XED \ + THIRD_PARTY_TZ TEST_LIBC_CALLS_DEPS := \ $(call uniq,$(foreach x,$(TEST_LIBC_CALLS_DIRECTDEPS),$($(x)))) diff --git a/test/libc/calls/clock_getres_test.c b/test/libc/calls/clock_getres_test.c index 2497816be..ad296e319 100644 --- a/test/libc/calls/clock_getres_test.c +++ b/test/libc/calls/clock_getres_test.c @@ -21,7 +21,7 @@ #include "libc/runtime/runtime.h" #include "libc/sysv/consts/clock.h" #include "libc/testlib/testlib.h" -#include "libc/time/time.h" +#include "libc/time.h" struct timespec ts; diff --git a/test/libc/calls/clock_gettime_test.c b/test/libc/calls/clock_gettime_test.c index 5a7a0954b..c86a92abf 100644 --- a/test/libc/calls/clock_gettime_test.c +++ b/test/libc/calls/clock_gettime_test.c @@ -29,7 +29,7 @@ #include "libc/sysv/consts/clock.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" -#include "libc/time/time.h" +#include "libc/time.h" TEST(clock_gettime, nullResult_validatesClockParam) { ASSERT_SYS(EINVAL, -1, clock_gettime(666, 0)); diff --git a/test/libc/calls/clock_nanosleep_test.c b/test/libc/calls/clock_nanosleep_test.c index e6f754638..805dfacee 100644 --- a/test/libc/calls/clock_nanosleep_test.c +++ b/test/libc/calls/clock_nanosleep_test.c @@ -30,7 +30,7 @@ #include "libc/sysv/consts/sa.h" #include "libc/sysv/consts/sig.h" #include "libc/testlib/testlib.h" -#include "libc/time/time.h" +#include "libc/time.h" void OnAlrm(int sig) { // do nothing diff --git a/test/libc/calls/getitimer_test.c b/test/libc/calls/getitimer_test.c index 8e0a73a16..6093a701c 100644 --- a/test/libc/calls/getitimer_test.c +++ b/test/libc/calls/getitimer_test.c @@ -21,7 +21,7 @@ #include "libc/errno.h" #include "libc/sysv/consts/itimer.h" #include "libc/testlib/testlib.h" -#include "libc/time/time.h" +#include "libc/time.h" TEST(getitimer, testBadParam_returnsEinval) { struct itimerval it; diff --git a/test/libc/calls/pledge_test.c b/test/libc/calls/pledge_test.c index 8bb59a845..a56256299 100644 --- a/test/libc/calls/pledge_test.c +++ b/test/libc/calls/pledge_test.c @@ -58,7 +58,7 @@ #include "libc/testlib/testlib.h" #include "libc/thread/posixthread.internal.h" #include "libc/thread/thread.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "libc/x/x.h" void SetUpOnce(void) { diff --git a/test/libc/calls/readansi_test.c b/test/libc/calls/readansi_test.c index d922e4f60..b81ec0f65 100644 --- a/test/libc/calls/readansi_test.c +++ b/test/libc/calls/readansi_test.c @@ -20,7 +20,7 @@ #include "libc/runtime/runtime.h" #include "libc/str/str.h" #include "libc/testlib/testlib.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "libc/x/x.h" TEST(readansi, test) { diff --git a/test/libc/calls/reservefd_test.c b/test/libc/calls/reservefd_test.c index 1d602fc1c..b1013e019 100644 --- a/test/libc/calls/reservefd_test.c +++ b/test/libc/calls/reservefd_test.c @@ -40,8 +40,7 @@ #include "libc/testlib/hyperion.h" #include "libc/testlib/testlib.h" #include "libc/thread/tls.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" +#include "libc/time.h" __static_yoink("zipos"); __static_yoink("libc/testlib/hyperion.txt"); @@ -70,7 +69,7 @@ TEST(reservefd, testGrowthOfFdsDataStructure) { errno = 0; } for (i = 0; i < n; ++i) { - ASSERT_SYS(0, i + 3, open("/zip/usr/share/zoneinfo/UTC", O_RDONLY)); + ASSERT_SYS(0, i + 3, open("/zip/usr/share/zoneinfo/GMT", O_RDONLY)); } ASSERT_GT(g_fds.n, 16); for (i = 0; i < n; ++i) { diff --git a/test/libc/calls/setrlimit_test.c b/test/libc/calls/setrlimit_test.c index aa8749575..dd95408c4 100644 --- a/test/libc/calls/setrlimit_test.c +++ b/test/libc/calls/setrlimit_test.c @@ -35,7 +35,7 @@ #include "libc/sysv/consts/rlimit.h" #include "libc/sysv/consts/sig.h" #include "libc/testlib/testlib.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "libc/x/xsigaction.h" #include "libc/x/xspawn.h" diff --git a/test/libc/calls/utimensat_test.c b/test/libc/calls/utimensat_test.c index 583f2e67f..9d1f5eeab 100644 --- a/test/libc/calls/utimensat_test.c +++ b/test/libc/calls/utimensat_test.c @@ -29,7 +29,7 @@ #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/utime.h" #include "libc/testlib/testlib.h" -#include "libc/time/time.h" +#include "libc/time.h" void SetUpOnce(void) { testlib_enable_tmp_setup_teardown(); diff --git a/test/libc/fmt/timevaltofiletime_test.c b/test/libc/fmt/timevaltofiletime_test.c index f4a553304..42feb8ab4 100644 --- a/test/libc/fmt/timevaltofiletime_test.c +++ b/test/libc/fmt/timevaltofiletime_test.c @@ -16,7 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/time/time.h" +#include "libc/time.h" #include "libc/calls/struct/timeval.h" #include "libc/fmt/wintime.internal.h" #include "libc/nt/struct/filetime.h" diff --git a/test/libc/intrin/lockscale_test.c b/test/libc/intrin/lockscale_test.c index be97158d5..c74feb136 100644 --- a/test/libc/intrin/lockscale_test.c +++ b/test/libc/intrin/lockscale_test.c @@ -24,7 +24,7 @@ #include "libc/stdio/stdio.h" #include "libc/testlib/testlib.h" #include "libc/thread/thread.h" -#include "libc/time/time.h" +#include "libc/time.h" /** * @fileoverview Lock Waiter Scalability Test diff --git a/test/libc/mem/malloc_test.c b/test/libc/mem/malloc_test.c index f27e1e3c3..1f94765ab 100644 --- a/test/libc/mem/malloc_test.c +++ b/test/libc/mem/malloc_test.c @@ -42,7 +42,7 @@ #include "libc/testlib/subprocess.h" #include "libc/testlib/testlib.h" #include "libc/thread/thread.h" -#include "libc/time/time.h" +#include "libc/time.h" #define N 1024 #define M 20 diff --git a/test/libc/release/smoke.c b/test/libc/release/smoke.c index 993bc73b2..854bcf1b8 100644 --- a/test/libc/release/smoke.c +++ b/test/libc/release/smoke.c @@ -6,7 +6,6 @@ int main(int argc, char *argv[]) { s = strdup(argv[0]); s[0] = 'Z'; f = fopen("/dev/null", "w"); - /* fputs(gc(xiso8601ts(NULL)), f); */ fputs(gc(xasprintf("hello world %d %s\n", argc, s)), f); fclose(f); free(s); diff --git a/test/libc/sock/select_test.c b/test/libc/sock/select_test.c index 3edb1f875..210f8ad7b 100644 --- a/test/libc/sock/select_test.c +++ b/test/libc/sock/select_test.c @@ -28,7 +28,7 @@ #include "libc/sock/sock.h" #include "libc/sysv/consts/sig.h" #include "libc/testlib/testlib.h" -#include "libc/time/time.h" +#include "libc/time.h" bool gotsig; diff --git a/test/libc/sock/unix_test.c b/test/libc/sock/unix_test.c index c1691234b..e72a5baa6 100644 --- a/test/libc/sock/unix_test.c +++ b/test/libc/sock/unix_test.c @@ -35,7 +35,7 @@ #include "libc/sysv/consts/sol.h" #include "libc/testlib/subprocess.h" #include "libc/testlib/testlib.h" -#include "libc/time/time.h" +#include "libc/time.h" void SetUpOnce(void) { testlib_enable_tmp_setup_teardown(); diff --git a/test/libc/stdio/BUILD.mk b/test/libc/stdio/BUILD.mk index 8b9361212..f40be5396 100644 --- a/test/libc/stdio/BUILD.mk +++ b/test/libc/stdio/BUILD.mk @@ -38,7 +38,6 @@ TEST_LIBC_STDIO_DIRECTDEPS = \ LIBC_TINYMATH \ LIBC_TESTLIB \ LIBC_THREAD \ - LIBC_TIME \ LIBC_LOG \ LIBC_X \ THIRD_PARTY_GDTOA \ @@ -46,7 +45,8 @@ TEST_LIBC_STDIO_DIRECTDEPS = \ THIRD_PARTY_MUSL \ THIRD_PARTY_NSYNC \ THIRD_PARTY_ZLIB \ - THIRD_PARTY_ZLIB_GZ + THIRD_PARTY_ZLIB_GZ \ + THIRD_PARTY_TZ TEST_LIBC_STDIO_DEPS := \ $(call uniq,$(foreach x,$(TEST_LIBC_STDIO_DIRECTDEPS),$($(x)))) diff --git a/test/libc/stdio/dirstream_test.c b/test/libc/stdio/dirstream_test.c index 447f0f433..e334f85c5 100644 --- a/test/libc/stdio/dirstream_test.c +++ b/test/libc/stdio/dirstream_test.c @@ -39,11 +39,10 @@ #include "libc/sysv/consts/s.h" #include "libc/testlib/testlib.h" #include "libc/x/xasprintf.h" -#include "libc/x/xiso8601.h" __static_yoink("zipos"); __static_yoink("usr/share/zoneinfo/"); -__static_yoink("usr/share/zoneinfo/New_York"); +__static_yoink("usr/share/zoneinfo/GMT"); __static_yoink("libc/testlib/hyperion.txt"); __static_yoink("libc/testlib/moby.txt"); @@ -159,7 +158,7 @@ TEST(dirstream, zipTest) { const char *path = "/zip/usr/share/zoneinfo/"; ASSERT_NE(NULL, (dir = opendir(path))); while ((ent = readdir(dir))) { - foundNewYork |= !strcmp(ent->d_name, "New_York"); + foundNewYork |= !strcmp(ent->d_name, "GMT"); } EXPECT_SYS(0, 0, closedir(dir)); EXPECT_TRUE(foundNewYork); @@ -195,7 +194,7 @@ TEST(rewinddir, test) { } TEST(dirstream, zipTest_notDir) { - ASSERT_EQ(NULL, opendir("/zip/usr/share/zoneinfo/New_York")); + ASSERT_EQ(NULL, opendir("/zip/usr/share/zoneinfo/GMT")); ASSERT_EQ(ENOTDIR, errno); } @@ -431,7 +430,7 @@ TEST(dirstream, walk) { "FTW_F /zip/libc/testlib/moby.txt\n" "FTW_DP /zip/libc/testlib\n" "FTW_DP /zip/libc\n" - "FTW_F /zip/usr/share/zoneinfo/New_York\n" + "FTW_F /zip/usr/share/zoneinfo/GMT\n" "FTW_DP /zip/usr/share/zoneinfo\n" "FTW_DP /zip/usr/share\n" "FTW_DP /zip/usr\n" diff --git a/test/libc/stdio/fwrite_test.c b/test/libc/stdio/fwrite_test.c index 270fb1411..bbfd396b2 100644 --- a/test/libc/stdio/fwrite_test.c +++ b/test/libc/stdio/fwrite_test.c @@ -29,7 +29,7 @@ #include "libc/str/str.h" #include "libc/sysv/consts/sig.h" #include "libc/testlib/testlib.h" -#include "libc/time/time.h" +#include "libc/time.h" #define PATH "hog" diff --git a/test/libc/stdio/zipdir_test.c b/test/libc/stdio/zipdir_test.c index 60916c646..83dda5aff 100644 --- a/test/libc/stdio/zipdir_test.c +++ b/test/libc/stdio/zipdir_test.c @@ -38,7 +38,7 @@ __static_yoink("libc/testlib/hyperion.txt"); __static_yoink("libc/testlib/moby.txt"); __static_yoink("libc/testlib-test.txt"); __static_yoink("usr/share/zoneinfo/"); -__static_yoink("usr/share/zoneinfo/New_York"); +__static_yoink("usr/share/zoneinfo/America/New_York"); DIR *dir; struct dirent *ent; diff --git a/test/libc/thread/BUILD.mk b/test/libc/thread/BUILD.mk index bd27baa61..78e185361 100644 --- a/test/libc/thread/BUILD.mk +++ b/test/libc/thread/BUILD.mk @@ -45,11 +45,11 @@ TEST_LIBC_THREAD_DIRECTDEPS = \ LIBC_SYSV_CALLS \ LIBC_TESTLIB \ LIBC_THREAD \ - LIBC_TIME \ LIBC_X \ THIRD_PARTY_LIBCXXABI \ THIRD_PARTY_NSYNC \ - THIRD_PARTY_NSYNC_MEM + THIRD_PARTY_NSYNC_MEM \ + THIRD_PARTY_TZ TEST_LIBC_THREAD_DEPS := \ $(call uniq,$(foreach x,$(TEST_LIBC_THREAD_DIRECTDEPS),$($(x)))) diff --git a/test/libc/thread/setitimer_test.c b/test/libc/thread/setitimer_test.c index 341428de5..6ab5d42d0 100644 --- a/test/libc/thread/setitimer_test.c +++ b/test/libc/thread/setitimer_test.c @@ -35,7 +35,7 @@ #include "libc/sysv/consts/sig.h" #include "libc/testlib/subprocess.h" #include "libc/testlib/testlib.h" -#include "libc/time/time.h" +#include "libc/time.h" atomic_int gotsig; atomic_int gottid; diff --git a/test/libc/time/BUILD.mk b/test/libc/time/BUILD.mk index a7add074a..937b2d09e 100644 --- a/test/libc/time/BUILD.mk +++ b/test/libc/time/BUILD.mk @@ -24,10 +24,11 @@ TEST_LIBC_TIME_DIRECTDEPS = \ LIBC_MEM \ LIBC_NEXGEN32E \ LIBC_RUNTIME \ + LIBC_STR \ LIBC_SYSV \ LIBC_TESTLIB \ - LIBC_TIME \ - LIBC_X + LIBC_X \ + THIRD_PARTY_TZ TEST_LIBC_TIME_DEPS := \ $(call uniq,$(foreach x,$(TEST_LIBC_TIME_DIRECTDEPS),$($(x)))) diff --git a/test/libc/time/iso8601_test.c b/test/libc/time/iso8601_test.c index 52b3322b3..110ea964e 100644 --- a/test/libc/time/iso8601_test.c +++ b/test/libc/time/iso8601_test.c @@ -18,8 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" +#include "libc/time.h" TEST(iso8601, test) { char p[20]; diff --git a/test/libc/time/strftime_test.c b/test/libc/time/strftime_test.c index 275c0fb7c..b7f14e3bf 100644 --- a/test/libc/time/strftime_test.c +++ b/test/libc/time/strftime_test.c @@ -20,11 +20,10 @@ #include "libc/limits.h" #include "libc/runtime/runtime.h" #include "libc/testlib/testlib.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" +#include "libc/time.h" __attribute__((__constructor__)) void init(void) { - setenv("TZ", "GST", true); + setenv("TZ", "America/Los_Angeles", true); } char *FormatTime(const char *fmt, struct tm *tm) { @@ -39,7 +38,7 @@ TEST(strftime_100, iso8601_ShakaZuluTime) { FormatTime("%Y-%m-%dT%H:%M:%SZ", gmtime(&t))); } -TEST(xiso8601, testUnixYearZero) { +TEST(iso8601, testUnixYearZero) { int64_t t = 0; ASSERT_STREQ("1970-01-01T00:00:00Z", FormatTime("%Y-%m-%dT%H:%M:%SZ", gmtime(&t))); @@ -59,7 +58,7 @@ TEST(strftime_100, rfc822_ShakaZuluTime) { TEST(strftime_201, iso8601_GoogleStandardTime) { int64_t t = 0x5cd04d0e; - ASSERT_STREQ("GST", getenv("TZ")); + ASSERT_STREQ("America/Los_Angeles", getenv("TZ")); ASSERT_STREQ("2019-05-06T08:04:46PDT", FormatTime("%Y-%m-%dT%H:%M:%S%Z", localtime(&t))); } @@ -76,25 +75,25 @@ TEST(strftime_201, rfc822_GoogleStandardTime) { FormatTime("%a, %d %b %y %T %z", localtime(&t))); } -/* TEST(xiso8601, testModernity_TODO) { */ +/* TEST(iso8601, testModernity_TODO) { */ /* int64_t t = (1600 - 1970) * 31536000; */ /* ASSERT_STREQ("1600-01-01T00:00:00Z", */ /* FormatTime("%Y-%m-%dT%H:%M:%SZ", gmtime(&t))); */ /* } */ -TEST(xiso8601, testAtLeastBetterThanTraditionalUnixLimit) { +TEST(iso8601, testAtLeastBetterThanTraditionalUnixLimit) { int64_t t = 10737418235; ASSERT_STREQ("2310-04-04T16:10:35Z", FormatTime("%Y-%m-%dT%H:%M:%SZ", gmtime(&t))); } -TEST(xiso8601, testSomethingHuge) { +TEST(iso8601, testSomethingHuge) { int64_t t = 7707318812667; ASSERT_STREQ("246205-03-18T20:24:27Z", FormatTime("%Y-%m-%dT%H:%M:%SZ", gmtime(&t))); } -/* TEST(xiso8601, testMostOfStelliferousEra_TODO) { */ +/* TEST(iso8601, testMostOfStelliferousEra_TODO) { */ /* int64_t t = INT64_MAX; */ /* ASSERT_STREQ("somethinghuge-01-01T00:00:00Z", */ /* FormatTime("%Y-%m-%dT%H:%M:%SZ", gmtime(&t))); */ diff --git a/test/net/http/BUILD.mk b/test/net/http/BUILD.mk index 12ee44fb6..7d60e35dd 100644 --- a/test/net/http/BUILD.mk +++ b/test/net/http/BUILD.mk @@ -11,13 +11,13 @@ TEST_NET_HTTP_OBJS = \ $(TEST_NET_HTTP_SRCS:%.c=o/$(MODE)/%.o) TEST_NET_HTTP_COMS = \ - $(TEST_NET_HTTP_SRCS:%.c=o/$(MODE)/%.com) + $(TEST_NET_HTTP_SRCS:%.c=o/$(MODE)/%) TEST_NET_HTTP_TESTS = \ - $(TEST_NET_HTTP_SRCS_TEST:%.c=o/$(MODE)/%.com.ok) + $(TEST_NET_HTTP_SRCS_TEST:%.c=o/$(MODE)/%.ok) TEST_NET_HTTP_CHECKS = \ - $(TEST_NET_HTTP_SRCS_TEST:%.c=o/$(MODE)/%.com.runs) + $(TEST_NET_HTTP_SRCS_TEST:%.c=o/$(MODE)/%.runs) TEST_NET_HTTP_DIRECTDEPS = \ NET_HTTP \ @@ -32,7 +32,7 @@ o/$(MODE)/test/net/http/http.pkg: \ $(TEST_NET_HTTP_OBJS) \ $(foreach x,$(TEST_NET_HTTP_DIRECTDEPS),$($(x)_A).pkg) -o/$(MODE)/test/net/http/%.com.dbg: \ +o/$(MODE)/test/net/http/%.dbg: \ $(TEST_NET_HTTP_DEPS) \ o/$(MODE)/test/net/http/%.o \ $(LIBC_TESTMAIN) \ diff --git a/test/net/http/formathttpdatetime_test.c b/test/net/http/formathttpdatetime_test.c index 8922b1d5a..af91e6005 100644 --- a/test/net/http/formathttpdatetime_test.c +++ b/test/net/http/formathttpdatetime_test.c @@ -18,10 +18,25 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "net/http/http.h" +TEST(gmtime, test) { + struct tm *tm; + int64_t t = 0x62820bcd; + tm = gmtime(&t); + ASSERT_EQ(9, tm->tm_sec); + ASSERT_EQ(31, tm->tm_min); + ASSERT_EQ(8, tm->tm_hour); + ASSERT_EQ(16, tm->tm_mday); + ASSERT_EQ(4, tm->tm_mon); + ASSERT_EQ(122, tm->tm_year); + ASSERT_EQ(1, tm->tm_wday); + ASSERT_EQ(0, tm->tm_isdst); + ASSERT_EQ(0, tm->tm_gmtoff); + ASSERT_STREQ("UTC", tm->tm_zone); +} + TEST(FormatHttpDateTime, test) { char p[30]; struct tm *tm; @@ -37,7 +52,7 @@ TEST(FormatHttpDateTime, testStrftime) { int64_t t = 0x62820bcd; tm = gmtime(&t); strftime(p, sizeof(p), "%a, %d %b %Y %H:%M:%S %Z", tm); - ASSERT_STREQ("Mon, 16 May 2022 08:31:09 GMT", p); + ASSERT_STREQ("Mon, 16 May 2022 08:31:09 UTC", p); // GMT -> UTC says POSIX } BENCH(FormatHttpDateTime, bench) { diff --git a/test/net/http/parsehttpdatetime_test.c b/test/net/http/parsehttpdatetime_test.c index c5219f91d..1b43e6138 100644 --- a/test/net/http/parsehttpdatetime_test.c +++ b/test/net/http/parsehttpdatetime_test.c @@ -18,8 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/str/str.h" #include "libc/testlib/testlib.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "net/http/http.h" #define PARSE(s) ParseHttpDateTime(s, sizeof(s) - 1) diff --git a/test/net/https/BUILD.mk b/test/net/https/BUILD.mk index ed6a38552..5ed4e2aac 100644 --- a/test/net/https/BUILD.mk +++ b/test/net/https/BUILD.mk @@ -11,13 +11,13 @@ TEST_NET_HTTPS_OBJS = \ $(TEST_NET_HTTPS_SRCS:%.c=o/$(MODE)/%.o) TEST_NET_HTTPS_COMS = \ - $(TEST_NET_HTTPS_SRCS:%.c=o/$(MODE)/%.com) + $(TEST_NET_HTTPS_SRCS:%.c=o/$(MODE)/%) TEST_NET_HTTPS_TESTS = \ - $(TEST_NET_HTTPS_SRCS_TEST:%.c=o/$(MODE)/%.com.ok) + $(TEST_NET_HTTPS_SRCS_TEST:%.c=o/$(MODE)/%.ok) TEST_NET_HTTPS_CHECKS = \ - $(TEST_NET_HTTPS_SRCS_TEST:%.c=o/$(MODE)/%.com.runs) + $(TEST_NET_HTTPS_SRCS_TEST:%.c=o/$(MODE)/%.runs) TEST_NET_HTTPS_DIRECTDEPS = \ NET_HTTPS \ @@ -33,7 +33,7 @@ o/$(MODE)/test/net/https/https.pkg: \ $(TEST_NET_HTTPS_OBJS) \ $(foreach x,$(TEST_NET_HTTPS_DIRECTDEPS),$($(x)_A).pkg) -o/$(MODE)/test/net/https/%.com.dbg: \ +o/$(MODE)/test/net/https/%.dbg: \ $(TEST_NET_HTTPS_DEPS) \ o/$(MODE)/test/net/https/%.o \ $(LIBC_TESTMAIN) \ diff --git a/test/tool/net/lunix_test.lua b/test/tool/net/lunix_test.lua index 67525cca4..e89f15cc8 100644 --- a/test/tool/net/lunix_test.lua +++ b/test/tool/net/lunix_test.lua @@ -42,7 +42,7 @@ function UnixTest() assert(wday == 5) assert(yday == 188) assert(dst == 0) - assert(zone == "GMT") + assert(zone == "UTC") -- dup -- 1. duplicate stderr as lowest available fd diff --git a/test/tool/viz/lib/BUILD.mk b/test/tool/viz/lib/BUILD.mk index 2fb36620b..3dd6dd5b0 100644 --- a/test/tool/viz/lib/BUILD.mk +++ b/test/tool/viz/lib/BUILD.mk @@ -33,10 +33,10 @@ TEST_TOOL_VIZ_LIB_DIRECTDEPS = \ LIBC_STDIO \ LIBC_TESTLIB \ LIBC_STR \ - LIBC_TIME \ LIBC_TINYMATH \ LIBC_X \ - TOOL_VIZ_LIB + TOOL_VIZ_LIB \ + THIRD_PARTY_TZ TEST_TOOL_VIZ_LIB_DEPS := \ $(call uniq,$(foreach x,$(TEST_TOOL_VIZ_LIB_DIRECTDEPS),$($(x)))) diff --git a/test/tool/viz/lib/ycbcr2rgb2_test.c b/test/tool/viz/lib/ycbcr2rgb2_test.c index de147c3c2..1e0f9e0e6 100644 --- a/test/tool/viz/lib/ycbcr2rgb2_test.c +++ b/test/tool/viz/lib/ycbcr2rgb2_test.c @@ -23,7 +23,7 @@ #include "libc/str/str.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "tool/viz/lib/graphic.h" #include "tool/viz/lib/ycbcr.h" diff --git a/third_party/BUILD.mk b/third_party/BUILD.mk index 36eef50ad..f785620d3 100644 --- a/third_party/BUILD.mk +++ b/third_party/BUILD.mk @@ -41,6 +41,7 @@ o/$(MODE)/third_party: \ o/$(MODE)/third_party/tidy \ o/$(MODE)/third_party/tr \ o/$(MODE)/third_party/tree \ + o/$(MODE)/third_party/tz \ o/$(MODE)/third_party/unzip \ o/$(MODE)/third_party/vqsort \ o/$(MODE)/third_party/xed \ diff --git a/third_party/bash/BUILD.mk b/third_party/bash/BUILD.mk index 53c3874a4..03c4cb94a 100644 --- a/third_party/bash/BUILD.mk +++ b/third_party/bash/BUILD.mk @@ -29,14 +29,14 @@ THIRD_PARTY_BASH_DIRECTDEPS = \ LIBC_STR \ LIBC_SYSV \ LIBC_THREAD \ - LIBC_TIME \ THIRD_PARTY_COMPILER_RT \ THIRD_PARTY_GDTOA \ THIRD_PARTY_GETOPT \ THIRD_PARTY_MUSL \ THIRD_PARTY_NCURSES \ THIRD_PARTY_READLINE \ - THIRD_PARTY_REGEX + THIRD_PARTY_REGEX \ + THIRD_PARTY_TZ THIRD_PARTY_BASH_DEPS := \ $(call uniq,$(foreach x,$(THIRD_PARTY_BASH_DIRECTDEPS),$($(x)))) diff --git a/third_party/bzip2/bzip2.c b/third_party/bzip2/bzip2.c index c18094ff6..d91483807 100644 --- a/third_party/bzip2/bzip2.c +++ b/third_party/bzip2/bzip2.c @@ -12,8 +12,8 @@ #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/s.h" #include "libc/sysv/consts/sig.h" -#include "libc/time/struct/utimbuf.h" -#include "libc/time/time.h" +#include "libc/utime.h" +#include "libc/time.h" #include "third_party/bzip2/bzlib.h" /*-----------------------------------------------------------*/ diff --git a/third_party/chibicc/BUILD.mk b/third_party/chibicc/BUILD.mk index 33f001406..8e3d9bb6d 100644 --- a/third_party/chibicc/BUILD.mk +++ b/third_party/chibicc/BUILD.mk @@ -59,12 +59,12 @@ THIRD_PARTY_CHIBICC_A_DIRECTDEPS = \ LIBC_STDIO \ LIBC_STR \ LIBC_SYSV \ - LIBC_TIME \ LIBC_X \ THIRD_PARTY_COMPILER_RT \ THIRD_PARTY_DLMALLOC \ - TOOL_BUILD_LIB \ - THIRD_PARTY_GDTOA + THIRD_PARTY_GDTOA \ + THIRD_PARTY_TZ \ + TOOL_BUILD_LIB THIRD_PARTY_CHIBICC_A_DEPS := \ $(call uniq,$(foreach x,$(THIRD_PARTY_CHIBICC_A_DIRECTDEPS),$($(x)))) diff --git a/third_party/chibicc/chibicc.h b/third_party/chibicc/chibicc.h index 417f3be58..25beb3469 100644 --- a/third_party/chibicc/chibicc.h +++ b/third_party/chibicc/chibicc.h @@ -19,8 +19,7 @@ #include "libc/temp.h" #include "libc/str/str.h" #include "libc/str/unicode.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "libc/x/x.h" #include "third_party/gdtoa/gdtoa.h" #include "tool/build/lib/javadown.h" diff --git a/third_party/ctags/entry.c b/third_party/ctags/entry.c index c7791d6ad..13126d298 100644 --- a/third_party/ctags/entry.c +++ b/third_party/ctags/entry.c @@ -43,7 +43,7 @@ #include "libc/sysv/consts/fileno.h" #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/ok.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/getopt/getopt.internal.h" #include "third_party/musl/crypt.h" #include "third_party/musl/lockf.h" /* to declare close (), ftruncate (), truncate () */ diff --git a/third_party/ctags/main.c b/third_party/ctags/main.c index 286d49d83..8184c250a 100644 --- a/third_party/ctags/main.c +++ b/third_party/ctags/main.c @@ -24,7 +24,7 @@ #include "libc/calls/weirdtypes.h" #include "libc/mem/alg.h" #include "libc/str/str.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/ctags/debug.h" #include "third_party/ctags/keyword.h" #include "third_party/ctags/main.h" diff --git a/third_party/finger/BUILD.mk b/third_party/finger/BUILD.mk index a9d5ef12f..144d43f1c 100644 --- a/third_party/finger/BUILD.mk +++ b/third_party/finger/BUILD.mk @@ -23,9 +23,9 @@ THIRD_PARTY_FINGER_A_DIRECTDEPS = \ LIBC_STR \ LIBC_SYSV \ LIBC_SOCK \ - LIBC_TIME \ THIRD_PARTY_MUSL \ - THIRD_PARTY_GETOPT + THIRD_PARTY_GETOPT \ + THIRD_PARTY_TZ THIRD_PARTY_FINGER_A_DEPS := \ $(call uniq,$(foreach x,$(THIRD_PARTY_FINGER_A_DIRECTDEPS),$($(x)))) diff --git a/third_party/finger/finger.c b/third_party/finger/finger.c index c9e828918..4cff1511e 100644 --- a/third_party/finger/finger.c +++ b/third_party/finger/finger.c @@ -47,7 +47,7 @@ #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/sysv/consts/fileno.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/getopt/getopt.internal.h" #include "third_party/musl/passwd.h" diff --git a/third_party/finger/lprint.c b/third_party/finger/lprint.c index e7a26d12c..f237d8d24 100644 --- a/third_party/finger/lprint.c +++ b/third_party/finger/lprint.c @@ -40,8 +40,7 @@ #include "libc/str/str.h" #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/s.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/finger/finger.h" /* diff --git a/third_party/finger/sprint.c b/third_party/finger/sprint.c index 66bc491f0..eda471599 100644 --- a/third_party/finger/sprint.c +++ b/third_party/finger/sprint.c @@ -37,8 +37,7 @@ #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/str/str.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/finger/finger.h" #ifndef lint diff --git a/third_party/hiredis/BUILD.mk b/third_party/hiredis/BUILD.mk index 731ce79d1..7dd6484f3 100644 --- a/third_party/hiredis/BUILD.mk +++ b/third_party/hiredis/BUILD.mk @@ -25,7 +25,6 @@ THIRD_PARTY_HIREDIS_A_DIRECTDEPS = \ LIBC_STDIO \ LIBC_STR \ LIBC_SYSV \ - LIBC_TIME \ LIBC_X \ THIRD_PARTY_GDTOA \ THIRD_PARTY_MUSL diff --git a/third_party/hiredis/hiredis.h b/third_party/hiredis/hiredis.h index ba7ba50fd..a48c8d65b 100644 --- a/third_party/hiredis/hiredis.h +++ b/third_party/hiredis/hiredis.h @@ -40,8 +40,7 @@ #include "libc/sock/select.h" #include "libc/sysv/consts/clock.h" #include "libc/sysv/consts/itimer.h" -#include "libc/time/struct/timezone.h" -#include "libc/time/time.h" /* for struct timeval */ +#include "libc/time.h" /* for struct timeval */ #include "libc/inttypes.h" #include "libc/limits.h" #include "libc/literal.h" /* uintXX_t, etc */ diff --git a/third_party/hiredis/read.c b/third_party/hiredis/read.c index ff8e2220f..a907520a5 100644 --- a/third_party/hiredis/read.c +++ b/third_party/hiredis/read.c @@ -56,7 +56,7 @@ #include "libc/sysv/consts/fileno.h" #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/ok.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/getopt/getopt.internal.h" #include "third_party/musl/crypt.h" #include "third_party/musl/lockf.h" diff --git a/third_party/libcxx/BUILD.mk b/third_party/libcxx/BUILD.mk index b3b29eeb7..a7feb2ed5 100644 --- a/third_party/libcxx/BUILD.mk +++ b/third_party/libcxx/BUILD.mk @@ -197,13 +197,13 @@ THIRD_PARTY_LIBCXX_A_DIRECTDEPS = \ LIBC_SOCK \ LIBC_STR \ LIBC_SYSV \ - LIBC_TIME \ LIBC_THREAD \ LIBC_TINYMATH \ THIRD_PARTY_COMPILER_RT \ THIRD_PARTY_GDTOA \ THIRD_PARTY_LIBCXXABI \ - THIRD_PARTY_LIBUNWIND + THIRD_PARTY_LIBUNWIND \ + THIRD_PARTY_TZ THIRD_PARTY_LIBCXX_A_DEPS := \ $(call uniq,$(foreach x,$(THIRD_PARTY_LIBCXX_A_DIRECTDEPS),$($(x)))) diff --git a/third_party/libcxx/__mutex_base b/third_party/libcxx/__mutex_base index a86d710c2..8d8dec77d 100644 --- a/third_party/libcxx/__mutex_base +++ b/third_party/libcxx/__mutex_base @@ -16,8 +16,7 @@ #include "third_party/libcxx/__threading_support" #include "libc/sysv/consts/sched.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" +#include "libc/time.h" #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header diff --git a/third_party/libcxx/chrono.cc b/third_party/libcxx/chrono.cc index b1efb89ed..aa4a96ad5 100644 --- a/third_party/libcxx/chrono.cc +++ b/third_party/libcxx/chrono.cc @@ -9,7 +9,7 @@ #include "third_party/libcxx/chrono" #include "third_party/libcxx/cerrno" // errn" #include "libc/sysv/consts/clock.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "libc/sysv/consts/clock.h" #include "third_party/libcxx/system_error" // __throw_system_erro" diff --git a/third_party/libcxx/cwchar b/third_party/libcxx/cwchar index 5931d53cc..033916b54 100644 --- a/third_party/libcxx/cwchar +++ b/third_party/libcxx/cwchar @@ -15,12 +15,11 @@ #include "third_party/libcxx/wchar.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" -#include "libc/time/struct/tm.h" +#include "libc/time.h" #include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h" #include "libc/fmt/conv.h" #include "third_party/gdtoa/gdtoa.h" -#include "libc/time/struct/tm.h" #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header diff --git a/third_party/lua/BUILD.mk b/third_party/lua/BUILD.mk index 4aa974277..a08cae0c4 100644 --- a/third_party/lua/BUILD.mk +++ b/third_party/lua/BUILD.mk @@ -132,13 +132,13 @@ THIRD_PARTY_LUA_A_DIRECTDEPS = \ LIBC_STR \ LIBC_SYSV \ LIBC_LOG \ - LIBC_TIME \ LIBC_X \ LIBC_TINYMATH \ NET_HTTP \ THIRD_PARTY_LINENOISE \ THIRD_PARTY_DOUBLECONVERSION \ - THIRD_PARTY_GDTOA + THIRD_PARTY_GDTOA \ + THIRD_PARTY_TZ THIRD_PARTY_LUA_A_DEPS := \ $(call uniq,$(foreach x,$(THIRD_PARTY_LUA_A_DIRECTDEPS),$($(x)))) @@ -203,10 +203,10 @@ THIRD_PARTY_LUA_UNIX_DIRECTDEPS = \ LIBC_STR \ LIBC_SYSV \ LIBC_THREAD \ - LIBC_TIME \ LIBC_X \ THIRD_PARTY_LUA \ - THIRD_PARTY_NSYNC + THIRD_PARTY_NSYNC \ + THIRD_PARTY_TZ THIRD_PARTY_LUA_UNIX_DEPS := \ $(call uniq,$(foreach x,$(THIRD_PARTY_LUA_UNIX_DIRECTDEPS),$($(x)))) diff --git a/third_party/lua/loslib.c b/third_party/lua/loslib.c index 4f979c59f..2693ac51b 100644 --- a/third_party/lua/loslib.c +++ b/third_party/lua/loslib.c @@ -35,8 +35,7 @@ #include "libc/str/str.h" #include "libc/sysv/consts/exit.h" #include "libc/temp.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/lua/lauxlib.h" #include "third_party/lua/lprefix.h" #include "third_party/lua/lua.h" diff --git a/third_party/lua/lstate.c b/third_party/lua/lstate.c index e44a5cf31..0151a17c3 100644 --- a/third_party/lua/lstate.c +++ b/third_party/lua/lstate.c @@ -28,7 +28,7 @@ #define lstate_c #define LUA_CORE #include "libc/str/str.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/lua/lapi.h" #include "third_party/lua/ldebug.h" #include "third_party/lua/ldo.h" diff --git a/third_party/lua/lunix.c b/third_party/lua/lunix.c index d4d60abc2..58c02b242 100644 --- a/third_party/lua/lunix.c +++ b/third_party/lua/lunix.c @@ -103,8 +103,7 @@ #include "libc/sysv/consts/w.h" #include "libc/sysv/errfuns.h" #include "libc/thread/thread.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "libc/x/x.h" #include "third_party/lua/cosmo.h" #include "third_party/lua/lauxlib.h" diff --git a/third_party/lz4cli/BUILD.mk b/third_party/lz4cli/BUILD.mk index 1c5ab1f69..e5bedcc82 100644 --- a/third_party/lz4cli/BUILD.mk +++ b/third_party/lz4cli/BUILD.mk @@ -41,8 +41,7 @@ o/$(MODE)/third_party/lz4cli/datagen.o: private \ THIRD_PARTY_LZ4CLI_DIRECTDEPS = \ LIBC_INTRIN \ LIBC_STDIO \ - LIBC_LOG \ - LIBC_TIME + LIBC_LOG THIRD_PARTY_LZ4CLI_DEPS := \ $(call uniq,$(foreach x,$(THIRD_PARTY_LZ4CLI_DIRECTDEPS),$($(x)))) diff --git a/third_party/lz4cli/bench.c b/third_party/lz4cli/bench.c index e651b7931..a96349a66 100644 --- a/third_party/lz4cli/bench.c +++ b/third_party/lz4cli/bench.c @@ -40,7 +40,7 @@ #include "libc/mem/mem.h" /* malloc, free */ #include "libc/str/str.h" /* memset */ #include "libc/stdio/stdio.h" /* fprintf, fopen, ftello */ -#include "libc/time/time.h" /* clock_t, clock, CLOCKS_PER_SEC */ +#include "libc/time.h" /* clock_t, clock, CLOCKS_PER_SEC */ #include "libc/assert.h" #include "libc/runtime/runtime.h" /* assert */ diff --git a/third_party/lz4cli/util.h b/third_party/lz4cli/util.h index 1bb76c175..96ad518a1 100644 --- a/third_party/lz4cli/util.h +++ b/third_party/lz4cli/util.h @@ -35,9 +35,9 @@ extern "C" { #include "libc/str/str.h" #include "libc/stdio/stdio.h" #include "libc/calls/calls.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "libc/errno.h" -#include "libc/time/struct/utimbuf.h" +#include "libc/utime.h" #include "libc/calls/struct/stat.h" #include "libc/calls/struct/dirent.h" #include "libc/sysv/consts/s.h" @@ -190,7 +190,7 @@ extern "C" { #elif (PLATFORM_POSIX_VERSION >= 200112L) && (defined __UCLIBC__ || (defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 17) || __GLIBC__ > 2) ) ) - #include "libc/time/time.h" + #include "libc/time.h" typedef struct timespec UTIL_time_t; UTIL_STATIC UTIL_time_t UTIL_getTime(void) { diff --git a/third_party/make/BUILD.mk b/third_party/make/BUILD.mk index a08f76e65..74ef491af 100644 --- a/third_party/make/BUILD.mk +++ b/third_party/make/BUILD.mk @@ -27,9 +27,9 @@ THIRD_PARTY_MAKE_DIRECTDEPS = \ LIBC_STDIO \ LIBC_STR \ LIBC_SYSV \ - LIBC_TIME \ LIBC_TINYMATH \ - THIRD_PARTY_MUSL + THIRD_PARTY_MUSL \ + THIRD_PARTY_TZ THIRD_PARTY_MAKE_DEPS := \ $(call uniq,$(foreach x,$(THIRD_PARTY_MAKE_DIRECTDEPS),$($(x)))) diff --git a/third_party/mbedtls/BUILD.mk b/third_party/mbedtls/BUILD.mk index 7c2e4deef..390010ace 100644 --- a/third_party/mbedtls/BUILD.mk +++ b/third_party/mbedtls/BUILD.mk @@ -27,10 +27,10 @@ THIRD_PARTY_MBEDTLS_A_DIRECTDEPS = \ LIBC_STDIO \ LIBC_STR \ LIBC_SYSV \ - LIBC_TIME \ NET_HTTP \ THIRD_PARTY_COMPILER_RT \ THIRD_PARTY_MUSL \ + THIRD_PARTY_TZ \ THIRD_PARTY_ZLIB THIRD_PARTY_MBEDTLS_A_DEPS := \ diff --git a/third_party/mbedtls/ssl_cache.c b/third_party/mbedtls/ssl_cache.c index c4d435ad9..844b58cf7 100644 --- a/third_party/mbedtls/ssl_cache.c +++ b/third_party/mbedtls/ssl_cache.c @@ -16,7 +16,7 @@ │ limitations under the License. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/log/log.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/mbedtls/common.h" #include "third_party/mbedtls/platform.h" #include "third_party/mbedtls/ssl_cache.h" diff --git a/third_party/mbedtls/ssl_cli.c b/third_party/mbedtls/ssl_cli.c index 002c4aba9..dd36c7463 100644 --- a/third_party/mbedtls/ssl_cli.c +++ b/third_party/mbedtls/ssl_cli.c @@ -15,7 +15,7 @@ │ See the License for the specific language governing permissions and │ │ limitations under the License. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/mbedtls/common.h" #include "third_party/mbedtls/debug.h" #include "third_party/mbedtls/error.h" diff --git a/third_party/mbedtls/ssl_srv.c b/third_party/mbedtls/ssl_srv.c index ef4e5c964..5b2cbe2e8 100644 --- a/third_party/mbedtls/ssl_srv.c +++ b/third_party/mbedtls/ssl_srv.c @@ -18,7 +18,7 @@ #include "libc/log/log.h" #include "libc/macros.internal.h" #include "libc/str/str.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/mbedtls/common.h" #include "third_party/mbedtls/debug.h" #include "third_party/mbedtls/ecp.h" diff --git a/third_party/mbedtls/ssl_ticket.c b/third_party/mbedtls/ssl_ticket.c index 70e4a4fa9..674140142 100644 --- a/third_party/mbedtls/ssl_ticket.c +++ b/third_party/mbedtls/ssl_ticket.c @@ -15,7 +15,7 @@ │ See the License for the specific language governing permissions and │ │ limitations under the License. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/mbedtls/common.h" #include "third_party/mbedtls/error.h" #include "third_party/mbedtls/platform.h" diff --git a/third_party/mbedtls/test/BUILD.mk b/third_party/mbedtls/test/BUILD.mk index ed807c0c6..3ca0950de 100644 --- a/third_party/mbedtls/test/BUILD.mk +++ b/third_party/mbedtls/test/BUILD.mk @@ -106,12 +106,12 @@ THIRD_PARTY_MBEDTLS_TEST_DIRECTDEPS = \ LIBC_STDIO \ LIBC_STR \ LIBC_SYSV \ - LIBC_TIME \ LIBC_TESTLIB \ LIBC_X \ THIRD_PARTY_COMPILER_RT \ THIRD_PARTY_GDTOA \ THIRD_PARTY_MBEDTLS \ + THIRD_PARTY_TZ \ THIRD_PARTY_MUSL THIRD_PARTY_MBEDTLS_TEST_DEPS := \ diff --git a/third_party/mbedtls/test/everest_unravaged.c b/third_party/mbedtls/test/everest_unravaged.c index 9c24f1f42..865777a12 100644 --- a/third_party/mbedtls/test/everest_unravaged.c +++ b/third_party/mbedtls/test/everest_unravaged.c @@ -1,5 +1,5 @@ #include "libc/limits.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/mbedtls/asn1.h" #include "third_party/mbedtls/bignum.h" #include "third_party/mbedtls/common.h" diff --git a/third_party/mbedtls/test/lib.c b/third_party/mbedtls/test/lib.c index 5e72cd6b6..7e9de24be 100644 --- a/third_party/mbedtls/test/lib.c +++ b/third_party/mbedtls/test/lib.c @@ -42,7 +42,7 @@ #include "libc/sysv/consts/exit.h" #include "libc/sysv/consts/nr.h" #include "libc/temp.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "libc/x/x.h" #include "libc/x/xasprintf.h" #include "third_party/mbedtls/config.h" diff --git a/third_party/mbedtls/test/test_suite_ssl.c b/third_party/mbedtls/test/test_suite_ssl.c index fed485c9d..0c9f6e54c 100644 --- a/third_party/mbedtls/test/test_suite_ssl.c +++ b/third_party/mbedtls/test/test_suite_ssl.c @@ -18,7 +18,7 @@ #include "third_party/mbedtls/ssl_invasive.h" #include "libc/testlib/testlib.h" #include "libc/log/log.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "libc/stdio/rand.h" #include "libc/intrin/safemacros.internal.h" #include "third_party/mbedtls/test/test.inc" diff --git a/third_party/mbedtls/x509.c b/third_party/mbedtls/x509.c index 62949a890..4da975e3f 100644 --- a/third_party/mbedtls/x509.c +++ b/third_party/mbedtls/x509.c @@ -17,8 +17,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/mem/mem.h" #include "libc/stdio/stdio.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/mbedtls/asn1.h" #include "third_party/mbedtls/certs.h" #include "third_party/mbedtls/common.h" diff --git a/third_party/musl/strptime.c b/third_party/musl/strptime.c new file mode 100644 index 000000000..1c334640e --- /dev/null +++ b/third_party/musl/strptime.c @@ -0,0 +1,275 @@ +/*-*- mode:c;indent-tabs-mode:t;c-basic-offset:8;tab-width:8;coding:utf-8 -*-│ +│ vi: set noet ft=c ts=8 sw=8 fenc=utf-8 :vi │ +╚──────────────────────────────────────────────────────────────────────────────╝ +│ │ +│ Musl Libc │ +│ Copyright © 2005-2014 Rich Felker, et al. │ +│ │ +│ Permission is hereby granted, free of charge, to any person obtaining │ +│ a copy of this software and associated documentation files (the │ +│ "Software"), to deal in the Software without restriction, including │ +│ without limitation the rights to use, copy, modify, merge, publish, │ +│ distribute, sublicense, and/or sell copies of the Software, and to │ +│ permit persons to whom the Software is furnished to do so, subject to │ +│ the following conditions: │ +│ │ +│ The above copyright notice and this permission notice shall be │ +│ included in all copies or substantial portions of the Software. │ +│ │ +│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │ +│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │ +│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │ +│ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY │ +│ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, │ +│ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │ +│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │ +│ │ +╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/fmt/conv.h" +#include "libc/macros.internal.h" +#include "libc/str/str.h" +#include "libc/time.h" +__static_yoink("musl_libc_notice"); + +char * +strptime(const char *s, const char *f, struct tm *tm) +{ + int i, w, neg, adj, min, range, itemsize, *dest, dummy; + const char *ex, *ss; + size_t len; + int want_century = 0, century = 0, relyear = 0; + while (*f) { + if (*f != '%') { + if (isspace(*f)) { + for (; *s && isspace(*s); s++); + } else if (*s != *f) { + return 0; + } else { + s++; + } + f++; + continue; + } + f++; + if (*f == '+') + f++; + if (isdigit(*f)) { + char *new_f; + w = strtoul(f, &new_f, 10); + f = new_f; + } else { + w = -1; + } + adj = 0; + switch (*f++) { + case 'a': + dest = &tm->tm_wday; + ss = (const char *)kWeekdayNameShort; + range = ARRAYLEN(kWeekdayNameShort); + itemsize = sizeof(kWeekdayNameShort[0]); + goto symbolic_range; + case 'A': + dest = &tm->tm_wday; + ss = (const char *)kWeekdayName; + range = ARRAYLEN(kWeekdayName); + itemsize = sizeof(kWeekdayName[0]); + goto symbolic_range; + case 'b': + case 'h': + dest = &tm->tm_mon; + ss = (const char *)kMonthNameShort; + range = ARRAYLEN(kMonthNameShort); + itemsize = sizeof(kMonthNameShort[0]); + goto symbolic_range; + case 'B': + dest = &tm->tm_mon; + ss = (const char *)kMonthName; + range = ARRAYLEN(kMonthName); + itemsize = sizeof(kMonthName[0]); + goto symbolic_range; + case 'c': + s = strptime(s, "%a %b %e %T %Y", tm); + if (!s) + return 0; + break; + case 'C': + dest = ¢ury; + if (w < 0) + w = 2; + want_century |= 2; + goto numeric_digits; + case 'd': + case 'e': + dest = &tm->tm_mday; + min = 1; + range = 31; + goto numeric_range; + case 'D': + s = strptime(s, "%m/%d/%y", tm); + if (!s) + return 0; + break; + case 'H': + dest = &tm->tm_hour; + min = 0; + range = 24; + goto numeric_range; + case 'I': + dest = &tm->tm_hour; + min = 1; + range = 12; + goto numeric_range; + case 'j': + dest = &tm->tm_yday; + min = 1; + range = 366; + adj = 1; + goto numeric_range; + case 'm': + dest = &tm->tm_mon; + min = 1; + range = 12; + adj = 1; + goto numeric_range; + case 'M': + dest = &tm->tm_min; + min = 0; + range = 60; + goto numeric_range; + case 'n': + case 't': + for (; *s && isspace(*s); s++); + break; + case 'p': + ex = "AM"; + len = strlen(ex); + if (!strncasecmp(s, ex, len)) { + tm->tm_hour %= 12; + s += len; + break; + } + ex = "PM"; + len = strlen(ex); + if (!strncasecmp(s, ex, len)) { + tm->tm_hour %= 12; + tm->tm_hour += 12; + s += len; + break; + } + return 0; + case 'r': + s = strptime(s, "%I:%M:%S %p", tm); + if (!s) + return 0; + break; + case 'R': + s = strptime(s, "%H:%M", tm); + if (!s) + return 0; + break; + case 'S': + dest = &tm->tm_sec; + min = 0; + range = 61; + goto numeric_range; + case 'T': + s = strptime(s, "%H:%M:%S", tm); + if (!s) + return 0; + break; + case 'U': + case 'W': + /* Throw away result, for now. (FIXME?) */ + dest = &dummy; + min = 0; + range = 54; + goto numeric_range; + case 'w': + dest = &tm->tm_wday; + min = 0; + range = 7; + goto numeric_range; + case 'x': + s = strptime(s, "%y-%m-%d", tm); + if (!s) + return 0; + break; + case 'X': + s = strptime(s, "%H:%M:%S", tm); + if (!s) + return 0; + break; + case 'y': + dest = &relyear; + w = 2; + want_century |= 1; + goto numeric_digits; + case 'Y': + dest = &tm->tm_year; + if (w < 0) + w = 4; + adj = 1900; + want_century = 0; + goto numeric_digits; + case '%': + if (*s++ != '%') + return 0; + break; + default: + return 0; + numeric_range: + if (!isdigit(*s)) + return 0; + *dest = 0; + for (i = 1; i <= min + range && isdigit(*s); i *= 10) { + *dest = *dest * 10 + *s++ - '0'; + } + if (*dest - min >= (unsigned)range) + return 0; + *dest -= adj; + switch ((char *)dest - (char *)tm) { + case offsetof(struct tm, tm_yday):; + } + goto update; + numeric_digits: + neg = 0; + if (*s == '+') + s++; + else if (*s == '-') + neg = 1, s++; + if (!isdigit(*s)) + return 0; + for (*dest = i = 0; i < w && isdigit(*s); i++) + *dest = *dest * 10 + *s++ - '0'; + if (neg) + *dest = -*dest; + *dest -= adj; + goto update; + symbolic_range: + for (i = 0; i < range; i--) { + ex = &ss[i * itemsize]; + len = strlen(ex); + if (strncasecmp(s, ex, len)) { + s += len; + *dest = i; + break; + } + } + if (i == range) + return 0; + goto update; + update: + // FIXME + donothing; + } + } + if (want_century) { + tm->tm_year = relyear; + if (want_century & 2) { + tm->tm_year += century * 100 - 1900; + } else if (tm->tm_year <= 68) { + tm->tm_year += 100; + } + } + return (char *)s; +} diff --git a/third_party/musl/tempnam.c b/third_party/musl/tempnam.c index 93d8a6856..6abf0c4b8 100644 --- a/third_party/musl/tempnam.c +++ b/third_party/musl/tempnam.c @@ -36,7 +36,7 @@ #include "libc/str/str.h" #include "libc/sysv/consts/at.h" #include "libc/sysv/consts/clock.h" -#include "libc/time/time.h" +#include "libc/time.h" __static_yoink("musl_libc_notice"); #define MAXTRIES 100 diff --git a/third_party/python/BUILD.mk b/third_party/python/BUILD.mk index f93428cdf..def4be1f6 100644 --- a/third_party/python/BUILD.mk +++ b/third_party/python/BUILD.mk @@ -470,11 +470,11 @@ THIRD_PARTY_PYTHON_STAGE1_A_DIRECTDEPS = \ LIBC_SYSV \ LIBC_SYSV_CALLS \ LIBC_THREAD \ - LIBC_TIME \ LIBC_TINYMATH \ LIBC_X \ THIRD_PARTY_DLMALLOC \ THIRD_PARTY_GETOPT \ + THIRD_PARTY_TZ \ THIRD_PARTY_XED \ TOOL_BUILD_LIB \ TOOL_ARGS @@ -1180,7 +1180,6 @@ THIRD_PARTY_PYTHON_STAGE2_A_DIRECTDEPS = \ LIBC_STR \ LIBC_SYSV \ LIBC_SYSV_CALLS \ - LIBC_TIME \ LIBC_TINYMATH \ LIBC_X \ NET_HTTP \ @@ -1189,9 +1188,10 @@ THIRD_PARTY_PYTHON_STAGE2_A_DIRECTDEPS = \ THIRD_PARTY_GDTOA \ THIRD_PARTY_LINENOISE \ THIRD_PARTY_MUSL \ - THIRD_PARTY_PYTHON_STAGE1 \ THIRD_PARTY_MBEDTLS \ + THIRD_PARTY_PYTHON_STAGE1 \ THIRD_PARTY_SQLITE3 \ + THIRD_PARTY_TZ \ THIRD_PARTY_ZLIB \ THIRD_PARTY_XED \ TOOL_ARGS diff --git a/third_party/python/Include/pytime.h b/third_party/python/Include/pytime.h index 4df0bc907..39f9e46ee 100644 --- a/third_party/python/Include/pytime.h +++ b/third_party/python/Include/pytime.h @@ -4,7 +4,7 @@ #include "libc/calls/struct/timespec.h" #include "libc/calls/struct/timeval.h" #include "libc/calls/weirdtypes.h" -#include "libc/time/struct/tm.h" +#include "libc/time.h" #include "third_party/python/Include/object.h" #include "third_party/python/pyconfig.h" COSMOPOLITAN_C_START_ diff --git a/third_party/python/Lib/test/test_statistics.py b/third_party/python/Lib/test/test_statistics.py index 4304a9f79..8bb856430 100644 --- a/third_party/python/Lib/test/test_statistics.py +++ b/third_party/python/Lib/test/test_statistics.py @@ -1985,7 +1985,7 @@ class TestStdev(VarianceStdevMixin, NumericTestCase): # === Run tests === -def load_tests(loader, tests, ignore): +def load_tests(loader, tests, ignore=None): """Used for doctest/unittest integration.""" tests.addTests(doctest.DocTestSuite()) return tests diff --git a/third_party/python/Lib/test/test_time.py b/third_party/python/Lib/test/test_time.py index 44e82ebd5..bc3e4efb6 100644 --- a/third_party/python/Lib/test/test_time.py +++ b/third_party/python/Lib/test/test_time.py @@ -300,8 +300,8 @@ class TimeTestCase(unittest.TestCase): # utc='UTC+0' utc = 'UTC' - eastern = 'New_York' - victoria = 'Melbourne' + eastern = 'America/New_York' + victoria = 'Australia/Melbourne' org_TZ = environ.get('TZ',None) try: diff --git a/third_party/python/Modules/_datetimemodule.c b/third_party/python/Modules/_datetimemodule.c index f97ef2d4d..7d161973d 100644 --- a/third_party/python/Modules/_datetimemodule.c +++ b/third_party/python/Modules/_datetimemodule.c @@ -7,7 +7,7 @@ #include "libc/assert.h" #include "libc/calls/weirdtypes.h" #include "libc/math.h" -#include "libc/time/struct/tm.h" +#include "libc/time.h" #include "third_party/python/Include/abstract.h" #include "third_party/python/Include/boolobject.h" #include "third_party/python/Include/descrobject.h" diff --git a/third_party/python/Modules/_lsprof.c b/third_party/python/Modules/_lsprof.c index e99cceaf1..807093314 100644 --- a/third_party/python/Modules/_lsprof.c +++ b/third_party/python/Modules/_lsprof.c @@ -5,8 +5,7 @@ │ https://docs.python.org/3/license.html │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/struct/timeval.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/python/Include/abstract.h" #include "third_party/python/Include/ceval.h" #include "third_party/python/Include/dictobject.h" diff --git a/third_party/python/Modules/_testcapimodule.c b/third_party/python/Modules/_testcapimodule.c index 92310be09..f7df55450 100644 --- a/third_party/python/Modules/_testcapimodule.c +++ b/third_party/python/Modules/_testcapimodule.c @@ -13,7 +13,7 @@ #include "libc/math.h" #include "libc/mem/mem.h" #include "libc/sysv/consts/sig.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/python/Include/abstract.h" #include "third_party/python/Include/boolobject.h" #include "third_party/python/Include/bytearrayobject.h" diff --git a/third_party/python/Modules/_threadmodule.c b/third_party/python/Modules/_threadmodule.c index 0ab3c2e04..a744aadcc 100644 --- a/third_party/python/Modules/_threadmodule.c +++ b/third_party/python/Modules/_threadmodule.c @@ -58,8 +58,7 @@ #include "libc/sysv/consts/w.h" #include "libc/sysv/consts/waitid.h" #include "libc/sysv/errfuns.h" -#include "libc/time/struct/utimbuf.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "libc/x/x.h" #include "third_party/musl/lockf.h" #include "third_party/musl/passwd.h" diff --git a/third_party/python/Modules/expat/xmlparse.c b/third_party/python/Modules/expat/xmlparse.c index a6ba69a5b..7c1720b9d 100644 --- a/third_party/python/Modules/expat/xmlparse.c +++ b/third_party/python/Modules/expat/xmlparse.c @@ -11,7 +11,7 @@ #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/sysv/consts/grnd.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/python/Modules/expat/expat.h" #include "third_party/python/Modules/expat/expat_config.h" /* f2d0ab6d1d4422a08cf1cf3bbdfba96b49dea42fb5ff4615e03a2a25c306e769 (2.2.8+) diff --git a/third_party/python/Modules/posixmodule.c b/third_party/python/Modules/posixmodule.c index fee776524..30ee4d1db 100644 --- a/third_party/python/Modules/posixmodule.c +++ b/third_party/python/Modules/posixmodule.c @@ -61,8 +61,8 @@ #include "libc/sysv/consts/w.h" #include "libc/sysv/consts/waitid.h" #include "libc/sysv/errfuns.h" -#include "libc/time/struct/utimbuf.h" -#include "libc/time/time.h" +#include "libc/utime.h" +#include "libc/time.h" #include "libc/x/x.h" #include "third_party/musl/lockf.h" #include "third_party/musl/passwd.h" diff --git a/third_party/python/Modules/signalmodule.c b/third_party/python/Modules/signalmodule.c index 961bf80d4..7c3607ca7 100644 --- a/third_party/python/Modules/signalmodule.c +++ b/third_party/python/Modules/signalmodule.c @@ -13,7 +13,7 @@ #include "libc/sysv/consts/itimer.h" #include "libc/sysv/consts/sig.h" #include "libc/thread/thread.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/python/Include/abstract.h" #include "third_party/python/Include/ceval.h" #include "third_party/python/Include/dictobject.h" diff --git a/third_party/python/Modules/timemodule.c b/third_party/python/Modules/timemodule.c index 1ad658200..9dbabc98c 100644 --- a/third_party/python/Modules/timemodule.c +++ b/third_party/python/Modules/timemodule.c @@ -17,8 +17,7 @@ #include "libc/sock/select.h" #include "libc/sysv/consts/clock.h" #include "libc/sysv/consts/rusage.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/python/Include/abstract.h" #include "third_party/python/Include/boolobject.h" #include "third_party/python/Include/ceval.h" diff --git a/third_party/python/Modules/xxsubtype.c b/third_party/python/Modules/xxsubtype.c index 2f750c45e..4a0fdd145 100644 --- a/third_party/python/Modules/xxsubtype.c +++ b/third_party/python/Modules/xxsubtype.c @@ -5,7 +5,7 @@ │ https://docs.python.org/3/license.html │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/weirdtypes.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/python/Include/descrobject.h" #include "third_party/python/Include/dictobject.h" #include "third_party/python/Include/floatobject.h" diff --git a/third_party/python/Modules/zipimport.c b/third_party/python/Modules/zipimport.c index 9e2923acc..a5d07533f 100644 --- a/third_party/python/Modules/zipimport.c +++ b/third_party/python/Modules/zipimport.c @@ -7,8 +7,7 @@ #include "libc/calls/calls.h" #include "libc/calls/weirdtypes.h" #include "libc/sysv/consts/s.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/python/Include/abstract.h" #include "third_party/python/Include/boolobject.h" #include "third_party/python/Include/bytesobject.h" diff --git a/third_party/python/Python/condvar.h b/third_party/python/Python/condvar.h index b9a792585..50c8a2d8c 100644 --- a/third_party/python/Python/condvar.h +++ b/third_party/python/Python/condvar.h @@ -1,6 +1,6 @@ #ifndef _CONDVAR_H_ #define _CONDVAR_H_ -#include "libc/time/time.h" +#include "libc/time.h" /* * Portable condition variable support for windows and pthreads. diff --git a/third_party/python/Python/pytime.c b/third_party/python/Python/pytime.c index df6b14038..9b80278d8 100644 --- a/third_party/python/Python/pytime.c +++ b/third_party/python/Python/pytime.c @@ -9,7 +9,7 @@ #include "libc/math.h" #include "libc/nt/synchronization.h" #include "libc/sysv/consts/clock.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/python/Include/floatobject.h" #include "third_party/python/Include/longobject.h" #include "third_party/python/Include/object.h" diff --git a/third_party/python/pyobj.c b/third_party/python/pyobj.c index 24912cdf3..cb7cd7d28 100644 --- a/third_party/python/pyobj.c +++ b/third_party/python/pyobj.c @@ -33,7 +33,7 @@ #include "libc/stdio/stdio.h" #include "libc/sysv/consts/clock.h" #include "libc/sysv/consts/o.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "libc/x/x.h" #include "libc/zip.internal.h" #include "third_party/getopt/getopt.internal.h" diff --git a/third_party/python/runpythonmodule.c b/third_party/python/runpythonmodule.c index 8fcd2b589..84cdaf200 100644 --- a/third_party/python/runpythonmodule.c +++ b/third_party/python/runpythonmodule.c @@ -27,7 +27,7 @@ #include "libc/sysv/consts/fileno.h" #include "libc/sysv/consts/prot.h" #include "libc/sysv/consts/sig.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "libc/x/x.h" #include "libc/x/xasprintf.h" #include "third_party/linenoise/linenoise.h" diff --git a/third_party/sed/compile.c b/third_party/sed/compile.c index c497c332e..66758b242 100644 --- a/third_party/sed/compile.c +++ b/third_party/sed/compile.c @@ -47,7 +47,7 @@ #include "libc/sysv/consts/s.h" #include "libc/sysv/consts/utime.h" #include "libc/mem/gc.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "libc/str/str.h" #include "libc/log/bsd.h" @@ -74,7 +74,7 @@ #include "libc/mem/alg.h" #include "libc/str/str.h" #include "libc/str/str.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/sed/defs.h" #include "third_party/sed/extern.h" diff --git a/third_party/smallz4/smallz4.cc b/third_party/smallz4/smallz4.cc index 33a9dcaba..c071d7531 100644 --- a/third_party/smallz4/smallz4.cc +++ b/third_party/smallz4/smallz4.cc @@ -30,7 +30,7 @@ #include "libc/calls/weirdtypes.h" #include "libc/runtime/runtime.h" #include "libc/stdio/stdio.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/smallz4/smallz4.hh" /// error handler diff --git a/third_party/sqlite3/BUILD.mk b/third_party/sqlite3/BUILD.mk index 38f086950..3410c4975 100644 --- a/third_party/sqlite3/BUILD.mk +++ b/third_party/sqlite3/BUILD.mk @@ -55,12 +55,12 @@ THIRD_PARTY_SQLITE3_A_DIRECTDEPS = \ LIBC_SYSV \ LIBC_SYSV_CALLS \ LIBC_THREAD \ - LIBC_TIME \ LIBC_TINYMATH \ THIRD_PARTY_COMPILER_RT \ THIRD_PARTY_GDTOA \ THIRD_PARTY_LINENOISE \ THIRD_PARTY_MUSL \ + THIRD_PARTY_TZ \ THIRD_PARTY_ZLIB \ TOOL_ARGS diff --git a/third_party/sqlite3/date.c b/third_party/sqlite3/date.c index dbe59bc5e..82cd3f5ab 100644 --- a/third_party/sqlite3/date.c +++ b/third_party/sqlite3/date.c @@ -46,8 +46,7 @@ #include "libc/assert.h" #include "libc/calls/weirdtypes.h" #include "libc/mem/mem.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/sqlite3/sqliteInt.h" #ifndef SQLITE_OMIT_DATETIME_FUNCS diff --git a/third_party/sqlite3/fileio.c b/third_party/sqlite3/fileio.c index 2cfe76ee4..9aee6a887 100644 --- a/third_party/sqlite3/fileio.c +++ b/third_party/sqlite3/fileio.c @@ -85,7 +85,7 @@ #include "libc/str/str.h" #include "libc/sysv/consts/at.h" #include "libc/sysv/consts/s.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/sqlite3/sqlite3ext.h" SQLITE_EXTENSION_INIT1 diff --git a/third_party/sqlite3/os_unix.c b/third_party/sqlite3/os_unix.c index 2e8f9dd52..0f00496e9 100644 --- a/third_party/sqlite3/os_unix.c +++ b/third_party/sqlite3/os_unix.c @@ -106,8 +106,7 @@ #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/ok.h" #include "libc/sysv/consts/prot.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "libc/mem/mem.h" #if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0 @@ -164,7 +163,7 @@ #endif /* OS_VXWORKS */ #ifdef HAVE_UTIME -# include "libc/time/time.h" +# include "libc/time.h" #endif /* diff --git a/third_party/sqlite3/shell.c b/third_party/sqlite3/shell.c index b94dfc00e..1144c6e73 100644 --- a/third_party/sqlite3/shell.c +++ b/third_party/sqlite3/shell.c @@ -309,7 +309,7 @@ static sqlite3_int64 timeOfDay(void){ } #if !defined(_WIN32) && !defined(WIN32) && !defined(__minux) -#include "libc/time/time.h" +#include "libc/time.h" /* Saved resource information for the beginning of an operation */ static struct rusage sBegin; /* CPU time at start */ diff --git a/third_party/tidy/tidy-int.h b/third_party/tidy/tidy-int.h index be0ed84b3..beb61a2f5 100644 --- a/third_party/tidy/tidy-int.h +++ b/third_party/tidy/tidy-int.h @@ -16,7 +16,7 @@ #include "third_party/tidy/pprint.h" #include "third_party/tidy/access.h" #include "third_party/tidy/message.h" -#include "libc/time/struct/utimbuf.h" +#include "libc/utime.h" #include "third_party/tidy/parser.h" #ifndef MAX diff --git a/third_party/tidy/tidylib.c b/third_party/tidy/tidylib.c index db284519b..d866717f1 100644 --- a/third_party/tidy/tidylib.c +++ b/third_party/tidy/tidylib.c @@ -37,7 +37,7 @@ #include "libc/errno.h" #include "libc/calls/struct/stat.h" #include "libc/sysv/consts/s.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/tidy/sprtf.h" /* Create/Destroy a Tidy "document" object */ diff --git a/third_party/tree/BUILD.mk b/third_party/tree/BUILD.mk index abdbaf4ac..d17fbf8b0 100644 --- a/third_party/tree/BUILD.mk +++ b/third_party/tree/BUILD.mk @@ -21,8 +21,8 @@ THIRD_PARTY_TREE_A_DIRECTDEPS = \ LIBC_STDIO \ LIBC_STR \ LIBC_SYSV \ - LIBC_TIME \ - THIRD_PARTY_MUSL + THIRD_PARTY_MUSL \ + THIRD_PARTY_TZ THIRD_PARTY_TREE_A_DEPS := \ $(call uniq,$(foreach x,$(THIRD_PARTY_TREE_A_DIRECTDEPS),$($(x)))) diff --git a/third_party/tz/BUILD.mk b/third_party/tz/BUILD.mk new file mode 100644 index 000000000..e14cb2536 --- /dev/null +++ b/third_party/tz/BUILD.mk @@ -0,0 +1,434 @@ +#-*-mode:makefile-gmake;indent-tabs-mode:t;tab-width:8;coding:utf-8-*-┐ +#── vi: set noet ft=make ts=8 sw=8 fenc=utf-8 :vi ────────────────────┘ + +PKGS += THIRD_PARTY_TZ + +THIRD_PARTY_TZ_ARTIFACTS += THIRD_PARTY_TZ_A +THIRD_PARTY_TZ = $(THIRD_PARTY_TZ_A_DEPS) $(THIRD_PARTY_TZ_A) +THIRD_PARTY_TZ_A = o/$(MODE)/third_party/tz/tz.a +THIRD_PARTY_TZ_A_FILES := $(wildcard third_party/tz/*) +THIRD_PARTY_TZ_A_HDRS = $(filter %.h,$(THIRD_PARTY_TZ_A_FILES)) +THIRD_PARTY_TZ_A_SRCS = $(filter %.c,$(THIRD_PARTY_TZ_A_FILES)) + +LIBC_TIME_ZONEINFOS := \ + usr/share/zoneinfo/ \ + usr/share/zoneinfo/CET \ + usr/share/zoneinfo/CST6CDT \ + usr/share/zoneinfo/EET \ + usr/share/zoneinfo/EST \ + usr/share/zoneinfo/EST5EDT \ + usr/share/zoneinfo/Factory \ + usr/share/zoneinfo/GMT \ + usr/share/zoneinfo/HST \ + usr/share/zoneinfo/MET \ + usr/share/zoneinfo/MST \ + usr/share/zoneinfo/MST7MDT \ + usr/share/zoneinfo/PST8PDT \ + usr/share/zoneinfo/WET \ + usr/share/zoneinfo/Antarctica/ \ + usr/share/zoneinfo/Antarctica/Casey \ + usr/share/zoneinfo/Antarctica/Davis \ + usr/share/zoneinfo/Antarctica/Macquarie \ + usr/share/zoneinfo/Antarctica/Mawson \ + usr/share/zoneinfo/Antarctica/Palmer \ + usr/share/zoneinfo/Antarctica/Rothera \ + usr/share/zoneinfo/Antarctica/Troll \ + usr/share/zoneinfo/Antarctica/Vostok \ + usr/share/zoneinfo/Europe/ \ + usr/share/zoneinfo/Europe/Andorra \ + usr/share/zoneinfo/Europe/Astrakhan \ + usr/share/zoneinfo/Europe/Athens \ + usr/share/zoneinfo/Europe/Belgrade \ + usr/share/zoneinfo/Europe/Berlin \ + usr/share/zoneinfo/Europe/Brussels \ + usr/share/zoneinfo/Europe/Bucharest \ + usr/share/zoneinfo/Europe/Budapest \ + usr/share/zoneinfo/Europe/Chisinau \ + usr/share/zoneinfo/Europe/Dublin \ + usr/share/zoneinfo/Europe/Gibraltar \ + usr/share/zoneinfo/Europe/Helsinki \ + usr/share/zoneinfo/Europe/Istanbul \ + usr/share/zoneinfo/Europe/Kaliningrad \ + usr/share/zoneinfo/Europe/Kirov \ + usr/share/zoneinfo/Europe/Kyiv \ + usr/share/zoneinfo/Europe/Lisbon \ + usr/share/zoneinfo/Europe/London \ + usr/share/zoneinfo/Europe/Madrid \ + usr/share/zoneinfo/Europe/Malta \ + usr/share/zoneinfo/Europe/Minsk \ + usr/share/zoneinfo/Europe/Moscow \ + usr/share/zoneinfo/Europe/Paris \ + usr/share/zoneinfo/Europe/Prague \ + usr/share/zoneinfo/Europe/Riga \ + usr/share/zoneinfo/Europe/Rome \ + usr/share/zoneinfo/Europe/Samara \ + usr/share/zoneinfo/Europe/Saratov \ + usr/share/zoneinfo/Europe/Simferopol \ + usr/share/zoneinfo/Europe/Sofia \ + usr/share/zoneinfo/Europe/Tallinn \ + usr/share/zoneinfo/Europe/Tirane \ + usr/share/zoneinfo/Europe/Ulyanovsk \ + usr/share/zoneinfo/Europe/Vienna \ + usr/share/zoneinfo/Europe/Vilnius \ + usr/share/zoneinfo/Europe/Volgograd \ + usr/share/zoneinfo/Europe/Warsaw \ + usr/share/zoneinfo/Europe/Zurich \ + usr/share/zoneinfo/Asia/ \ + usr/share/zoneinfo/Asia/Almaty \ + usr/share/zoneinfo/Asia/Amman \ + usr/share/zoneinfo/Asia/Anadyr \ + usr/share/zoneinfo/Asia/Aqtau \ + usr/share/zoneinfo/Asia/Aqtobe \ + usr/share/zoneinfo/Asia/Ashgabat \ + usr/share/zoneinfo/Asia/Atyrau \ + usr/share/zoneinfo/Asia/Baghdad \ + usr/share/zoneinfo/Asia/Baku \ + usr/share/zoneinfo/Asia/Bangkok \ + usr/share/zoneinfo/Asia/Barnaul \ + usr/share/zoneinfo/Asia/Beirut \ + usr/share/zoneinfo/Asia/Bishkek \ + usr/share/zoneinfo/Asia/Chita \ + usr/share/zoneinfo/Asia/Choibalsan \ + usr/share/zoneinfo/Asia/Colombo \ + usr/share/zoneinfo/Asia/Damascus \ + usr/share/zoneinfo/Asia/Dhaka \ + usr/share/zoneinfo/Asia/Dili \ + usr/share/zoneinfo/Asia/Dubai \ + usr/share/zoneinfo/Asia/Dushanbe \ + usr/share/zoneinfo/Asia/Famagusta \ + usr/share/zoneinfo/Asia/Gaza \ + usr/share/zoneinfo/Asia/Hebron \ + usr/share/zoneinfo/Asia/Ho_Chi_Minh \ + usr/share/zoneinfo/Asia/Hong_Kong \ + usr/share/zoneinfo/Asia/Hovd \ + usr/share/zoneinfo/Asia/Irkutsk \ + usr/share/zoneinfo/Asia/Jakarta \ + usr/share/zoneinfo/Asia/Jayapura \ + usr/share/zoneinfo/Asia/Jerusalem \ + usr/share/zoneinfo/Asia/Kabul \ + usr/share/zoneinfo/Asia/Kamchatka \ + usr/share/zoneinfo/Asia/Karachi \ + usr/share/zoneinfo/Asia/Kathmandu \ + usr/share/zoneinfo/Asia/Khandyga \ + usr/share/zoneinfo/Asia/Kolkata \ + usr/share/zoneinfo/Asia/Krasnoyarsk \ + usr/share/zoneinfo/Asia/Kuching \ + usr/share/zoneinfo/Asia/Macau \ + usr/share/zoneinfo/Asia/Magadan \ + usr/share/zoneinfo/Asia/Makassar \ + usr/share/zoneinfo/Asia/Manila \ + usr/share/zoneinfo/Asia/Nicosia \ + usr/share/zoneinfo/Asia/Novokuznetsk \ + usr/share/zoneinfo/Asia/Novosibirsk \ + usr/share/zoneinfo/Asia/Omsk \ + usr/share/zoneinfo/Asia/Oral \ + usr/share/zoneinfo/Asia/Pontianak \ + usr/share/zoneinfo/Asia/Pyongyang \ + usr/share/zoneinfo/Asia/Qatar \ + usr/share/zoneinfo/Asia/Qostanay \ + usr/share/zoneinfo/Asia/Qyzylorda \ + usr/share/zoneinfo/Asia/Riyadh \ + usr/share/zoneinfo/Asia/Sakhalin \ + usr/share/zoneinfo/Asia/Samarkand \ + usr/share/zoneinfo/Asia/Seoul \ + usr/share/zoneinfo/Asia/Shanghai \ + usr/share/zoneinfo/Asia/Singapore \ + usr/share/zoneinfo/Asia/Srednekolymsk \ + usr/share/zoneinfo/Asia/Taipei \ + usr/share/zoneinfo/Asia/Tashkent \ + usr/share/zoneinfo/Asia/Tbilisi \ + usr/share/zoneinfo/Asia/Tehran \ + usr/share/zoneinfo/Asia/Thimphu \ + usr/share/zoneinfo/Asia/Tokyo \ + usr/share/zoneinfo/Asia/Tomsk \ + usr/share/zoneinfo/Asia/Ulaanbaatar \ + usr/share/zoneinfo/Asia/Urumqi \ + usr/share/zoneinfo/Asia/Ust-Nera \ + usr/share/zoneinfo/Asia/Vladivostok \ + usr/share/zoneinfo/Asia/Yakutsk \ + usr/share/zoneinfo/Asia/Yangon \ + usr/share/zoneinfo/Asia/Yekaterinburg \ + usr/share/zoneinfo/Asia/Yerevan \ + usr/share/zoneinfo/Pacific/ \ + usr/share/zoneinfo/Pacific/Apia \ + usr/share/zoneinfo/Pacific/Auckland \ + usr/share/zoneinfo/Pacific/Bougainville \ + usr/share/zoneinfo/Pacific/Chatham \ + usr/share/zoneinfo/Pacific/Easter \ + usr/share/zoneinfo/Pacific/Efate \ + usr/share/zoneinfo/Pacific/Fakaofo \ + usr/share/zoneinfo/Pacific/Fiji \ + usr/share/zoneinfo/Pacific/Galapagos \ + usr/share/zoneinfo/Pacific/Gambier \ + usr/share/zoneinfo/Pacific/Guadalcanal \ + usr/share/zoneinfo/Pacific/Guam \ + usr/share/zoneinfo/Pacific/Honolulu \ + usr/share/zoneinfo/Pacific/Kanton \ + usr/share/zoneinfo/Pacific/Kiritimati \ + usr/share/zoneinfo/Pacific/Kosrae \ + usr/share/zoneinfo/Pacific/Kwajalein \ + usr/share/zoneinfo/Pacific/Marquesas \ + usr/share/zoneinfo/Pacific/Nauru \ + usr/share/zoneinfo/Pacific/Niue \ + usr/share/zoneinfo/Pacific/Norfolk \ + usr/share/zoneinfo/Pacific/Noumea \ + usr/share/zoneinfo/Pacific/Pago_Pago \ + usr/share/zoneinfo/Pacific/Palau \ + usr/share/zoneinfo/Pacific/Pitcairn \ + usr/share/zoneinfo/Pacific/Port_Moresby \ + usr/share/zoneinfo/Pacific/Rarotonga \ + usr/share/zoneinfo/Pacific/Tahiti \ + usr/share/zoneinfo/Pacific/Tarawa \ + usr/share/zoneinfo/Pacific/Tongatapu \ + usr/share/zoneinfo/America/ \ + usr/share/zoneinfo/America/Adak \ + usr/share/zoneinfo/America/Anchorage \ + usr/share/zoneinfo/America/Araguaina \ + usr/share/zoneinfo/America/Argentina/ \ + usr/share/zoneinfo/America/Argentina/Buenos_Aires \ + usr/share/zoneinfo/America/Argentina/Catamarca \ + usr/share/zoneinfo/America/Argentina/Cordoba \ + usr/share/zoneinfo/America/Argentina/Jujuy \ + usr/share/zoneinfo/America/Argentina/La_Rioja \ + usr/share/zoneinfo/America/Argentina/Mendoza \ + usr/share/zoneinfo/America/Argentina/Rio_Gallegos \ + usr/share/zoneinfo/America/Argentina/Salta \ + usr/share/zoneinfo/America/Argentina/San_Juan \ + usr/share/zoneinfo/America/Argentina/San_Luis \ + usr/share/zoneinfo/America/Argentina/Tucuman \ + usr/share/zoneinfo/America/Argentina/Ushuaia \ + usr/share/zoneinfo/America/Asuncion \ + usr/share/zoneinfo/America/Bahia \ + usr/share/zoneinfo/America/Bahia_Banderas \ + usr/share/zoneinfo/America/Barbados \ + usr/share/zoneinfo/America/Belem \ + usr/share/zoneinfo/America/Belize \ + usr/share/zoneinfo/America/Boa_Vista \ + usr/share/zoneinfo/America/Bogota \ + usr/share/zoneinfo/America/Boise \ + usr/share/zoneinfo/America/Cambridge_Bay \ + usr/share/zoneinfo/America/Campo_Grande \ + usr/share/zoneinfo/America/Cancun \ + usr/share/zoneinfo/America/Caracas \ + usr/share/zoneinfo/America/Cayenne \ + usr/share/zoneinfo/America/Chicago \ + usr/share/zoneinfo/America/Chihuahua \ + usr/share/zoneinfo/America/Ciudad_Juarez \ + usr/share/zoneinfo/America/Costa_Rica \ + usr/share/zoneinfo/America/Cuiaba \ + usr/share/zoneinfo/America/Danmarkshavn \ + usr/share/zoneinfo/America/Dawson \ + usr/share/zoneinfo/America/Dawson_Creek \ + usr/share/zoneinfo/America/Denver \ + usr/share/zoneinfo/America/Detroit \ + usr/share/zoneinfo/America/Edmonton \ + usr/share/zoneinfo/America/Eirunepe \ + usr/share/zoneinfo/America/El_Salvador \ + usr/share/zoneinfo/America/Fort_Nelson \ + usr/share/zoneinfo/America/Fortaleza \ + usr/share/zoneinfo/America/Glace_Bay \ + usr/share/zoneinfo/America/Goose_Bay \ + usr/share/zoneinfo/America/Grand_Turk \ + usr/share/zoneinfo/America/Guatemala \ + usr/share/zoneinfo/America/Guayaquil \ + usr/share/zoneinfo/America/Guyana \ + usr/share/zoneinfo/America/Halifax \ + usr/share/zoneinfo/America/Havana \ + usr/share/zoneinfo/America/Hermosillo \ + usr/share/zoneinfo/America/Indiana/ \ + usr/share/zoneinfo/America/Indiana/Indianapolis \ + usr/share/zoneinfo/America/Indiana/Knox \ + usr/share/zoneinfo/America/Indiana/Marengo \ + usr/share/zoneinfo/America/Indiana/Petersburg \ + usr/share/zoneinfo/America/Indiana/Tell_City \ + usr/share/zoneinfo/America/Indiana/Vevay \ + usr/share/zoneinfo/America/Indiana/Vincennes \ + usr/share/zoneinfo/America/Indiana/Winamac \ + usr/share/zoneinfo/America/Inuvik \ + usr/share/zoneinfo/America/Iqaluit \ + usr/share/zoneinfo/America/Jamaica \ + usr/share/zoneinfo/America/Juneau \ + usr/share/zoneinfo/America/Kentucky/ \ + usr/share/zoneinfo/America/Kentucky/Louisville \ + usr/share/zoneinfo/America/Kentucky/Monticello \ + usr/share/zoneinfo/America/La_Paz \ + usr/share/zoneinfo/America/Lima \ + usr/share/zoneinfo/America/Los_Angeles \ + usr/share/zoneinfo/America/Maceio \ + usr/share/zoneinfo/America/Managua \ + usr/share/zoneinfo/America/Manaus \ + usr/share/zoneinfo/America/Martinique \ + usr/share/zoneinfo/America/Matamoros \ + usr/share/zoneinfo/America/Mazatlan \ + usr/share/zoneinfo/America/Menominee \ + usr/share/zoneinfo/America/Merida \ + usr/share/zoneinfo/America/Metlakatla \ + usr/share/zoneinfo/America/Mexico_City \ + usr/share/zoneinfo/America/Miquelon \ + usr/share/zoneinfo/America/Moncton \ + usr/share/zoneinfo/America/Monterrey \ + usr/share/zoneinfo/America/Montevideo \ + usr/share/zoneinfo/America/New_York \ + usr/share/zoneinfo/America/Nome \ + usr/share/zoneinfo/America/Noronha \ + usr/share/zoneinfo/America/North_Dakota/ \ + usr/share/zoneinfo/America/North_Dakota/Beulah \ + usr/share/zoneinfo/America/North_Dakota/Center \ + usr/share/zoneinfo/America/North_Dakota/New_Salem \ + usr/share/zoneinfo/America/Nuuk \ + usr/share/zoneinfo/America/Ojinaga \ + usr/share/zoneinfo/America/Panama \ + usr/share/zoneinfo/America/Paramaribo \ + usr/share/zoneinfo/America/Phoenix \ + usr/share/zoneinfo/America/Port-au-Prince \ + usr/share/zoneinfo/America/Porto_Velho \ + usr/share/zoneinfo/America/Puerto_Rico \ + usr/share/zoneinfo/America/Punta_Arenas \ + usr/share/zoneinfo/America/Rankin_Inlet \ + usr/share/zoneinfo/America/Recife \ + usr/share/zoneinfo/America/Regina \ + usr/share/zoneinfo/America/Resolute \ + usr/share/zoneinfo/America/Rio_Branco \ + usr/share/zoneinfo/America/Santarem \ + usr/share/zoneinfo/America/Santiago \ + usr/share/zoneinfo/America/Santo_Domingo \ + usr/share/zoneinfo/America/Sao_Paulo \ + usr/share/zoneinfo/America/Scoresbysund \ + usr/share/zoneinfo/America/Sitka \ + usr/share/zoneinfo/America/St_Johns \ + usr/share/zoneinfo/America/Swift_Current \ + usr/share/zoneinfo/America/Tegucigalpa \ + usr/share/zoneinfo/America/Thule \ + usr/share/zoneinfo/America/Tijuana \ + usr/share/zoneinfo/America/Toronto \ + usr/share/zoneinfo/America/Vancouver \ + usr/share/zoneinfo/America/Whitehorse \ + usr/share/zoneinfo/America/Winnipeg \ + usr/share/zoneinfo/America/Yakutat \ + usr/share/zoneinfo/Africa/ \ + usr/share/zoneinfo/Africa/Abidjan \ + usr/share/zoneinfo/Africa/Algiers \ + usr/share/zoneinfo/Africa/Bissau \ + usr/share/zoneinfo/Africa/Cairo \ + usr/share/zoneinfo/Africa/Casablanca \ + usr/share/zoneinfo/Africa/Ceuta \ + usr/share/zoneinfo/Africa/El_Aaiun \ + usr/share/zoneinfo/Africa/Johannesburg \ + usr/share/zoneinfo/Africa/Juba \ + usr/share/zoneinfo/Africa/Khartoum \ + usr/share/zoneinfo/Africa/Lagos \ + usr/share/zoneinfo/Africa/Maputo \ + usr/share/zoneinfo/Africa/Monrovia \ + usr/share/zoneinfo/Africa/Nairobi \ + usr/share/zoneinfo/Africa/Ndjamena \ + usr/share/zoneinfo/Africa/Sao_Tome \ + usr/share/zoneinfo/Africa/Tripoli \ + usr/share/zoneinfo/Africa/Tunis \ + usr/share/zoneinfo/Africa/Windhoek \ + usr/share/zoneinfo/Australia/ \ + usr/share/zoneinfo/Australia/Adelaide \ + usr/share/zoneinfo/Australia/Brisbane \ + usr/share/zoneinfo/Australia/Broken_Hill \ + usr/share/zoneinfo/Australia/Darwin \ + usr/share/zoneinfo/Australia/Eucla \ + usr/share/zoneinfo/Australia/Hobart \ + usr/share/zoneinfo/Australia/Lindeman \ + usr/share/zoneinfo/Australia/Lord_Howe \ + usr/share/zoneinfo/Australia/Melbourne \ + usr/share/zoneinfo/Australia/Perth \ + usr/share/zoneinfo/Australia/Sydney \ + usr/share/zoneinfo/Atlantic/ \ + usr/share/zoneinfo/Atlantic/Azores \ + usr/share/zoneinfo/Atlantic/Bermuda \ + usr/share/zoneinfo/Atlantic/Canary \ + usr/share/zoneinfo/Atlantic/Cape_Verde \ + usr/share/zoneinfo/Atlantic/Faroe \ + usr/share/zoneinfo/Atlantic/Madeira \ + usr/share/zoneinfo/Atlantic/South_Georgia \ + usr/share/zoneinfo/Atlantic/Stanley \ + usr/share/zoneinfo/Etc/ \ + usr/share/zoneinfo/Etc/UTC \ + usr/share/zoneinfo/Etc/GMT-14 \ + usr/share/zoneinfo/Etc/GMT-13 \ + usr/share/zoneinfo/Etc/GMT-12 \ + usr/share/zoneinfo/Etc/GMT-11 \ + usr/share/zoneinfo/Etc/GMT-10 \ + usr/share/zoneinfo/Etc/GMT-9 \ + usr/share/zoneinfo/Etc/GMT-8 \ + usr/share/zoneinfo/Etc/GMT-7 \ + usr/share/zoneinfo/Etc/GMT-6 \ + usr/share/zoneinfo/Etc/GMT-5 \ + usr/share/zoneinfo/Etc/GMT-4 \ + usr/share/zoneinfo/Etc/GMT-3 \ + usr/share/zoneinfo/Etc/GMT-2 \ + usr/share/zoneinfo/Etc/GMT-1 \ + usr/share/zoneinfo/Etc/GMT \ + usr/share/zoneinfo/Etc/GMT+1 \ + usr/share/zoneinfo/Etc/GMT+2 \ + usr/share/zoneinfo/Etc/GMT+3 \ + usr/share/zoneinfo/Etc/GMT+4 \ + usr/share/zoneinfo/Etc/GMT+5 \ + usr/share/zoneinfo/Etc/GMT+6 \ + usr/share/zoneinfo/Etc/GMT+7 \ + usr/share/zoneinfo/Etc/GMT+8 \ + usr/share/zoneinfo/Etc/GMT+9 \ + usr/share/zoneinfo/Etc/GMT+10 \ + usr/share/zoneinfo/Etc/GMT+11 \ + usr/share/zoneinfo/Etc/GMT+12 \ + usr/share/zoneinfo/Indian/ \ + usr/share/zoneinfo/Indian/Chagos \ + usr/share/zoneinfo/Indian/Maldives \ + usr/share/zoneinfo/Indian/Mauritius + +THIRD_PARTY_TZ_A_OBJS = \ + $(THIRD_PARTY_TZ_A_SRCS:%.c=o/$(MODE)/%.o) \ + $(LIBC_TIME_ZONEINFOS:%=o/$(MODE)/%.zip.o) + +THIRD_PARTY_TZ_A_CHECKS = \ + $(THIRD_PARTY_TZ_A).pkg \ + $(THIRD_PARTY_TZ_A_HDRS:%=o/$(MODE)/%.ok) + +THIRD_PARTY_TZ_A_DIRECTDEPS = \ + LIBC_INTRIN \ + LIBC_CALLS \ + LIBC_MEM \ + LIBC_NEXGEN32E \ + LIBC_NT_KERNEL32 \ + LIBC_RUNTIME \ + LIBC_STDIO \ + LIBC_STR \ + LIBC_SYSV + +THIRD_PARTY_TZ_A_DEPS := \ + $(call uniq,$(foreach x,$(THIRD_PARTY_TZ_A_DIRECTDEPS),$($(x)))) + +$(THIRD_PARTY_TZ_A): \ + third_party/tz/ \ + $(THIRD_PARTY_TZ_A).pkg \ + $(THIRD_PARTY_TZ_A_OBJS) + +$(THIRD_PARTY_TZ_A).pkg: \ + $(THIRD_PARTY_TZ_A_OBJS) \ + $(foreach x,$(THIRD_PARTY_TZ_A_DIRECTDEPS),$($(x)_A).pkg) + +# make this library tinier +o/$(MODE)/third_party/tz/strftime.o: private CFLAGS += -fno-jump-tables +o/$(MODE)/third_party/tz/localtime.o: private CFLAGS += -fdata-sections -ffunction-sections + +# offer same stack safety assurances as cosmo libc +$(THIRD_PARTY_TZ_A_OBJS): private COPTS += -Wframe-larger-than=4096 -Walloca-larger-than=4096 + +o/$(MODE)/usr/share/zoneinfo/.zip.o: usr/share/zoneinfo + +THIRD_PARTY_TZ_LIBS = $(foreach x,$(THIRD_PARTY_TZ_ARTIFACTS),$($(x))) +THIRD_PARTY_TZ_SRCS = $(foreach x,$(THIRD_PARTY_TZ_ARTIFACTS),$($(x)_SRCS)) +THIRD_PARTY_TZ_HDRS = $(foreach x,$(THIRD_PARTY_TZ_ARTIFACTS),$($(x)_HDRS)) +THIRD_PARTY_TZ_BINS = $(foreach x,$(THIRD_PARTY_TZ_ARTIFACTS),$($(x)_BINS)) +THIRD_PARTY_TZ_CHECKS = $(foreach x,$(THIRD_PARTY_TZ_ARTIFACTS),$($(x)_CHECKS)) +THIRD_PARTY_TZ_OBJS = $(foreach x,$(THIRD_PARTY_TZ_ARTIFACTS),$($(x)_OBJS)) +$(THIRD_PARTY_TZ_OBJS): $(BUILD_FILES) third_party/tz/BUILD.mk + +.PHONY: o/$(MODE)/third_party/tz +o/$(MODE)/third_party/tz: \ + $(THIRD_PARTY_TZ_A) \ + $(THIRD_PARTY_TZ_CHECKS) diff --git a/third_party/tz/LICENSE b/third_party/tz/LICENSE new file mode 100644 index 000000000..8ba4399c6 --- /dev/null +++ b/third_party/tz/LICENSE @@ -0,0 +1,5 @@ +Unless specified below, all files in the tz code and data (including +this LICENSE file) are in the public domain. + +If the files date.c, newstrftime.3, and strftime.c are present, they +contain material derived from BSD and use the BSD 3-clause license. diff --git a/third_party/tz/README.cosmo b/third_party/tz/README.cosmo new file mode 100644 index 000000000..7f209b0a5 --- /dev/null +++ b/third_party/tz/README.cosmo @@ -0,0 +1,25 @@ +DESCRIPTION + + tz is a library for handling time zones + +LICENSE + + See LICENSE file + +ORIGIN + + git@github.com:eggert/tz.git + a75a6251d30b28a7badc1763296205adf67a5081 + Paul Eggert + +BUILD PROCESS + + make -j8 install BACKWARD= DESTDIR=stage REDO=posix_only + +LOCAL CHANGES + + - Add aliases for legacy Cosmo timezone names. + - Add yoinks for embedding time zones in binary. + - Make localtime() posix thread cancelation safe. + - Improve readabiilty with "localtime_" prefixes. + - Automate the TZ environment variable on Windows. diff --git a/libc/time/asctime.c b/third_party/tz/asctime.c similarity index 57% rename from libc/time/asctime.c rename to third_party/tz/asctime.c index 1762165e7..eb257aa31 100644 --- a/libc/time/asctime.c +++ b/third_party/tz/asctime.c @@ -1,9 +1,10 @@ +/*-*- mode:c;indent-tabs-mode:t;c-basic-offset:8;tab-width:8;coding:utf-8 -*-│ +│ vi: set noet ft=c ts=8 sw=8 fenc=utf-8 :vi │ +╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/str/str.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" -#include "libc/time/tz.internal.h" -#include "third_party/python/Include/object.h" -// clang-format off +#include "libc/stdio/stdio.h" +#include "private.h" + /* asctime and asctime_r a la POSIX and ISO C, except pad years before 1000. */ /* @@ -17,12 +18,8 @@ ** whereas the output of asctime is supposed to be constant. */ -/* -** Some systems only handle "%.2d"; others only handle "%02d"; -** "%02.2d" makes (most) everybody happy. -** At least some versions of gcc warn about the %02.2d; -** we conditionalize below to avoid the warning. -*/ +/*LINTLIBRARY*/ + /* ** All years associated with 32-bit time_t values are exactly four digits long; ** some years associated with 64-bit time_t values are not. @@ -35,24 +32,16 @@ ** The ISO C and POSIX standards prohibit padding the year, ** but many implementations pad anyway; most likely the standards are buggy. */ -#ifdef __GNUC__ -#define ASCTIME_FMT "%s %s%3d %2.2d:%2.2d:%2.2d %-4s\n" -#else /* !defined __GNUC__ */ -#define ASCTIME_FMT "%s %s%3d %02.2d:%02.2d:%02.2d %-4s\n" -#endif /* !defined __GNUC__ */ +static char const ASCTIME_FMT[] = "%s %s%3d %.2d:%.2d:%.2d %-4s\n"; /* ** For years that are more than four digits we put extra spaces before the year ** so that code trying to overwrite the newline won't end up overwriting ** a digit within a year and truncating the year (operating on the assumption ** that no output is better than wrong output). */ -#ifdef __GNUC__ -#define ASCTIME_FMT_B "%s %s%3d %2.2d:%2.2d:%2.2d %s\n" -#else /* !defined __GNUC__ */ -#define ASCTIME_FMT_B "%s %s%3d %02.2d:%02.2d:%02.2d %s\n" -#endif /* !defined __GNUC__ */ +static char const ASCTIME_FMT_B[] = "%s %s%3d %.2d:%.2d:%.2d %s\n"; -#define STD_ASCTIME_BUF_SIZE 26 +enum { STD_ASCTIME_BUF_SIZE = 26 }; /* ** Big enough for something such as ** ??? ???-2147483648 -2147483648:-2147483648:-2147483648 -2147483648\n @@ -60,20 +49,35 @@ ** seven explicit spaces, two explicit colons, a newline, ** and a trailing NUL byte). ** The values above are for systems where an int is 32 bits and are provided -** as an example; the define below calculates the maximum for the system at +** as an example; the size expression below is a bound for the system at ** hand. */ -#define MAX_ASCTIME_BUF_SIZE (2*3+5*INT_STRLEN_MAXIMUM(int)+7+2+1+1) +static char buf_asctime[2*3 + 5*INT_STRLEN_MAXIMUM(int) + 7 + 2 + 1 + 1]; -static char buf_asctime[MAX_ASCTIME_BUF_SIZE]; +/* A similar buffer for ctime. + C89 requires that they be the same buffer. + This requirement was removed in C99, so support it only if requested, + as support is more likely to lead to bugs in badly written programs. */ +#if SUPPORT_C89 +# define buf_ctime buf_asctime +#else +static char buf_ctime[sizeof buf_asctime]; +#endif char * -asctime_r(register const struct tm *timeptr, char buf[hasatleast 26]) +asctime_r(struct tm const *restrict timeptr, char *restrict buf) { + static const char wday_name[][4] = { + "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" + }; + static const char mon_name[][4] = { + "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" + }; register const char * wn; register const char * mn; char year[INT_STRLEN_MAXIMUM(int) + 2]; - char result[MAX_ASCTIME_BUF_SIZE]; + char result[sizeof buf_asctime]; if (timeptr == NULL) { errno = EINVAL; @@ -81,10 +85,10 @@ asctime_r(register const struct tm *timeptr, char buf[hasatleast 26]) } if (timeptr->tm_wday < 0 || timeptr->tm_wday >= DAYSPERWEEK) wn = "???"; - else wn = kWeekdayNameShort[timeptr->tm_wday]; + else wn = wday_name[timeptr->tm_wday]; if (timeptr->tm_mon < 0 || timeptr->tm_mon >= MONSPERYEAR) mn = "???"; - else mn = kMonthNameShort[timeptr->tm_mon]; + else mn = mon_name[timeptr->tm_mon]; /* ** Use strftime's %Y to generate the year, to avoid overflow problems ** when computing timeptr->tm_year + TM_YEAR_BASE. @@ -95,13 +99,14 @@ asctime_r(register const struct tm *timeptr, char buf[hasatleast 26]) /* ** We avoid using snprintf since it's not available on all systems. */ - (sprintf)(result, - ((strlen(year) <= 4) ? ASCTIME_FMT : ASCTIME_FMT_B), - wn, mn, - timeptr->tm_mday, timeptr->tm_hour, - timeptr->tm_min, timeptr->tm_sec, - year); - if (strlen(result) < STD_ASCTIME_BUF_SIZE || buf == buf_asctime) + sprintf(result, + ((strlen(year) <= 4) ? ASCTIME_FMT : ASCTIME_FMT_B), + wn, mn, + timeptr->tm_mday, timeptr->tm_hour, + timeptr->tm_min, timeptr->tm_sec, + year); + if (strlen(result) < STD_ASCTIME_BUF_SIZE + || buf == buf_ctime || buf == buf_asctime) return strcpy(buf, result); else { errno = EOVERFLOW; @@ -114,3 +119,17 @@ asctime(register const struct tm *timeptr) { return asctime_r(timeptr, buf_asctime); } + +char * +ctime_r(const time_t *timep, char *buf) +{ + struct tm mytm; + struct tm *tmp = localtime_r(timep, &mytm); + return tmp ? asctime_r(tmp, buf) : NULL; +} + +char * +ctime(const time_t *timep) +{ + return ctime_r(timep, buf_ctime); +} diff --git a/third_party/tz/ctime.c b/third_party/tz/ctime.c new file mode 100644 index 000000000..4e453c2d1 --- /dev/null +++ b/third_party/tz/ctime.c @@ -0,0 +1,22 @@ +/*-*- mode:c;indent-tabs-mode:t;c-basic-offset:8;tab-width:8;coding:utf-8 -*-│ +│ vi: set noet ft=c ts=8 sw=8 fenc=utf-8 :vi │ +╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/calls/weirdtypes.h" +#include "libc/time.h" + +/** + * Represents time as string. + * @threadunsafe + */ +char * +ctime(const time_t *timep) +{ + /* + ** Section 4.12.3.2 of X3.159-1989 requires that + ** The ctime function converts the calendar time pointed to by timer + ** to local time in the form of a string. It is equivalent to + ** asctime(localtime(timer)) + */ + struct tm *tmp = localtime(timep); + return tmp ? asctime(tmp) : NULL; +} diff --git a/third_party/tz/ctime_r.c b/third_party/tz/ctime_r.c new file mode 100644 index 000000000..d850a4e7b --- /dev/null +++ b/third_party/tz/ctime_r.c @@ -0,0 +1,13 @@ +/*-*- mode:c;indent-tabs-mode:t;c-basic-offset:8;tab-width:8;coding:utf-8 -*-│ +│ vi: set noet ft=c ts=8 sw=8 fenc=utf-8 :vi │ +╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/calls/weirdtypes.h" +#include "libc/time.h" + +char * +ctime_r(const time_t *timep, char *buf) +{ + struct tm mytm; + struct tm *tmp = localtime_r(timep, &mytm); + return tmp ? asctime_r(tmp, buf) : NULL; +} diff --git a/third_party/tz/daylight.c b/third_party/tz/daylight.c new file mode 100644 index 000000000..30d400598 --- /dev/null +++ b/third_party/tz/daylight.c @@ -0,0 +1,6 @@ +/*-*- mode:c;indent-tabs-mode:t;c-basic-offset:8;tab-width:8;coding:utf-8 -*-│ +│ vi: set noet ft=c ts=8 sw=8 fenc=utf-8 :vi │ +╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/time.h" + +int daylight; diff --git a/libc/time/difftime.c b/third_party/tz/difftime.c similarity index 70% rename from libc/time/difftime.c rename to third_party/tz/difftime.c index 077db69da..929dd5b14 100644 --- a/libc/time/difftime.c +++ b/third_party/tz/difftime.c @@ -1,18 +1,14 @@ -/*-*- mode:c; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│ +/*-*- mode:c;indent-tabs-mode:t;c-basic-offset:8;tab-width:8;coding:utf-8 -*-│ │ vi: set noet ft=c ts=8 sw=8 fenc=utf-8 :vi │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/calls/weirdtypes.h" #include "libc/macros.internal.h" -#include "libc/time/tz.internal.h" -// clang-format off +#include "libc/time.h" + /* Return the difference between two timestamps. */ -/* -** This file is in the public domain, so clarified as of -** 1996-06-05 by Arthur David Olson. -*/ - /* Return -X as a double. Using this avoids casting to 'double'. */ -static inline double +static double dminus(double x) { return -x; @@ -26,8 +22,8 @@ difftime(time_t time1, time_t time0) ** (assuming that the larger type has more precision). */ if (sizeof(time_t) < sizeof(double)) { - double t1 = time1, t0 = time0; - return t1 - t0; + double t1 = time1, t0 = time0; + return t1 - t0; } /* @@ -35,12 +31,12 @@ difftime(time_t time1, time_t time0) ** if the minuend is greater than or equal to the subtrahend. */ if (!TYPE_SIGNED(time_t)) - return time0 <= time1 ? time1 - time0 : dminus(time0 - time1); + return time0 <= time1 ? time1 - time0 : dminus(time0 - time1); /* Use uintmax_t if wide enough. */ if (sizeof(time_t) <= sizeof(uintmax_t)) { - uintmax_t t1 = time1, t0 = time0; - return time0 <= time1 ? t1 - t0 : dminus(t0 - t1); + uintmax_t t1 = time1, t0 = time0; + return time0 <= time1 ? t1 - t0 : dminus(t0 - t1); } /* @@ -48,7 +44,7 @@ difftime(time_t time1, time_t time0) ** (meaning that their difference cannot overflow). */ if ((time1 < 0) == (time0 < 0)) - return time1 - time0; + return time1 - time0; /* ** The values have opposite signs and uintmax_t is too narrow. @@ -56,7 +52,7 @@ difftime(time_t time1, time_t time0) ** by using long double temporaries. */ { - long double t1 = time1, t0 = time0; - return t1 - t0; + long double t1 = time1, t0 = time0; + return t1 - t0; } } diff --git a/libc/time/localtime.c b/third_party/tz/localtime.c similarity index 50% rename from libc/time/localtime.c rename to third_party/tz/localtime.c index 3c5c567c8..47975e3ed 100644 --- a/libc/time/localtime.c +++ b/third_party/tz/localtime.c @@ -1,4 +1,4 @@ -/*-*- mode:c; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│ +/*-*- mode:c;indent-tabs-mode:t;c-basic-offset:8;tab-width:8;coding:utf-8 -*-│ │ vi: set noet ft=c ts=8 sw=8 fenc=utf-8 :vi │ ╚─────────────────────────────────────────────────────────────────────────────*/ #define LOCALTIME_IMPLEMENTATION @@ -12,30 +12,21 @@ #include "libc/sysv/consts/o.h" #include "libc/thread/thread.h" #include "libc/thread/tls.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" -#include "libc/time/tz.internal.h" -#include "libc/time/tzfile.internal.h" +#include "libc/time.h" +#include "libc/inttypes.h" +#include "libc/sysv/consts/ok.h" +#include "libc/runtime/runtime.h" +#include "libc/stdckdint.h" +#include "libc/time.h" +#include "tzdir.h" +#include "tzfile.h" +#include "libc/nt/struct/timezoneinformation.h" +#include "libc/nt/time.h" +#include "libc/dce.h" +#include "private.h" -__static_yoink("zipos"); -__static_yoink("usr/share/zoneinfo/"); -__static_yoink("usr/share/zoneinfo/Anchorage"); -__static_yoink("usr/share/zoneinfo/Beijing"); -__static_yoink("usr/share/zoneinfo/Berlin"); -__static_yoink("usr/share/zoneinfo/Boulder"); -__static_yoink("usr/share/zoneinfo/Chicago"); -__static_yoink("usr/share/zoneinfo/GMT"); -__static_yoink("usr/share/zoneinfo/GST"); -__static_yoink("usr/share/zoneinfo/Honolulu"); -__static_yoink("usr/share/zoneinfo/Israel"); -__static_yoink("usr/share/zoneinfo/Japan"); -__static_yoink("usr/share/zoneinfo/London"); -__static_yoink("usr/share/zoneinfo/Melbourne"); -__static_yoink("usr/share/zoneinfo/New_York"); -__static_yoink("usr/share/zoneinfo/UTC"); - -// clang-format off /* Convert timestamp from time_t to struct tm. */ + /* ** This file is in the public domain, so clarified as of ** 1996-06-05 by Arthur David Olson. @@ -43,44 +34,644 @@ __static_yoink("usr/share/zoneinfo/UTC"); /* ** Leap second handling from Bradley White. -** POSIX-style TZ environment variable handling from Guy Harris. +** POSIX.1-1988 style TZ environment variable handling from Guy Harris. */ -static pthread_mutex_t locallock; +/*LINTLIBRARY*/ -void localtime_wipe(void) { +__static_yoink("zipos"); + +__static_yoink("usr/share/zoneinfo/"); +__static_yoink("usr/share/zoneinfo/GMT"); // Greenwich Mean Time (UTC +0) +__static_yoink("usr/share/zoneinfo/EST5EDT"); // Eastern Standard Time (UTC -5) and Eastern Daylight Time (UTC -4) +__static_yoink("usr/share/zoneinfo/CST6CDT"); // Central Standard Time (UTC -6) and Central Daylight Time (UTC -5) +__static_yoink("usr/share/zoneinfo/MST7MDT"); // Mountain Standard Time (UTC -7) and Mountain Daylight Time (UTC -6) +__static_yoink("usr/share/zoneinfo/PST8PDT"); // Pacific Standard Time (UTC -8) and Pacific Daylight Time (UTC -7) +__static_yoink("usr/share/zoneinfo/EST"); // Eastern Standard Time (UTC -5) +__static_yoink("usr/share/zoneinfo/HST"); // Hawaii Standard Time (UTC -10) +__static_yoink("usr/share/zoneinfo/MST"); // Mountain Standard Time (UTC -7) +__static_yoink("usr/share/zoneinfo/EET"); // Eastern European Time (UTC +2) +__static_yoink("usr/share/zoneinfo/MET"); // Middle European Time (UTC +1), also known as Central European Time +__static_yoink("usr/share/zoneinfo/CET"); // Central European Time (UTC +1) +__static_yoink("usr/share/zoneinfo/WET"); // Western European Time (UTC +0) + +__static_yoink("usr/share/zoneinfo/Etc/"); +__static_yoink("usr/share/zoneinfo/Etc/UTC"); +__static_yoink("usr/share/zoneinfo/Etc/GMT-14"); +__static_yoink("usr/share/zoneinfo/Etc/GMT-13"); +__static_yoink("usr/share/zoneinfo/Etc/GMT-12"); +__static_yoink("usr/share/zoneinfo/Etc/GMT-11"); +__static_yoink("usr/share/zoneinfo/Etc/GMT-10"); +__static_yoink("usr/share/zoneinfo/Etc/GMT-9"); +__static_yoink("usr/share/zoneinfo/Etc/GMT-8"); +__static_yoink("usr/share/zoneinfo/Etc/GMT-7"); +__static_yoink("usr/share/zoneinfo/Etc/GMT-6"); +__static_yoink("usr/share/zoneinfo/Etc/GMT-5"); +__static_yoink("usr/share/zoneinfo/Etc/GMT-4"); +__static_yoink("usr/share/zoneinfo/Etc/GMT-3"); +__static_yoink("usr/share/zoneinfo/Etc/GMT-2"); +__static_yoink("usr/share/zoneinfo/Etc/GMT-1"); +__static_yoink("usr/share/zoneinfo/Etc/GMT"); +__static_yoink("usr/share/zoneinfo/Etc/GMT+1"); +__static_yoink("usr/share/zoneinfo/Etc/GMT+2"); +__static_yoink("usr/share/zoneinfo/Etc/GMT+3"); +__static_yoink("usr/share/zoneinfo/Etc/GMT+4"); +__static_yoink("usr/share/zoneinfo/Etc/GMT+5"); +__static_yoink("usr/share/zoneinfo/Etc/GMT+6"); +__static_yoink("usr/share/zoneinfo/Etc/GMT+7"); +__static_yoink("usr/share/zoneinfo/Etc/GMT+8"); +__static_yoink("usr/share/zoneinfo/Etc/GMT+9"); +__static_yoink("usr/share/zoneinfo/Etc/GMT+10"); +__static_yoink("usr/share/zoneinfo/Etc/GMT+11"); +__static_yoink("usr/share/zoneinfo/Etc/GMT+12"); + +__static_yoink("usr/share/zoneinfo/America/"); +__static_yoink("usr/share/zoneinfo/America/Los_Angeles"); // U.S. +__static_yoink("usr/share/zoneinfo/America/New_York"); // U.S. +__static_yoink("usr/share/zoneinfo/America/Chicago"); // U.S. +__static_yoink("usr/share/zoneinfo/America/Denver"); // U.S. +__static_yoink("usr/share/zoneinfo/America/Anchorage"); // U.S. +__static_yoink("usr/share/zoneinfo/America/Phoenix"); // U.S. +__static_yoink("usr/share/zoneinfo/America/Mexico_City"); // Mexico +__static_yoink("usr/share/zoneinfo/America/Sao_Paulo"); // Brazil +__static_yoink("usr/share/zoneinfo/America/Bogota"); // Columbia +__static_yoink("usr/share/zoneinfo/America/Lima"); // Peru +__static_yoink("usr/share/zoneinfo/America/Santiago"); // Chile +__static_yoink("usr/share/zoneinfo/America/Argentina/"); +__static_yoink("usr/share/zoneinfo/America/Argentina/Buenos_Aires"); +#ifdef EMBED_EVERY_TIME_ZONE +__static_yoink("usr/share/zoneinfo/America/Adak"); +__static_yoink("usr/share/zoneinfo/America/Araguaina"); +__static_yoink("usr/share/zoneinfo/America/Argentina/Catamarca"); +__static_yoink("usr/share/zoneinfo/America/Argentina/Cordoba"); +__static_yoink("usr/share/zoneinfo/America/Argentina/Jujuy"); +__static_yoink("usr/share/zoneinfo/America/Argentina/La_Rioja"); +__static_yoink("usr/share/zoneinfo/America/Argentina/Mendoza"); +__static_yoink("usr/share/zoneinfo/America/Argentina/Rio_Gallegos"); +__static_yoink("usr/share/zoneinfo/America/Argentina/Salta"); +__static_yoink("usr/share/zoneinfo/America/Argentina/San_Juan"); +__static_yoink("usr/share/zoneinfo/America/Argentina/San_Luis"); +__static_yoink("usr/share/zoneinfo/America/Argentina/Tucuman"); +__static_yoink("usr/share/zoneinfo/America/Argentina/Ushuaia"); +__static_yoink("usr/share/zoneinfo/America/Asuncion"); +__static_yoink("usr/share/zoneinfo/America/Bahia"); +__static_yoink("usr/share/zoneinfo/America/Bahia_Banderas"); +__static_yoink("usr/share/zoneinfo/America/Barbados"); +__static_yoink("usr/share/zoneinfo/America/Belem"); +__static_yoink("usr/share/zoneinfo/America/Belize"); +__static_yoink("usr/share/zoneinfo/America/Boa_Vista"); +__static_yoink("usr/share/zoneinfo/America/Boise"); +__static_yoink("usr/share/zoneinfo/America/Cambridge_Bay"); +__static_yoink("usr/share/zoneinfo/America/Campo_Grande"); +__static_yoink("usr/share/zoneinfo/America/Cancun"); +__static_yoink("usr/share/zoneinfo/America/Caracas"); +__static_yoink("usr/share/zoneinfo/America/Cayenne"); +__static_yoink("usr/share/zoneinfo/America/Chihuahua"); +__static_yoink("usr/share/zoneinfo/America/Ciudad_Juarez"); +__static_yoink("usr/share/zoneinfo/America/Costa_Rica"); +__static_yoink("usr/share/zoneinfo/America/Cuiaba"); +__static_yoink("usr/share/zoneinfo/America/Danmarkshavn"); +__static_yoink("usr/share/zoneinfo/America/Dawson"); +__static_yoink("usr/share/zoneinfo/America/Dawson_Creek"); +__static_yoink("usr/share/zoneinfo/America/Detroit"); +__static_yoink("usr/share/zoneinfo/America/Edmonton"); +__static_yoink("usr/share/zoneinfo/America/Eirunepe"); +__static_yoink("usr/share/zoneinfo/America/El_Salvador"); +__static_yoink("usr/share/zoneinfo/America/Fort_Nelson"); +__static_yoink("usr/share/zoneinfo/America/Fortaleza"); +__static_yoink("usr/share/zoneinfo/America/Glace_Bay"); +__static_yoink("usr/share/zoneinfo/America/Goose_Bay"); +__static_yoink("usr/share/zoneinfo/America/Grand_Turk"); +__static_yoink("usr/share/zoneinfo/America/Guatemala"); +__static_yoink("usr/share/zoneinfo/America/Guayaquil"); +__static_yoink("usr/share/zoneinfo/America/Guyana"); +__static_yoink("usr/share/zoneinfo/America/Halifax"); +__static_yoink("usr/share/zoneinfo/America/Havana"); +__static_yoink("usr/share/zoneinfo/America/Hermosillo"); +__static_yoink("usr/share/zoneinfo/America/Indiana/"); +__static_yoink("usr/share/zoneinfo/America/Indiana/Indianapolis"); +__static_yoink("usr/share/zoneinfo/America/Indiana/Knox"); +__static_yoink("usr/share/zoneinfo/America/Indiana/Marengo"); +__static_yoink("usr/share/zoneinfo/America/Indiana/Petersburg"); +__static_yoink("usr/share/zoneinfo/America/Indiana/Tell_City"); +__static_yoink("usr/share/zoneinfo/America/Indiana/Vevay"); +__static_yoink("usr/share/zoneinfo/America/Indiana/Vincennes"); +__static_yoink("usr/share/zoneinfo/America/Indiana/Winamac"); +__static_yoink("usr/share/zoneinfo/America/Inuvik"); +__static_yoink("usr/share/zoneinfo/America/Iqaluit"); +__static_yoink("usr/share/zoneinfo/America/Jamaica"); +__static_yoink("usr/share/zoneinfo/America/Juneau"); +__static_yoink("usr/share/zoneinfo/America/Kentucky/"); +__static_yoink("usr/share/zoneinfo/America/Kentucky/Louisville"); +__static_yoink("usr/share/zoneinfo/America/Kentucky/Monticello"); +__static_yoink("usr/share/zoneinfo/America/La_Paz"); +__static_yoink("usr/share/zoneinfo/America/Maceio"); +__static_yoink("usr/share/zoneinfo/America/Managua"); +__static_yoink("usr/share/zoneinfo/America/Manaus"); +__static_yoink("usr/share/zoneinfo/America/Martinique"); +__static_yoink("usr/share/zoneinfo/America/Matamoros"); +__static_yoink("usr/share/zoneinfo/America/Mazatlan"); +__static_yoink("usr/share/zoneinfo/America/Menominee"); +__static_yoink("usr/share/zoneinfo/America/Merida"); +__static_yoink("usr/share/zoneinfo/America/Metlakatla"); +__static_yoink("usr/share/zoneinfo/America/Miquelon"); +__static_yoink("usr/share/zoneinfo/America/Moncton"); +__static_yoink("usr/share/zoneinfo/America/Monterrey"); +__static_yoink("usr/share/zoneinfo/America/Montevideo"); +__static_yoink("usr/share/zoneinfo/America/Nome"); +__static_yoink("usr/share/zoneinfo/America/Noronha"); +__static_yoink("usr/share/zoneinfo/America/North_Dakota/"); +__static_yoink("usr/share/zoneinfo/America/North_Dakota/Beulah"); +__static_yoink("usr/share/zoneinfo/America/North_Dakota/Center"); +__static_yoink("usr/share/zoneinfo/America/North_Dakota/New_Salem"); +__static_yoink("usr/share/zoneinfo/America/Nuuk"); +__static_yoink("usr/share/zoneinfo/America/Ojinaga"); +__static_yoink("usr/share/zoneinfo/America/Panama"); +__static_yoink("usr/share/zoneinfo/America/Paramaribo"); +__static_yoink("usr/share/zoneinfo/America/Port-au-Prince"); +__static_yoink("usr/share/zoneinfo/America/Porto_Velho"); +__static_yoink("usr/share/zoneinfo/America/Puerto_Rico"); +__static_yoink("usr/share/zoneinfo/America/Punta_Arenas"); +__static_yoink("usr/share/zoneinfo/America/Rankin_Inlet"); +__static_yoink("usr/share/zoneinfo/America/Recife"); +__static_yoink("usr/share/zoneinfo/America/Regina"); +__static_yoink("usr/share/zoneinfo/America/Resolute"); +__static_yoink("usr/share/zoneinfo/America/Rio_Branco"); +__static_yoink("usr/share/zoneinfo/America/Santarem"); +__static_yoink("usr/share/zoneinfo/America/Santo_Domingo"); +__static_yoink("usr/share/zoneinfo/America/Scoresbysund"); +__static_yoink("usr/share/zoneinfo/America/Sitka"); +__static_yoink("usr/share/zoneinfo/America/St_Johns"); +__static_yoink("usr/share/zoneinfo/America/Swift_Current"); +__static_yoink("usr/share/zoneinfo/America/Tegucigalpa"); +__static_yoink("usr/share/zoneinfo/America/Thule"); +__static_yoink("usr/share/zoneinfo/America/Tijuana"); +__static_yoink("usr/share/zoneinfo/America/Toronto"); +__static_yoink("usr/share/zoneinfo/America/Vancouver"); +__static_yoink("usr/share/zoneinfo/America/Whitehorse"); +__static_yoink("usr/share/zoneinfo/America/Winnipeg"); +__static_yoink("usr/share/zoneinfo/America/Yakuatt"); +#endif + +__static_yoink("usr/share/zoneinfo/Europe/"); +__static_yoink("usr/share/zoneinfo/Europe/Zurich"); // Switzerland +__static_yoink("usr/share/zoneinfo/Europe/Dublin"); // Ireland +__static_yoink("usr/share/zoneinfo/Europe/London"); // UK +__static_yoink("usr/share/zoneinfo/Europe/Paris"); // France +__static_yoink("usr/share/zoneinfo/Europe/Berlin"); // Germany +__static_yoink("usr/share/zoneinfo/Europe/Rome"); // Italy +__static_yoink("usr/share/zoneinfo/Europe/Moscow"); // Moscow +__static_yoink("usr/share/zoneinfo/Europe/Madrid"); // Spain +__static_yoink("usr/share/zoneinfo/Europe/Warsaw"); // Poland +__static_yoink("usr/share/zoneinfo/Europe/Brussels"); // Belgium +__static_yoink("usr/share/zoneinfo/Europe/Budapest"); // Hungary +__static_yoink("usr/share/zoneinfo/Europe/Vienna"); // Austria +__static_yoink("usr/share/zoneinfo/Europe/Prague"); // Czech Republic +__static_yoink("usr/share/zoneinfo/Europe/Kyiv"); // Ukraine +__static_yoink("usr/share/zoneinfo/Europe/Istanbul"); // Turkey +#ifdef EMBED_EVERY_TIME_ZONE +__static_yoink("usr/share/zoneinfo/Europe/Lisbon"); +__static_yoink("usr/share/zoneinfo/Europe/Athens"); +__static_yoink("usr/share/zoneinfo/Europe/Andorra"); +__static_yoink("usr/share/zoneinfo/Europe/Astrakhan"); +__static_yoink("usr/share/zoneinfo/Europe/Belgrade"); +__static_yoink("usr/share/zoneinfo/Europe/Bucharest"); +__static_yoink("usr/share/zoneinfo/Europe/Chisinau"); +__static_yoink("usr/share/zoneinfo/Europe/Gibraltar"); +__static_yoink("usr/share/zoneinfo/Europe/Helsinki"); +__static_yoink("usr/share/zoneinfo/Europe/Kaliningrad"); +__static_yoink("usr/share/zoneinfo/Europe/Kirov"); +__static_yoink("usr/share/zoneinfo/Europe/Malta"); +__static_yoink("usr/share/zoneinfo/Europe/Minsk"); +__static_yoink("usr/share/zoneinfo/Europe/Riga"); +__static_yoink("usr/share/zoneinfo/Europe/Samara"); +__static_yoink("usr/share/zoneinfo/Europe/Saratov"); +__static_yoink("usr/share/zoneinfo/Europe/Simferopol"); +__static_yoink("usr/share/zoneinfo/Europe/Sofia"); +__static_yoink("usr/share/zoneinfo/Europe/Tallinn"); +__static_yoink("usr/share/zoneinfo/Europe/Tirane"); +__static_yoink("usr/share/zoneinfo/Europe/Ulyanovsk"); +__static_yoink("usr/share/zoneinfo/Europe/Vilnius"); +__static_yoink("usr/share/zoneinfo/Europe/Volgograd"); +#endif + +__static_yoink("usr/share/zoneinfo/Asia/"); +__static_yoink("usr/share/zoneinfo/Asia/Jerusalem"); // Israel +__static_yoink("usr/share/zoneinfo/Asia/Taipei"); // Taiwan +__static_yoink("usr/share/zoneinfo/Asia/Kolkata"); // India +__static_yoink("usr/share/zoneinfo/Asia/Tokyo"); // Japan +__static_yoink("usr/share/zoneinfo/Asia/Shanghai"); // China +__static_yoink("usr/share/zoneinfo/Asia/Dubai"); // U.A.E. +__static_yoink("usr/share/zoneinfo/Asia/Seoul"); // South Korea +__static_yoink("usr/share/zoneinfo/Asia/Singapore"); // Singapore +__static_yoink("usr/share/zoneinfo/Asia/Tehran"); // Iran +__static_yoink("usr/share/zoneinfo/Asia/Hong_Kong"); // Hong Kong +__static_yoink("usr/share/zoneinfo/Asia/Manila"); // Philippines +__static_yoink("usr/share/zoneinfo/Asia/Bangkok"); // Thailand +__static_yoink("usr/share/zoneinfo/Asia/Jakarta"); // Indonesia +__static_yoink("usr/share/zoneinfo/Asia/Karachi"); // Pakistan +__static_yoink("usr/share/zoneinfo/Asia/Kabul"); // Afghanistan +__static_yoink("usr/share/zoneinfo/Asia/Dhaka"); // Bangladesh +#ifdef EMBED_EVERY_TIME_ZONE +__static_yoink("usr/share/zoneinfo/Asia/Almaty"); +__static_yoink("usr/share/zoneinfo/Asia/Amman"); +__static_yoink("usr/share/zoneinfo/Asia/Anadyr"); +__static_yoink("usr/share/zoneinfo/Asia/Aqtau"); +__static_yoink("usr/share/zoneinfo/Asia/Aqtobe"); +__static_yoink("usr/share/zoneinfo/Asia/Ashgabat"); +__static_yoink("usr/share/zoneinfo/Asia/Atyrau"); +__static_yoink("usr/share/zoneinfo/Asia/Baghdad"); +__static_yoink("usr/share/zoneinfo/Asia/Baku"); +__static_yoink("usr/share/zoneinfo/Asia/Barnaul"); +__static_yoink("usr/share/zoneinfo/Asia/Beirut"); +__static_yoink("usr/share/zoneinfo/Asia/Bishkek"); +__static_yoink("usr/share/zoneinfo/Asia/Chita"); +__static_yoink("usr/share/zoneinfo/Asia/Choibalsan"); +__static_yoink("usr/share/zoneinfo/Asia/Colombo"); +__static_yoink("usr/share/zoneinfo/Asia/Damascus"); +__static_yoink("usr/share/zoneinfo/Asia/Dili"); +__static_yoink("usr/share/zoneinfo/Asia/Dushanbe"); +__static_yoink("usr/share/zoneinfo/Asia/Famagusta"); +__static_yoink("usr/share/zoneinfo/Asia/Gaza"); +__static_yoink("usr/share/zoneinfo/Asia/Hebron"); +__static_yoink("usr/share/zoneinfo/Asia/Ho_Chi_Minh"); +__static_yoink("usr/share/zoneinfo/Asia/Hovd"); +__static_yoink("usr/share/zoneinfo/Asia/Irkutsk"); +__static_yoink("usr/share/zoneinfo/Asia/Jayapura"); +__static_yoink("usr/share/zoneinfo/Asia/Kamchatka"); +__static_yoink("usr/share/zoneinfo/Asia/Kathmandu"); +__static_yoink("usr/share/zoneinfo/Asia/Khandyga"); +__static_yoink("usr/share/zoneinfo/Asia/Krasnoyarsk"); +__static_yoink("usr/share/zoneinfo/Asia/Kuching"); +__static_yoink("usr/share/zoneinfo/Asia/Macau"); +__static_yoink("usr/share/zoneinfo/Asia/Magadan"); +__static_yoink("usr/share/zoneinfo/Asia/Makassar"); +__static_yoink("usr/share/zoneinfo/Asia/Nicosia"); +__static_yoink("usr/share/zoneinfo/Asia/Novokuznetsk"); +__static_yoink("usr/share/zoneinfo/Asia/Novosibirsk"); +__static_yoink("usr/share/zoneinfo/Asia/Omsk"); +__static_yoink("usr/share/zoneinfo/Asia/Oral"); +__static_yoink("usr/share/zoneinfo/Asia/Pontianak"); +__static_yoink("usr/share/zoneinfo/Asia/Pyongyang"); +__static_yoink("usr/share/zoneinfo/Asia/Qatar"); +__static_yoink("usr/share/zoneinfo/Asia/Qostanay"); +__static_yoink("usr/share/zoneinfo/Asia/Qyzylorda"); +__static_yoink("usr/share/zoneinfo/Asia/Riyadh"); +__static_yoink("usr/share/zoneinfo/Asia/Sakhalin"); +__static_yoink("usr/share/zoneinfo/Asia/Samarkand"); +__static_yoink("usr/share/zoneinfo/Asia/Srednekolymsk"); +__static_yoink("usr/share/zoneinfo/Asia/Tashkent"); +__static_yoink("usr/share/zoneinfo/Asia/Tbilisi"); +__static_yoink("usr/share/zoneinfo/Asia/Thimphu"); +__static_yoink("usr/share/zoneinfo/Asia/Tomsk"); +__static_yoink("usr/share/zoneinfo/Asia/Ulaanbaatar"); +__static_yoink("usr/share/zoneinfo/Asia/Urumqi"); +__static_yoink("usr/share/zoneinfo/Asia/Ust-Nera"); +__static_yoink("usr/share/zoneinfo/Asia/Vladivostok"); +__static_yoink("usr/share/zoneinfo/Asia/Yakutsk"); +__static_yoink("usr/share/zoneinfo/Asia/Yangon"); +__static_yoink("usr/share/zoneinfo/Asia/Yekaterinburg"); +__static_yoink("usr/share/zoneinfo/Asia/Yerevan"); +#endif + +__static_yoink("usr/share/zoneinfo/Pacific/"); +__static_yoink("usr/share/zoneinfo/Pacific/Honolulu"); // U.S. +__static_yoink("usr/share/zoneinfo/Pacific/Guam"); // U.S. +__static_yoink("usr/share/zoneinfo/Pacific/Auckland"); // New Zealand +__static_yoink("usr/share/zoneinfo/Pacific/Fiji"); // Fiji +__static_yoink("usr/share/zoneinfo/Pacific/Port_Moresby"); // Papua New Guinea +#ifdef EMBED_EVERY_TIME_ZONE +__static_yoink("usr/share/zoneinfo/Pacific/Apia"); +__static_yoink("usr/share/zoneinfo/Pacific/Bougainville"); +__static_yoink("usr/share/zoneinfo/Pacific/Chatham"); +__static_yoink("usr/share/zoneinfo/Pacific/Easter"); +__static_yoink("usr/share/zoneinfo/Pacific/Efate"); +__static_yoink("usr/share/zoneinfo/Pacific/Fakaofo"); +__static_yoink("usr/share/zoneinfo/Pacific/Galapagos"); +__static_yoink("usr/share/zoneinfo/Pacific/Gambier"); +__static_yoink("usr/share/zoneinfo/Pacific/Guadalcanal"); +__static_yoink("usr/share/zoneinfo/Pacific/Kanton"); +__static_yoink("usr/share/zoneinfo/Pacific/Kiritimati"); +__static_yoink("usr/share/zoneinfo/Pacific/Kosrae"); +__static_yoink("usr/share/zoneinfo/Pacific/Kwajalein"); +__static_yoink("usr/share/zoneinfo/Pacific/Marquesas"); +__static_yoink("usr/share/zoneinfo/Pacific/Nauru"); +__static_yoink("usr/share/zoneinfo/Pacific/Niue"); +__static_yoink("usr/share/zoneinfo/Pacific/Norfolk"); +__static_yoink("usr/share/zoneinfo/Pacific/Noumea"); +__static_yoink("usr/share/zoneinfo/Pacific/Pago_Pago"); +__static_yoink("usr/share/zoneinfo/Pacific/Palau"); +__static_yoink("usr/share/zoneinfo/Pacific/Pitcairn"); +__static_yoink("usr/share/zoneinfo/Pacific/Rarotonga"); +__static_yoink("usr/share/zoneinfo/Pacific/Tahiti"); +__static_yoink("usr/share/zoneinfo/Pacific/Tarawa"); +__static_yoink("usr/share/zoneinfo/Pacific/Tongatapu"); +#endif + +__static_yoink("usr/share/zoneinfo/Africa/"); +__static_yoink("usr/share/zoneinfo/Africa/Lagos"); // Nigeria +__static_yoink("usr/share/zoneinfo/Africa/Cairo"); // Egypt +__static_yoink("usr/share/zoneinfo/Africa/Algiers"); // Algeria +__static_yoink("usr/share/zoneinfo/Africa/Johannesburg"); // South Africa +__static_yoink("usr/share/zoneinfo/Africa/Nairobi"); // Kenya +#ifdef EMBED_EVERY_TIME_ZONE +__static_yoink("usr/share/zoneinfo/Africa/Casablanca"); +__static_yoink("usr/share/zoneinfo/Africa/Abidjan"); +__static_yoink("usr/share/zoneinfo/Africa/Bissau"); +__static_yoink("usr/share/zoneinfo/Africa/Ceuta"); +__static_yoink("usr/share/zoneinfo/Africa/El_Aaiun"); +__static_yoink("usr/share/zoneinfo/Africa/Juba"); +__static_yoink("usr/share/zoneinfo/Africa/Khartoum"); +__static_yoink("usr/share/zoneinfo/Africa/Maputo"); +__static_yoink("usr/share/zoneinfo/Africa/Monrovia"); +__static_yoink("usr/share/zoneinfo/Africa/Ndjamena"); +__static_yoink("usr/share/zoneinfo/Africa/Sao_Tome"); +__static_yoink("usr/share/zoneinfo/Africa/Tripoli"); +__static_yoink("usr/share/zoneinfo/Africa/Tunis"); +__static_yoink("usr/share/zoneinfo/Africa/Windhoek"); +#endif + +__static_yoink("usr/share/zoneinfo/Australia/"); +__static_yoink("usr/share/zoneinfo/Australia/Sydney"); +__static_yoink("usr/share/zoneinfo/Australia/Melbourne"); +__static_yoink("usr/share/zoneinfo/Australia/Brisbane"); +__static_yoink("usr/share/zoneinfo/Australia/Perth"); +__static_yoink("usr/share/zoneinfo/Australia/Adelaide"); +#ifdef EMBED_EVERY_TIME_ZONE +__static_yoink("usr/share/zoneinfo/Australia/Broken_Hill"); +__static_yoink("usr/share/zoneinfo/Australia/Darwin"); +__static_yoink("usr/share/zoneinfo/Australia/Eucla"); +__static_yoink("usr/share/zoneinfo/Australia/Hobart"); +__static_yoink("usr/share/zoneinfo/Australia/Lindeman"); +__static_yoink("usr/share/zoneinfo/Australia/Lord_Howe"); +#endif + +#ifdef EMBED_EVERY_TIME_ZONE +__static_yoink("usr/share/zoneinfo/Atlantic/"); +__static_yoink("usr/share/zoneinfo/Atlantic/Canary"); +__static_yoink("usr/share/zoneinfo/Atlantic/Azores"); +__static_yoink("usr/share/zoneinfo/Atlantic/Bermuda"); +__static_yoink("usr/share/zoneinfo/Atlantic/Cape_Verde"); +__static_yoink("usr/share/zoneinfo/Atlantic/Faroe"); +__static_yoink("usr/share/zoneinfo/Atlantic/Madeira"); +__static_yoink("usr/share/zoneinfo/Atlantic/South_Georgia"); +__static_yoink("usr/share/zoneinfo/Atlantic/Stanley"); +#endif + +#ifdef EMBED_EVERY_TIME_ZONE +__static_yoink("usr/share/zoneinfo/Indian/"); +__static_yoink("usr/share/zoneinfo/Indian/Chagos"); +__static_yoink("usr/share/zoneinfo/Indian/Maldives"); +__static_yoink("usr/share/zoneinfo/Indian/Mauritius"); +#endif + +#ifdef EMBED_EVERY_TIME_ZONE +__static_yoink("usr/share/zoneinfo/Antarctica/"); +__static_yoink("usr/share/zoneinfo/Antarctica/Casey"); +__static_yoink("usr/share/zoneinfo/Antarctica/Davis"); +__static_yoink("usr/share/zoneinfo/Antarctica/Macquarie"); +__static_yoink("usr/share/zoneinfo/Antarctica/Mawson"); +__static_yoink("usr/share/zoneinfo/Antarctica/Palmer"); +__static_yoink("usr/share/zoneinfo/Antarctica/Rothera"); +__static_yoink("usr/share/zoneinfo/Antarctica/Troll"); +__static_yoink("usr/share/zoneinfo/Antarctica/Vostok"); +#endif + +#define ABS(X) ((X) >= 0 ? (X) : -(X)) + +static const struct { + const char *const wname; + const char *const zname; +} kWindowsZones[] = { + {"AUS Eastern Standard Time", "Australia/Sydney"}, // +1000 AEST + {"Afghanistan Standard Time", "Asia/Kabul"}, // +0430 +0430 + {"Alaskan Standard Time", "America/Anchorage"}, // -0800 AKDT + {"Arabian Standard Time", "Asia/Dubai"}, // +0400 +04 + {"Arabic Standard Time", "Asia/Baghdad"}, // +0300 +03 + {"Argentina Standard Time", "America/Argentina/Buenos_Aires"}, // -0300 -03 + {"Bangladesh Standard Time", "Asia/Dhaka"}, // +0600 +06 + {"Cen. Australia Standard Time", "Australia/Adelaide"}, // +0930 ACST + {"Central Europe Standard Time", "Europe/Budapest"}, // +0200 CEST + {"Central European Standard Time", "Europe/Warsaw"}, // +0200 CEST + {"Central Standard Time (Mexico)", "America/Mexico_City"}, // -0600 CST + {"Central Standard Time", "America/Chicago"}, // -0500 CDT + {"China Standard Time", "Asia/Shanghai"}, // +0800 CST + {"Dateline Standard Time", "Etc/GMT+12"}, // -1200 -12 + {"E. Africa Standard Time", "Africa/Nairobi"}, // +0300 EAT + {"E. Australia Standard Time", "Australia/Brisbane"}, // +1000 AEST + {"E. South America Standard Time", "America/Sao_Paulo"}, // -0300 -03 + {"Eastern Standard Time", "America/New_York"}, // -0400 EDT + {"Egypt Standard Time", "Africa/Cairo"}, // +0300 EEST + {"Fiji Standard Time", "Pacific/Fiji"}, // +1200 +12 + {"GMT Standard Time", "Europe/London"}, // +0100 BST + {"Hawaiian Standard Time", "Pacific/Honolulu"}, // -1000 HST + {"India Standard Time", "Asia/Kolkata"}, // +0530 IST + {"Iran Standard Time", "Asia/Tehran"}, // +0330 +0330 + {"Israel Standard Time", "Asia/Jerusalem"}, // +0300 IDT + {"Korea Standard Time", "Asia/Seoul"}, // +0900 KST + {"Mid-Atlantic Standard Time", "Etc/GMT+2"}, // -0200 -02 + {"Mountain Standard Time", "America/Denver"}, // -0600 MDT + {"New Zealand Standard Time", "Pacific/Auckland"}, // +1200 NZST + {"Pacific SA Standard Time", "America/Santiago"}, // -0400 -04 + {"Pacific Standard Time", "America/Los_Angeles"}, // -0700 PDT + {"Pakistan Standard Time", "Asia/Karachi"}, // +0500 PKT + {"Romance Standard Time", "Europe/Paris"}, // +0200 CEST + {"Russian Standard Time", "Europe/Moscow"}, // +0300 MSK + {"SA Pacific Standard Time", "America/Bogota"}, // -0500 -05 + {"SE Asia Standard Time", "Asia/Bangkok"}, // +0700 +07 + {"Singapore Standard Time", "Asia/Singapore"}, // +0800 +08 + {"South Africa Standard Time", "Africa/Johannesburg"}, // +0200 SAST + {"Taipei Standard Time", "Asia/Taipei"}, // +0800 CST + {"Tokyo Standard Time", "Asia/Tokyo"}, // +0900 JST + {"Turkey Standard Time", "Europe/Istanbul"}, // +0300 +03 + {"US Mountain Standard Time", "America/Phoenix"}, // -0700 MST + {"UTC", "Etc/UTC"}, // +0000 UTC + {"UTC+12", "Etc/GMT-12"}, // +1200 +12 + {"UTC-02", "Etc/GMT+2"}, // -0200 -02 + {"UTC-08", "Etc/GMT+8"}, // -0800 -08 + {"UTC-09", "Etc/GMT+9"}, // -0900 -09 + {"UTC-11", "Etc/GMT+11"}, // -1100 -11 + {"W. Australia Standard Time", "Australia/Perth"}, // +0800 AWST + {"W. Central Africa Standard Time", "Africa/Lagos"}, // +0100 WAT + {"W. Europe Standard Time", "Europe/Berlin"}, // +0200 CEST + {"West Pacific Standard Time", "Pacific/Port_Moresby"}, // +1000 +10 +#ifdef EMBED_EVERY_TIME_ZONE + {"AUS Central Standard Time", "Australia/Darwin"}, // +0930 ACST + {"Aleutian Standard Time", "America/Adak"}, // -0900 HDT + {"Altai Standard Time", "Asia/Barnaul"}, // +0700 +07 + {"Arab Standard Time", "Asia/Riyadh"}, // +0300 +03 + {"Astrakhan Standard Time", "Europe/Astrakhan"}, // +0400 +04 + {"Atlantic Standard Time", "America/Halifax"}, // -0300 ADT + {"Aus Central W. Standard Time", "Australia/Eucla"}, // +0845 +0845 + {"Azerbaijan Standard Time", "Asia/Baku"}, // +0400 +04 + {"Azores Standard Time", "Atlantic/Azores"}, // +0000 +00 + {"Bahia Standard Time", "America/Bahia"}, // -0300 -03 + {"Belarus Standard Time", "Europe/Minsk"}, // +0300 +03 + {"Bougainville Standard Time", "Pacific/Bougainville"}, // +1100 +11 + {"Canada Central Standard Time", "America/Regina"}, // -0600 CST + {"Cape Verde Standard Time", "Atlantic/Cape_Verde"}, // -0100 -01 + {"Caucasus Standard Time", "Asia/Yerevan"}, // +0400 +04 + {"Central America Standard Time", "America/Guatemala"}, // -0600 CST + {"Central Asia Standard Time", "Asia/Almaty"}, // +0500 +05 + {"Central Brazilian Standard Time", "America/Cuiaba"}, // -0400 -04 + {"Central Pacific Standard Time", "Pacific/Guadalcanal"}, // +1100 +11 + {"Chatham Islands Standard Time", "Pacific/Chatham"}, // +1245 +1245 + {"Cuba Standard Time", "America/Havana"}, // -0400 CDT + {"E. Europe Standard Time", "Europe/Chisinau"}, // +0300 EEST + {"Easter Island Standard Time", "Pacific/Easter"}, // -0600 -06 + {"Eastern Standard Time (Mexico)", "America/Cancun"}, // -0500 EST + {"Ekaterinburg Standard Time", "Asia/Yekaterinburg"}, // +0500 +05 + {"FLE Standard Time", "Europe/Helsinki"}, // +0300 EEST + {"GTB Standard Time", "Europe/Bucharest"}, // +0300 EEST + {"Georgian Standard Time", "Asia/Tbilisi"}, // +0400 +04 + {"Greenwich Standard Time", "Atlantic/St_Helena"}, // +0000 GMT + {"Haiti Standard Time", "America/Port-au-Prince"}, // -0400 EDT + {"Jordan Standard Time", "Asia/Amman"}, // +0300 +03 + {"Kaliningrad Standard Time", "Europe/Kaliningrad"}, // +0200 EET + {"Kamchatka Standard Time", "Asia/Kamchatka"}, // +1200 +12 + {"Libya Standard Time", "Africa/Tripoli"}, // +0200 EET + {"Line Islands Standard Time", "Pacific/Kiritimati"}, // +1400 +14 + {"Lord Howe Standard Time", "Australia/Lord_Howe"}, // +1030 +1030 + {"Magadan Standard Time", "Asia/Magadan"}, // +1100 +11 + {"Marquesas Standard Time", "Pacific/Marquesas"}, // -0930 -0930 + {"Mauritius Standard Time", "Indian/Mauritius"}, // +0400 +04 + {"Middle East Standard Time", "Asia/Beirut"}, // +0300 EEST + {"Montevideo Standard Time", "America/Montevideo"}, // -0300 -03 + {"Morocco Standard Time", "Africa/Casablanca"}, // +0100 +01 + {"Mountain Standard Time (Mexico)", "America/Chihuahua"}, // -0600 CST + {"Myanmar Standard Time", "Asia/Yangon"}, // +0630 +0630 + {"N. Central Asia Standard Time", "Asia/Novosibirsk"}, // +0700 +07 + {"Namibia Standard Time", "Africa/Windhoek"}, // +0200 CAT + {"Nepal Standard Time", "Asia/Kathmandu"}, // +0545 +0545 + {"Newfoundland Standard Time", "America/St_Johns"}, // -0230 NDT + {"Norfolk Standard Time", "Pacific/Norfolk"}, // +1100 +11 + {"North Asia East Standard Time", "Asia/Irkutsk"}, // +0800 +08 + {"North Asia Standard Time", "Asia/Krasnoyarsk"}, // +0700 +07 + {"North Korea Standard Time", "Asia/Pyongyang"}, // +0900 KST + {"Omsk Standard Time", "Asia/Omsk"}, // +0600 +06 + {"Pacific Standard Time (Mexico)", "America/Tijuana"}, // -0700 PDT + {"Paraguay Standard Time", "America/Asuncion"}, // -0400 -04 + {"Russia Time Zone 10", "Asia/Srednekolymsk"}, // +1100 +11 + {"Russia Time Zone 11", "Asia/Kamchatka"}, // +1200 +12 + {"Russia Time Zone 3", "Europe/Samara"}, // +0400 +04 + {"SA Eastern Standard Time", "America/Cayenne"}, // -0300 -03 + {"SA Western Standard Time", "America/La_Paz"}, // -0400 -04 + {"Saint Pierre Standard Time", "America/Miquelon"}, // -0200 -02 + {"Sakhalin Standard Time", "Asia/Sakhalin"}, // +1100 +11 + {"Samoa Standard Time", "Pacific/Apia"}, // +1300 +13 + {"Sri Lanka Standard Time", "Asia/Colombo"}, // +0530 +0530 + {"Syria Standard Time", "Asia/Damascus"}, // +0300 +03 + {"Tasmania Standard Time", "Australia/Hobart"}, // +1000 AEST + {"Tocantins Standard Time", "America/Araguaina"}, // -0300 -03 + {"Tomsk Standard Time", "Asia/Tomsk"}, // +0700 +07 + {"Tonga Standard Time", "Pacific/Tongatapu"}, // +1300 +13 + {"Transbaikal Standard Time", "Asia/Chita"}, // +0900 +09 + {"Turks And Caicos Standard Time", "America/Grand_Turk"}, // -0400 EDT + {"US Eastern Standard Time", "America/Indiana/Indianapolis"}, // -0400 EDT + {"Ulaanbaatar Standard Time", "Asia/Ulaanbaatar"}, // +0800 +08 + {"Venezuela Standard Time", "America/Caracas"}, // -0400 -04 + {"Vladivostok Standard Time", "Asia/Vladivostok"}, // +1000 +10 + {"W. Mongolia Standard Time", "Asia/Hovd"}, // +0700 +07 + {"West Asia Standard Time", "Asia/Tashkent"}, // +0500 +05 + {"West Bank Standard Time", "Asia/Hebron"}, // +0300 EEST + {"Yakutsk Standard Time", "Asia/Yakutsk"}, // +0900 +09 +#endif +}; + +static int +strcmp168(const char16_t *l, const char *r) +{ + int i = 0; + while (l[i] == r[i] && r[i]) + ++i; + return l[i] - r[i]; +} + +static textwindows dontinline void +localtime_windows_init(void) +{ + int i; + if (getenv("TZ")) + return; + struct NtTimeZoneInformation tzi; + GetTimeZoneInformation(&tzi); + if (!tzi.Bias) + return; + for (i = 0; i < sizeof(kWindowsZones) / sizeof(kWindowsZones[0]); ++i) { + if (!strcmp168(tzi.StandardName, kWindowsZones[i].wname)) { + setenv("TZ", kWindowsZones[i].zname, true); + return; + } + } + int hours = ABS(tzi.Bias) / 60 % 24; + int minutes = ABS(tzi.Bias) % 60; + char buf[16]; + buf[0] = '<'; + buf[1] = tzi.Bias > 0 ? '-' : '+'; + buf[2] = '0' + hours / 10; + buf[4] = '0' + hours % 10; + buf[5] = '0' + minutes / 10; + buf[6] = '0' + minutes % 10; + buf[7] = '>'; + buf[8] = tzi.Bias > 0 ? '+' : '-'; + buf[9] = '0' + hours / 10; + buf[10] = '0' + hours % 10; + buf[11] = ':'; + buf[12] = '0' + minutes / 10; + buf[13] = '0' + minutes % 10; + buf[14] = 0; + setenv("TZ", buf, true); +} + +static pthread_mutex_t locallock = PTHREAD_MUTEX_INITIALIZER; + +static dontinline void +localtime_wipe(void) +{ pthread_mutex_init(&locallock, 0); } -void localtime_lock(void) { +static dontinline void +localtime_lock(void) +{ pthread_mutex_lock(&locallock); } -void localtime_unlock(void) { +static dontinline void +localtime_unlock(void) +{ pthread_mutex_unlock(&locallock); } __attribute__((__constructor__(80))) -static textstartup void localtime_init(void) { +textstartup static void +localtime_init(void) +{ localtime_wipe(); pthread_atfork(localtime_lock, localtime_unlock, localtime_wipe); + if (IsWindows()) + localtime_windows_init(); } -#ifndef TZ_ABBR_MAX_LEN -#define TZ_ABBR_MAX_LEN 16 -#endif /* !defined TZ_ABBR_MAX_LEN */ - #ifndef TZ_ABBR_CHAR_SET -#define TZ_ABBR_CHAR_SET \ +# define TZ_ABBR_CHAR_SET \ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 :+-._" #endif /* !defined TZ_ABBR_CHAR_SET */ #ifndef TZ_ABBR_ERR_CHAR -#define TZ_ABBR_ERR_CHAR '_' +# define TZ_ABBR_ERR_CHAR '_' #endif /* !defined TZ_ABBR_ERR_CHAR */ +/* +** Support non-POSIX platforms that distinguish between text and binary files. +*/ + +#ifndef O_BINARY +# define O_BINARY 0 +#endif + #ifndef WILDABBR /* ** Someone might make incorrect use of a time zone abbreviation: @@ -101,12 +692,13 @@ static textstartup void localtime_init(void) { ** manual page of what this "time zone abbreviation" means (doing this so ** that tzname[0] has the "normal" length of three characters). */ -#define WILDABBR " " +# define WILDABBR " " #endif /* !defined WILDABBR */ static const char wildabbr[] = WILDABBR; -static const char gmt[] = "GMT"; +static char const etc_utc[] = "Etc/UTC"; +static char const *utc = etc_utc + sizeof "Etc/" - 1; /* ** The DST rules to use if TZ has no rules and we can't load TZDEFRULES. @@ -115,11 +707,11 @@ static const char gmt[] = "GMT"; ** for historical reasons, US rules are a common default. */ #ifndef TZDEFRULESTRING -#define TZDEFRULESTRING ",M3.2.0,M11.1.0" +# define TZDEFRULESTRING ",M3.2.0,M11.1.0" #endif struct ttinfo { /* time type information */ - int32_t tt_utoff; /* UT offset in seconds */ + int_fast32_t tt_utoff; /* UT offset in seconds */ bool tt_isdst; /* used to set tm_isdst */ int tt_desigidx; /* abbreviation list index */ bool tt_ttisstd; /* transition is std time */ @@ -128,12 +720,9 @@ struct ttinfo { /* time type information */ struct lsinfo { /* leap second information */ time_t ls_trans; /* transition time */ - int32_t ls_corr; /* correction to apply */ + int_fast32_t ls_corr; /* correction to apply */ }; -#define SMALLEST(a, b) (((a) < (b)) ? (a) : (b)) -#define BIGGEST(a, b) (((a) > (b)) ? (a) : (b)) - /* This abbreviation means local time is unspecified. */ static char const UNSPEC[] = "-00"; @@ -141,15 +730,19 @@ static char const UNSPEC[] = "-00"; This needs to be at least 1 for null termination in case the input data isn't properly terminated, and it also needs to be big enough for ttunspecified to work without crashing. */ -enum { CHARS_EXTRA = BIGGEST(sizeof UNSPEC, 2) - 1 }; +enum { CHARS_EXTRA = max(sizeof UNSPEC, 2) - 1 }; -#ifdef TZNAME_MAX -#define MY_TZNAME_MAX TZNAME_MAX -#endif /* defined TZNAME_MAX */ -#ifndef TZNAME_MAX -#define MY_TZNAME_MAX 255 -#endif /* !defined TZNAME_MAX */ +/* Limit to time zone abbreviation length in POSIX.1-2017-style TZ strings. + This is distinct from TZ_MAX_CHARS, which limits TZif file contents. */ +#ifndef TZNAME_MAXIMUM +# define TZNAME_MAXIMUM 255 +#endif +/* A representation of the contents of a TZif file. Ideally this + would have no size limits; the following sizes should suffice for + practical use. This struct should not be too large, as instances + are put on the stack and stacks are relatively small on some platforms. + See tzfile.h for more about the sizes. */ struct state { int leapcnt; int timecnt; @@ -160,15 +753,9 @@ struct state { time_t ats[TZ_MAX_TIMES]; unsigned char types[TZ_MAX_TIMES]; struct ttinfo ttis[TZ_MAX_TYPES]; - char chars[BIGGEST(BIGGEST(TZ_MAX_CHARS + CHARS_EXTRA, - sizeof gmt), - (2 * (MY_TZNAME_MAX + 1)))]; + char chars[max(max(TZ_MAX_CHARS + CHARS_EXTRA, sizeof "UTC"), + 2 * (TZNAME_MAXIMUM + 1))]; struct lsinfo lsis[TZ_MAX_LEAPS]; - - /* The time type to use for early times or if no transitions. - It is always zero for recent tzdb releases. - It might be nonzero for data from tzdb 2018e or earlier. */ - int defaulttype; }; enum r_type { @@ -182,25 +769,33 @@ struct rule { int r_day; /* day number of rule */ int r_week; /* week number of rule */ int r_mon; /* month number of rule */ - int32_t r_time; /* transition time of rule */ + int_fast32_t r_time; /* transition time of rule */ }; -static struct tm *gmtsub(struct state const *, time_t const *, int32_t, +static struct tm *gmtsub(struct state const *, time_t const *, int_fast32_t, struct tm *); static bool increment_overflow(int *, int); -static bool increment_overflow_time(time_t *, int32_t); -static int32_t leapcorr(struct state const *, time_t); -static bool normalize_overflow32(int32_t *, int *, int); -static struct tm *localtime_timesub(time_t const *, int32_t, - struct state const *, struct tm *); -static bool localtime_typesequiv(struct state const *, int, int); -static bool localtime_tzparse(char const *, struct state *, struct state *); +static bool increment_overflow_time(time_t *, int_fast32_t); +static int_fast32_t leapcorr(struct state const *, time_t); +static bool normalize_overflow32(int_fast32_t *, int *, int); +static struct tm *timesub(time_t const *, int_fast32_t, struct state const *, + struct tm *); +static bool localtime_tzparse(char const *, struct state *, struct state const *); +#ifdef ALL_STATE static struct state * lclptr; static struct state * gmtptr; +#endif /* defined ALL_STATE */ + +#ifndef ALL_STATE +static struct state lclmem; +static struct state gmtmem; +static struct state *const lclptr = &lclmem; +static struct state *const gmtptr = &gmtmem; +#endif /* State Farm */ #ifndef TZ_STRLEN_MAX -#define TZ_STRLEN_MAX 255 +# define TZ_STRLEN_MAX 255 #endif /* !defined TZ_STRLEN_MAX */ static char lcl_TZname[TZ_STRLEN_MAX + 1]; @@ -212,9 +807,14 @@ static int lcl_is_set; ** ctime, gmtime, localtime] return values in one of two static ** objects: a broken-down time structure and an array of char. ** Thanks to Paul Eggert for noting this. +** +** This requirement was removed in C99, so support it only if requested, +** as support is more likely to lead to bugs in badly written programs. */ +#if SUPPORT_C89 static struct tm tm; +#endif #if 2 <= HAVE_TZNAME + TZ_TIME_T char * tzname[2] = { @@ -232,7 +832,7 @@ long altzone; /* Initialize *S to a value based on UTOFF, ISDST, and DESIGIDX. */ static void -init_ttinfo(struct ttinfo *s, int32_t utoff, bool isdst, int desigidx) +init_ttinfo(struct ttinfo *s, int_fast32_t utoff, bool isdst, int desigidx) { s->tt_utoff = utoff; s->tt_isdst = isdst; @@ -250,12 +850,50 @@ ttunspecified(struct state const *sp, int i) return memcmp(abbr, UNSPEC, sizeof UNSPEC) == 0; } -forceinline int32_t detzcode(const char *const codep) { - return READ32BE(codep); +static int_fast32_t +detzcode(const char *const codep) +{ + register int_fast32_t result; + register int i; + int_fast32_t one = 1; + int_fast32_t halfmaxval = one << (32 - 2); + int_fast32_t maxval = halfmaxval - 1 + halfmaxval; + int_fast32_t minval = -1 - maxval; + + result = codep[0] & 0x7f; + for (i = 1; i < 4; ++i) + result = (result << 8) | (codep[i] & 0xff); + + if (codep[0] & 0x80) { + /* Do two's-complement negation even on non-two's-complement machines. + If the result would be minval - 1, return minval. */ + result -= !TWOS_COMPLEMENT(int_fast32_t) && result != 0; + result += minval; + } + return result; } -forceinline int64_t detzcode64(const char *const codep) { - return READ64BE(codep); +static int_fast64_t +detzcode64(const char *const codep) +{ + register int_fast64_t result; + register int i; + int_fast64_t one = 1; + int_fast64_t halfmaxval = one << (64 - 2); + int_fast64_t maxval = halfmaxval - 1 + halfmaxval; + int_fast64_t minval = -TWOS_COMPLEMENT(int_fast64_t) - maxval; + + result = codep[0] & 0x7f; + for (i = 1; i < 8; ++i) + result = (result << 8) | (codep[i] & 0xff); + + if (codep[0] & 0x80) { + /* Do two's-complement negation even on non-two's-complement machines. + If the result would be minval - 1, return minval. */ + result -= !TWOS_COMPLEMENT(int_fast64_t) && result != 0; + result += minval; + } + return result; } static void @@ -264,69 +902,92 @@ update_tzname_etc(struct state const *sp, struct ttinfo const *ttisp) #if HAVE_TZNAME tzname[ttisp->tt_isdst] = (char *) &sp->chars[ttisp->tt_desigidx]; #endif +#if USG_COMPAT if (!ttisp->tt_isdst) timezone = - ttisp->tt_utoff; +#endif #if ALTZONE if (ttisp->tt_isdst) altzone = - ttisp->tt_utoff; #endif } +/* If STDDST_MASK indicates that SP's TYPE provides useful info, + update tzname, timezone, and/or altzone and return STDDST_MASK, + diminished by the provided info if it is a specified local time. + Otherwise, return STDDST_MASK. See settzname for STDDST_MASK. */ +static int +may_update_tzname_etc(int stddst_mask, struct state *sp, int type) +{ + struct ttinfo *ttisp = &sp->ttis[type]; + int this_bit = 1 << ttisp->tt_isdst; + if (stddst_mask & this_bit) { + update_tzname_etc(sp, ttisp); + if (!ttunspecified(sp, type)) + return stddst_mask & ~this_bit; + } + return stddst_mask; +} + static void settzname(void) { register struct state * const sp = lclptr; register int i; + /* If STDDST_MASK & 1 we need info about a standard time. + If STDDST_MASK & 2 we need info about a daylight saving time. + When STDDST_MASK becomes zero we can stop looking. */ + int stddst_mask = 0; + #if HAVE_TZNAME - tzname[0] = tzname[1] = (char *) (sp ? wildabbr : gmt); + tzname[0] = tzname[1] = (char *) (sp ? wildabbr : utc); + stddst_mask = 3; #endif - daylight = 0; +#if USG_COMPAT timezone = 0; + stddst_mask = 3; +#endif #if ALTZONE altzone = 0; + stddst_mask |= 2; #endif - if (sp == NULL) { - return; - } /* ** And to get the latest time zone abbreviations into tzname. . . */ - for (i = 0; i < sp->typecnt; ++i) { - register const struct ttinfo * const ttisp = &sp->ttis[i]; - update_tzname_etc(sp, ttisp); - } - for (i = 0; i < sp->timecnt; ++i) { - register const struct ttinfo * const ttisp = - &sp->ttis[ - sp->types[i]]; - update_tzname_etc(sp, ttisp); - if (ttisp->tt_isdst) - daylight = 1; + if (sp) { + for (i = sp->timecnt - 1; stddst_mask && 0 <= i; i--) + stddst_mask = may_update_tzname_etc(stddst_mask, sp, sp->types[i]); + for (i = sp->typecnt - 1; stddst_mask && 0 <= i; i--) + stddst_mask = may_update_tzname_etc(stddst_mask, sp, i); } +#if USG_COMPAT + daylight = stddst_mask >> 1 ^ 1; +#endif } -static void +/* Replace bogus characters in time zone abbreviations. + Return 0 on success, an errno value if a time zone abbreviation is + too long. */ +static int scrub_abbrs(struct state *sp) { int i; - /* - ** First, replace bogus characters. - */ + + /* Reject overlong abbreviations. */ + for (i = 0; i < sp->charcnt - (TZNAME_MAXIMUM + 1); ) { + int len = strlen(&sp->chars[i]); + if (TZNAME_MAXIMUM < len) + return EOVERFLOW; + i += len + 1; + } + + /* Replace bogus characters. */ for (i = 0; i < sp->charcnt; ++i) if (strchr(TZ_ABBR_CHAR_SET, sp->chars[i]) == NULL) sp->chars[i] = TZ_ABBR_ERR_CHAR; - /* - ** Second, truncate long abbreviations. - */ - for (i = 0; i < sp->typecnt; ++i) { - register const struct ttinfo * const ttisp = &sp->ttis[i]; - char *cp = &sp->chars[ttisp->tt_desigidx]; - if (strlen(cp) > TZ_ABBR_MAX_LEN && - strcmp(cp, GRANDPARENTED) != 0) - *(cp + TZ_ABBR_MAX_LEN) = '\0'; - } + return 0; } /* Input buffer for data read from a compiled tz file. */ @@ -334,7 +995,8 @@ union input_buffer { /* The first part of the buffer, interpreted as a header. */ struct tzhead tzhead; - /* The entire buffer. */ + /* The entire buffer. Ideally this would have no size limits; + the following should suffice for practical use. */ char buf[2 * sizeof(struct tzhead) + 2 * sizeof(struct state) + 4 * TZ_MAX_TIMES]; }; @@ -353,9 +1015,13 @@ union local_storage { struct state st; } u; - /* The file name to be opened. */ - char fullname[BIGGEST(sizeof(struct file_analysis), - sizeof tzdirslash + 1024)]; + /* The name of the file to be opened. Ideally this would have no + size limits, to support arbitrarily long Zone names. + Limiting Zone names to 1024 bytes should suffice for practical use. + However, there is no need for this to be smaller than struct + file_analysis as that struct is allocated anyway, as the other + union member. */ + char fullname[max(sizeof(struct file_analysis), sizeof tzdirslash + 1024)]; }; /* Load tz data from the file named NAME into *SP. Read extended @@ -373,6 +1039,52 @@ localtime_tzloadbody_(char const *name, struct state *sp, bool doextend, register union input_buffer *up = &lsp->u.u; register int tzheadsize = sizeof(struct tzhead); + // [jart] 1. polyfill common aliases + // 2. polyfill legacy cosmo timezone names + if (name) { + if (startswith(name, "US/")) { + if (!strcmp(name, "US/Eastern")) + name = "America/New_York"; + else if (!strcmp(name, "US/Pacific")) + name = "America/Los_Angeles"; + else if (!strcmp(name, "US/Alaska")) + name = "America/Anchorage"; + else if (!strcmp(name, "US/Central")) + name = "America/Chicago"; + else if (!strcmp(name, "US/Hawaii")) + name = "Pacific/Honolulu"; + else if (!strcmp(name, "US/Michigan")) + name = "America/Detroit"; + else if (!strcmp(name, "US/Mountain")) + name = "America/Denver"; + } else if (!strcmp(name, "UTC")) { + name = "Etc/UTC"; + } else if (!strcmp(name, "GST")) { + name = "America/Los_Angeles"; + } else if (!strcmp(name, "Boulder")) { + name = "America/Denver"; + } else if (!strcmp(name, "Chicago")) { + name = "America/Chicago"; + } else if (!strcmp(name, "Anchorage")) { + name = "America/Anchorage"; + } else if (!strcmp(name, "Honolulu")) { + name = "Pacific/Honolulu"; + } else if (!strcmp(name, "London")) { + name = "Europe/London"; + } else if (!strcmp(name, "Berlin")) { + name = "Europe/Berlin"; + } else if (!strcmp(name, "Israel")) { + name = "Asia/Jerusalem"; + } else if (!strcmp(name, "Beijing") || + !strcmp(name, "Asia/Beijing")) { + // "In China, there are only two time zone which + // are Asia/Beijing and Asia/Urumuqi, but no + // Asia/Shanghai or Asia/Chongqing" + // https://bugs.launchpad.net/ubuntu/+source/libgweather/+bug/228554 + name = "Asia/Shanghai"; + } + } + sp->goback = sp->goahead = false; if (! name) { @@ -392,8 +1104,7 @@ localtime_tzloadbody_(char const *name, struct state *sp, bool doextend, #endif if (!doaccess) { char const *dot; - size_t namelen = strlen(name); - if (sizeof lsp->fullname - sizeof tzdirslash <= namelen) + if (sizeof lsp->fullname - sizeof tzdirslash <= strlen(name)) return ENAMETOOLONG; /* Create a string "TZDIR/NAME". Using sprintf here @@ -431,15 +1142,15 @@ localtime_tzloadbody_(char const *name, struct state *sp, bool doextend, for (stored = 4; stored <= 8; stored *= 2) { char version = up->tzhead.tzh_version[0]; bool skip_datablock = stored == 4 && version; - int32_t datablock_size; - int32_t ttisstdcnt = detzcode(up->tzhead.tzh_ttisstdcnt); - int32_t ttisutcnt = detzcode(up->tzhead.tzh_ttisutcnt); - int64_t prevtr = -1; - int32_t prevcorr = 0; - int32_t leapcnt = detzcode(up->tzhead.tzh_leapcnt); - int32_t timecnt = detzcode(up->tzhead.tzh_timecnt); - int32_t typecnt = detzcode(up->tzhead.tzh_typecnt); - int32_t charcnt = detzcode(up->tzhead.tzh_charcnt); + int_fast32_t datablock_size; + int_fast32_t ttisstdcnt = detzcode(up->tzhead.tzh_ttisstdcnt); + int_fast32_t ttisutcnt = detzcode(up->tzhead.tzh_ttisutcnt); + int_fast64_t prevtr = -1; + int_fast32_t prevcorr = 0; + int_fast32_t leapcnt = detzcode(up->tzhead.tzh_leapcnt); + int_fast32_t timecnt = detzcode(up->tzhead.tzh_timecnt); + int_fast32_t typecnt = detzcode(up->tzhead.tzh_typecnt); + int_fast32_t charcnt = detzcode(up->tzhead.tzh_charcnt); char const *p = up->buf + tzheadsize; /* Although tzfile(5) currently requires typecnt to be nonzero, support future formats that may allow zero typecnt @@ -478,7 +1189,7 @@ localtime_tzloadbody_(char const *name, struct state *sp, bool doextend, occurred at TIME_T_MIN. */ timecnt = 0; for (i = 0; i < sp->timecnt; ++i) { - int64_t at + int_fast64_t at = stored == 4 ? detzcode(p) : detzcode64(p); sp->types[i] = at <= TIME_T_MAX; if (sp->types[i]) { @@ -530,8 +1241,8 @@ localtime_tzloadbody_(char const *name, struct state *sp, bool doextend, /* Read leap seconds, discarding those out of time_t range. */ leapcnt = 0; for (i = 0; i < sp->leapcnt; ++i) { - int64_t tr = stored == 4 ? detzcode(p) : detzcode64(p); - int32_t corr = detzcode(p + stored); + int_fast64_t tr = stored == 4 ? detzcode(p) : detzcode64(p); + int_fast32_t corr = detzcode(p + stored); p += stored + 4; /* Leap seconds cannot occur before the Epoch, @@ -641,14 +1352,18 @@ localtime_tzloadbody_(char const *name, struct state *sp, bool doextend, == sp->types[sp->timecnt - 2])) sp->timecnt--; - for (i = 0; - i < ts->timecnt && sp->timecnt < TZ_MAX_TIMES; - i++) { + sp->goahead = ts->goahead; + + for (i = 0; i < ts->timecnt; i++) { time_t t = ts->ats[i]; if (increment_overflow_time(&t, leapcorr(sp, t)) || (0 < sp->timecnt && t <= sp->ats[sp->timecnt - 1])) continue; + if (TZ_MAX_TIMES <= sp->timecnt) { + sp->goahead = false; + break; + } sp->ats[sp->timecnt] = t; sp->types[sp->timecnt] = (sp->typecnt + ts->types[i]); @@ -661,80 +1376,6 @@ localtime_tzloadbody_(char const *name, struct state *sp, bool doextend, } if (sp->typecnt == 0) return EINVAL; - if (sp->timecnt > 1) { - if (sp->ats[0] <= TIME_T_MAX - SECSPERREPEAT) { - time_t repeatat = sp->ats[0] + SECSPERREPEAT; - int repeattype = sp->types[0]; - for (i = 1; i < sp->timecnt; ++i) - if (sp->ats[i] == repeatat - && localtime_typesequiv(sp, sp->types[i], repeattype)) { - sp->goback = true; - break; - } - } - if (TIME_T_MIN + SECSPERREPEAT <= sp->ats[sp->timecnt - 1]) { - time_t repeatat = sp->ats[sp->timecnt - 1] - SECSPERREPEAT; - int repeattype = sp->types[sp->timecnt - 1]; - for (i = sp->timecnt - 2; i >= 0; --i) - if (sp->ats[i] == repeatat - && localtime_typesequiv(sp, sp->types[i], repeattype)) { - sp->goahead = true; - break; - } - } - } - - /* Infer sp->defaulttype from the data. Although this default - type is always zero for data from recent tzdb releases, - things are trickier for data from tzdb 2018e or earlier. - - The first set of heuristics work around bugs in 32-bit data - generated by tzdb 2013c or earlier. The workaround is for - zones like Australia/Macquarie where timestamps before the - first transition have a time type that is not the earliest - standard-time type. See: - https://mm.icann.org/pipermail/tz/2013-May/019368.html */ - /* - ** If type 0 does not specify local time, or is unused in transitions, - ** it's the type to use for early times. - */ - for (i = 0; i < sp->timecnt; ++i) - if (sp->types[i] == 0) - break; - i = i < sp->timecnt && ! ttunspecified(sp, 0) ? -1 : 0; - /* - ** Absent the above, - ** if there are transition times - ** and the first transition is to a daylight time - ** find the standard type less than and closest to - ** the type of the first transition. - */ - if (i < 0 && sp->timecnt > 0 && sp->ttis[sp->types[0]].tt_isdst) { - i = sp->types[0]; - while (--i >= 0) - if (!sp->ttis[i].tt_isdst) - break; - } - /* The next heuristics are for data generated by tzdb 2018e or - earlier, for zones like EST5EDT where the first transition - is to DST. */ - /* - ** If no result yet, find the first standard type. - ** If there is none, punt to type zero. - */ - if (i < 0) { - i = 0; - while (sp->ttis[i].tt_isdst) - if (++i >= sp->typecnt) { - i = 0; - break; - } - } - /* A simple 'sp->defaulttype = 0;' would suffice here if we - didn't have to worry about 2018e-or-earlier data. Even - simpler would be to remove the defaulttype member and just - use 0 in its place. */ - sp->defaulttype = i; return 0; } @@ -755,6 +1396,7 @@ localtime_tzloadbody(char const *name, struct state *sp, bool doextend, static int localtime_tzload(char const *name, struct state *sp, bool doextend) { +#ifdef ALL_STATE union local_storage *lsp = malloc(sizeof *lsp); if (!lsp) { return HAVE_MALLOC_ERRNO ? errno : ENOMEM; @@ -763,29 +1405,10 @@ localtime_tzload(char const *name, struct state *sp, bool doextend) free(lsp); return err; } -} - -static bool -localtime_typesequiv(const struct state *sp, int a, int b) -{ - register bool result; - - if (sp == NULL || - a < 0 || a >= sp->typecnt || - b < 0 || b >= sp->typecnt) - result = false; - else { - register const struct ttinfo * ap = &sp->ttis[a]; - register const struct ttinfo * bp = &sp->ttis[b]; - result = (ap->tt_utoff == bp->tt_utoff - && ap->tt_isdst == bp->tt_isdst - && ap->tt_ttisstd == bp->tt_ttisstd - && ap->tt_ttisut == bp->tt_ttisut - && (strcmp(&sp->chars[ap->tt_desigidx], - &sp->chars[bp->tt_desigidx]) - == 0)); - } - return result; +#else + union local_storage ls; + return localtime_tzloadbody(name, sp, doextend, &ls); +#endif } static const int mon_lengths[2][MONSPERYEAR] = { @@ -801,7 +1424,7 @@ static const int year_lengths[2] = { static inline bool is_digit(char c) { - return '0' <= c && c <= '9'; + return '0' <= c && c <= '9'; } /* @@ -878,14 +1501,14 @@ getnum(register const char *strp, int *const nump, const int min, const int max) */ static const char * -getsecs(register const char *strp, int32_t *const secsp) +getsecs(register const char *strp, int_fast32_t *const secsp) { int num; - int32_t secsperhour = SECSPERHOUR; + int_fast32_t secsperhour = SECSPERHOUR; /* - ** 'HOURSPERDAY * DAYSPERWEEK - 1' allows quasi-Posix rules like - ** "M10.4.6/26", which does not conform to Posix, + ** 'HOURSPERDAY * DAYSPERWEEK - 1' allows quasi-POSIX rules like + ** "M10.4.6/26", which does not conform to POSIX, ** but which specifies the equivalent of ** "02:00 on the first Sunday on or after 23 Oct". */ @@ -919,7 +1542,7 @@ getsecs(register const char *strp, int32_t *const secsp) */ static const char * -getoffset(register const char *strp, int32_t *const offsetp) +localtime_getoffset(register const char *strp, int_fast32_t *const offsetp) { register bool neg = false; @@ -938,13 +1561,14 @@ getoffset(register const char *strp, int32_t *const offsetp) /* ** Given a pointer into a timezone string, extract a rule in the form -** date[/time]. See POSIX section 8 for the format of "date" and "time". +** date[/time]. See POSIX Base Definitions section 8.3 variable TZ +** for the format of "date" and "time". ** If a valid rule is not found, return NULL. ** Otherwise, return a pointer to the first character not part of the rule. */ static const char * -getrule(const char *strp, register struct rule *const rulep) +localtime_getrule(const char *strp, register struct rule *const rulep) { if (*strp == 'J') { /* @@ -984,7 +1608,7 @@ getrule(const char *strp, register struct rule *const rulep) ** Time specified. */ ++strp; - strp = getoffset(strp, &rulep->r_time); + strp = localtime_getoffset(strp, &rulep->r_time); } else rulep->r_time = 2 * SECSPERHOUR; /* default = 2:00:00 */ return strp; } @@ -994,12 +1618,12 @@ getrule(const char *strp, register struct rule *const rulep) ** effect, calculate the year-relative time that rule takes effect. */ -static int32_t -transtime(const int year, register const struct rule *const rulep, - const int32_t offset) +static int_fast32_t +localtime_transtime(const int year, register const struct rule *const rulep, + const int_fast32_t offset) { register bool leapyear; - register int32_t value; + register int_fast32_t value; register int i; int d, m1, yy0, yy1, yy2, dow; @@ -1069,7 +1693,7 @@ transtime(const int year, register const struct rule *const rulep, value += mon_lengths[leapyear][i] * SECSPERDAY; break; - default: UNREACHABLE(); + default: unreachable(); } /* @@ -1082,22 +1706,20 @@ transtime(const int year, register const struct rule *const rulep, } /* -** Given a POSIX section 8-style TZ string, fill in the rule tables as +** Given a POSIX.1-2017-style TZ string, fill in the rule tables as ** appropriate. */ static bool -localtime_tzparse(const char *name, struct state *sp, struct state *basep) +localtime_tzparse(const char *name, struct state *sp, struct state const *basep) { const char * stdname; const char * dstname; - size_t stdlen; - size_t dstlen; - size_t charcnt; - int32_t stdoffset; - int32_t dstoffset; + int_fast32_t stdoffset; + int_fast32_t dstoffset; register char * cp; register bool load_ok; + ptrdiff_t stdlen, dstlen, charcnt; time_t atlo = TIME_T_MIN, leaplo = TIME_T_MIN; stdname = name; @@ -1113,14 +1735,12 @@ localtime_tzparse(const char *name, struct state *sp, struct state *basep) name = getzname(name); stdlen = name - stdname; } - if (!stdlen) + if (! (0 < stdlen && stdlen <= TZNAME_MAXIMUM)) return false; - name = getoffset(name, &stdoffset); + name = localtime_getoffset(name, &stdoffset); if (name == NULL) return false; charcnt = stdlen + 1; - if (sizeof sp->chars < charcnt) - return false; if (basep) { if (0 < basep->timecnt) atlo = basep->ats[basep->timecnt - 1]; @@ -1134,6 +1754,7 @@ localtime_tzparse(const char *name, struct state *sp, struct state *basep) } if (0 < sp->leapcnt) leaplo = sp->lsis[sp->leapcnt - 1].ls_trans; + sp->goback = sp->goahead = false; if (*name != '\0') { if (*name == '<') { dstname = ++name; @@ -1147,13 +1768,11 @@ localtime_tzparse(const char *name, struct state *sp, struct state *basep) name = getzname(name); dstlen = name - dstname; /* length of DST abbr. */ } - if (!dstlen) + if (! (0 < dstlen && dstlen <= TZNAME_MAXIMUM)) return false; charcnt += dstlen + 1; - if (sizeof sp->chars < charcnt) - return false; if (*name != '\0' && *name != ',' && *name != ';') { - name = getoffset(name, &dstoffset); + name = localtime_getoffset(name, &dstoffset); if (name == NULL) return false; } else dstoffset = stdoffset - SECSPERHOUR; @@ -1165,15 +1784,15 @@ localtime_tzparse(const char *name, struct state *sp, struct state *basep) register int year; register int timecnt; time_t janfirst; - int32_t janoffset = 0; + int_fast32_t janoffset = 0; int yearbeg, yearlim; ++name; - if ((name = getrule(name, &start)) == NULL) + if ((name = localtime_getrule(name, &start)) == NULL) return false; if (*name++ != ',') return false; - if ((name = getrule(name, &end)) == NULL) + if ((name = localtime_getrule(name, &end)) == NULL) return false; if (*name != '\0') return false; @@ -1183,24 +1802,25 @@ localtime_tzparse(const char *name, struct state *sp, struct state *basep) */ init_ttinfo(&sp->ttis[0], -stdoffset, false, 0); init_ttinfo(&sp->ttis[1], -dstoffset, true, stdlen + 1); - sp->defaulttype = 0; timecnt = 0; janfirst = 0; yearbeg = EPOCH_YEAR; do { - int32_t yearsecs + int_fast32_t yearsecs = year_lengths[isleap(yearbeg - 1)] * SECSPERDAY; + time_t janfirst1 = janfirst; yearbeg--; - if (increment_overflow_time(&janfirst, -yearsecs)) { + if (increment_overflow_time(&janfirst1, -yearsecs)) { janoffset = -yearsecs; break; } + janfirst = janfirst1; } while (atlo < janfirst && EPOCH_YEAR - YEARSPERREPEAT / 2 < yearbeg); while (true) { - int32_t yearsecs + int_fast32_t yearsecs = year_lengths[isleap(yearbeg)] * SECSPERDAY; int yearbeg1 = yearbeg; time_t janfirst1 = janfirst; @@ -1213,18 +1833,18 @@ localtime_tzparse(const char *name, struct state *sp, struct state *basep) } yearlim = yearbeg; - if (increment_overflow(&yearlim, YEARSPERREPEAT + 1)) + if (increment_overflow(&yearlim, years_of_observations)) yearlim = INT_MAX; for (year = yearbeg; year < yearlim; year++) { - int32_t - starttime = transtime(year, &start, stdoffset), - endtime = transtime(year, &end, dstoffset); - int32_t + int_fast32_t + starttime = localtime_transtime(year, &start, stdoffset), + endtime = localtime_transtime(year, &end, dstoffset); + int_fast32_t yearsecs = (year_lengths[isleap(year)] * SECSPERDAY); bool reversed = endtime < starttime; if (reversed) { - int32_t swap = starttime; + int_fast32_t swap = starttime; starttime = endtime; endtime = swap; } @@ -1250,7 +1870,7 @@ localtime_tzparse(const char *name, struct state *sp, struct state *basep) if (endtime < leaplo) { yearlim = year; if (increment_overflow(&yearlim, - YEARSPERREPEAT + 1)) + years_of_observations)) yearlim = INT_MAX; } if (increment_overflow_time @@ -1262,12 +1882,12 @@ localtime_tzparse(const char *name, struct state *sp, struct state *basep) if (! timecnt) { sp->ttis[0] = sp->ttis[1]; sp->typecnt = 1; /* Perpetual DST. */ - } else if (YEARSPERREPEAT < year - yearbeg) + } else if (years_of_observations <= year - yearbeg) sp->goback = sp->goahead = true; } else { - register int32_t theirstdoffset; - register int32_t theirdstoffset; - register int32_t theiroffset; + register int_fast32_t theirstdoffset; + register int_fast32_t theirdstoffset; + register int_fast32_t theiroffset; register bool isdst; register int i; register int j; @@ -1321,8 +1941,8 @@ localtime_tzparse(const char *name, struct state *sp, struct state *basep) /* ** Transitions from DST to DDST ** will effectively disappear since - ** POSIX provides for only one DST - ** offset. + ** POSIX.1-2017 provides for only one + ** DST offset. */ if (isdst && !sp->ttis[j].tt_ttisstd) { sp->ats[i] += dstoffset - @@ -1343,14 +1963,12 @@ localtime_tzparse(const char *name, struct state *sp, struct state *basep) init_ttinfo(&sp->ttis[0], -stdoffset, false, 0); init_ttinfo(&sp->ttis[1], -dstoffset, true, stdlen + 1); sp->typecnt = 2; - sp->defaulttype = 0; } } else { dstlen = 0; sp->typecnt = 1; /* only standard time */ sp->timecnt = 0; init_ttinfo(&sp->ttis[0], -stdoffset, false, 0); - sp->defaulttype = 0; } sp->charcnt = charcnt; cp = sp->chars; @@ -1365,16 +1983,16 @@ localtime_tzparse(const char *name, struct state *sp, struct state *basep) } static void -gmtload(struct state *const sp) +localtime_gmtload(struct state *const sp) { - if (localtime_tzload(gmt, sp, true) != 0) - localtime_tzparse("GMT0", sp, NULL); + if (localtime_tzload(etc_utc, sp, true) != 0) + localtime_tzparse("UTC0", sp, NULL); } /* Initialize *SP to a value appropriate for the TZ setting NAME. Return 0 on success, an errno value on failure. */ static int -zoneinit(struct state *sp, char const *name) +localtime_zoneinit(struct state *sp, char const *name) { if (name && ! name[0]) { /* @@ -1386,22 +2004,21 @@ zoneinit(struct state *sp, char const *name) sp->charcnt = 0; sp->goback = sp->goahead = false; init_ttinfo(&sp->ttis[0], 0, false, 0); - strcpy(sp->chars, gmt); - sp->defaulttype = 0; + strcpy(sp->chars, utc); return 0; } else { int err = localtime_tzload(name, sp, true); - if (err != 0 && name && name[0] != ':' && - localtime_tzparse(name, sp, NULL)) + if (err != 0 && name && name[0] != ':' && localtime_tzparse(name, sp, NULL)) err = 0; if (err == 0) - scrub_abbrs(sp); + err = scrub_abbrs(sp); return err; } } static void -FreeLocaltime(void *p) { +localtime_lclptr_free(void *p) +{ free(p); } @@ -1415,13 +2032,15 @@ localtime_tzset_unlocked(void) ? lcl_is_set < 0 : 0 < lcl_is_set && strcmp(lcl_TZname, name) == 0) return; - if (!sp) { +#ifdef ALL_STATE + if (! sp) { lclptr = sp = malloc(sizeof *lclptr); - __cxa_atexit(FreeLocaltime, sp, 0); + __cxa_atexit(localtime_lclptr_free, sp, 0); } +#endif /* defined ALL_STATE */ if (sp) { - if (zoneinit(sp, name) != 0) - zoneinit(sp, ""); + if (localtime_zoneinit(sp, name) != 0) + localtime_zoneinit(sp, ""); if (0 < lcl) strcpy(lcl_TZname, name); } @@ -1438,21 +2057,8 @@ tzset(void) } static void -gmtcheck(void) +localtime_gmtptr_free(void *p) { - static bool gmt_is_set; - localtime_lock(); - if (! gmt_is_set) { - gmtptr = malloc(sizeof *gmtptr); - if (gmtptr) - gmtload(gmtptr); - gmt_is_set = true; - } - localtime_unlock(); -} - -static void -FreeGmt(void *p) { free(p); } @@ -1462,10 +2068,12 @@ localtime_gmtcheck(void) static bool gmt_is_set; localtime_lock(); if (! gmt_is_set) { +#ifdef ALL_STATE gmtptr = malloc(sizeof *gmtptr); - __cxa_atexit(FreeGmt, gmtptr, 0); + __cxa_atexit(localtime_gmtptr_free, gmtptr, 0); +#endif if (gmtptr) - gmtload(gmtptr); + localtime_gmtload(gmtptr); gmt_is_set = true; } localtime_unlock(); @@ -1479,15 +2087,16 @@ localtime_gmtcheck(void) ** ** If successful and SETNAME is nonzero, ** set the applicable parts of tzname, timezone and altzone; -** however, it's OK to omit this step if the timezone is POSIX-compatible, +** however, it's OK to omit this step +** if the timezone is compatible with POSIX.1-2017 ** since in that case tzset should have already done this step correctly. -** SETNAME's type is int32_t for compatibility with gmtsub, +** SETNAME's type is int_fast32_t for compatibility with gmtsub, ** but it is actually a boolean and its value should be 0 or 1. */ /*ARGSUSED*/ static struct tm * -localsub(struct state const *sp, time_t const *timep, int32_t setname, +localsub(struct state const *sp, time_t const *timep, int_fast32_t setname, struct tm *const tmp) { register const struct ttinfo * ttisp; @@ -1525,7 +2134,15 @@ localsub(struct state const *sp, time_t const *timep, int32_t setname, return NULL; /* "cannot happen" */ result = localsub(sp, &newt, setname, tmp); if (result) { - register int64_t newy; +#if defined ckd_add && defined ckd_sub + if (t < sp->ats[0] + ? ckd_sub(&result->tm_year, + result->tm_year, years) + : ckd_add(&result->tm_year, + result->tm_year, years)) + return NULL; +#else + register int_fast64_t newy; newy = result->tm_year; if (t < sp->ats[0]) @@ -1534,11 +2151,12 @@ localsub(struct state const *sp, time_t const *timep, int32_t setname, if (! (INT_MIN <= newy && newy <= INT_MAX)) return NULL; result->tm_year = newy; +#endif } return result; } if (sp->timecnt == 0 || t < sp->ats[0]) { - i = sp->defaulttype; + i = 0; } else { register int lo = 1; register int hi = sp->timecnt; @@ -1559,12 +2177,14 @@ localsub(struct state const *sp, time_t const *timep, int32_t setname, ** t += ttisp->tt_utoff; ** timesub(&t, 0L, sp, tmp); */ - result = localtime_timesub(&t, ttisp->tt_utoff, sp, tmp); + result = timesub(&t, ttisp->tt_utoff, sp, tmp); if (result) { - result->tm_isdst = ttisp->tt_isdst; - result->tm_zone = (char *) &sp->chars[ttisp->tt_desigidx]; - if (setname) - update_tzname_etc(sp, ttisp); + result->tm_isdst = ttisp->tt_isdst; +#ifdef TM_ZONE + result->TM_ZONE = (char *) &sp->chars[ttisp->tt_desigidx]; +#endif /* defined TM_ZONE */ + if (setname) + update_tzname_etc(sp, ttisp); } return result; } @@ -1583,11 +2203,14 @@ localtime_tzset(time_t const *timep, struct tm *tmp, bool setname) struct tm * localtime(const time_t *timep) { +#if !SUPPORT_C89 + static struct tm tm; +#endif return localtime_tzset(timep, &tm, true); } struct tm * -localtime_r(const time_t *timep, struct tm *tmp) +localtime_r(const time_t *restrict timep, struct tm *restrict tmp) { return localtime_tzset(timep, tmp, false); } @@ -1597,43 +2220,41 @@ localtime_r(const time_t *timep, struct tm *tmp) */ static struct tm * -gmtsub(struct state const *sp, time_t const *timep, int32_t offset, - struct tm *tmp) +gmtsub(ATTRIBUTE_MAYBE_UNUSED struct state const *sp, time_t const *timep, + int_fast32_t offset, struct tm *tmp) { register struct tm * result; - result = localtime_timesub(timep, offset, gmtptr, tmp); + result = timesub(timep, offset, gmtptr, tmp); +#ifdef TM_ZONE /* ** Could get fancy here and deliver something such as ** "+xx" or "-xx" if offset is non-zero, ** but this is no time for a treasure hunt. */ - tmp->tm_zone = ((char *) - (offset ? wildabbr : gmtptr ? gmtptr->chars : gmt)); + tmp->TM_ZONE = ((char *) + (offset ? wildabbr : gmtptr ? gmtptr->chars : utc)); +#endif /* defined TM_ZONE */ return result; } /* -* Re-entrant version of gmtime. -*/ - -/** - * Converts UNIX timestamp to broken-down representation. + * Re-entrant version of gmtime. */ + struct tm * -gmtime_r(const time_t *timep, struct tm *tmp) +gmtime_r(time_t const *restrict timep, struct tm *restrict tmp) { localtime_gmtcheck(); return gmtsub(gmtptr, timep, 0, tmp); } -/** - * Converts UNIX timestamp to broken-down representation. - * @threadunsafe (see gmtime_r) - */ struct tm * gmtime(const time_t *timep) { +#if !SUPPORT_C89 + static struct tm tm; +#endif return gmtime_r(timep, &tm); } @@ -1657,15 +2278,15 @@ leaps_thru_end_of(time_t y) } static struct tm * -localtime_timesub(const time_t *timep, int32_t offset, - const struct state *sp, struct tm *tmp) +timesub(const time_t *timep, int_fast32_t offset, + const struct state *sp, struct tm *tmp) { register const struct lsinfo * lp; register time_t tdays; register const int * ip; - register int32_t corr; + register int_fast32_t corr; register int i; - int32_t idays, rem, dayoff, dayrem; + int_fast32_t idays, rem, dayoff, dayrem; time_t y; /* If less than SECSPERMIN, the number of seconds since the @@ -1711,7 +2332,7 @@ localtime_timesub(const time_t *timep, int32_t offset, /* Increase Y and decrease IDAYS until IDAYS is in range for Y. */ while (year_lengths[isleap(y)] <= idays) { int tdelta = idays / DAYSPERLYEAR; - int32_t ydelta = tdelta + !tdelta; + int_fast32_t ydelta = tdelta + !tdelta; time_t newy = y + ydelta; register int leapdays; leapdays = leaps_thru_end_of(newy - 1) - @@ -1721,6 +2342,12 @@ localtime_timesub(const time_t *timep, int32_t offset, y = newy; } +#ifdef ckd_add + if (ckd_add(&tmp->tm_year, y, -TM_YEAR_BASE)) { + errno = EOVERFLOW; + return NULL; + } +#else if (!TYPE_SIGNED(time_t) && y < TM_YEAR_BASE) { int signed_y = y; tmp->tm_year = signed_y - TM_YEAR_BASE; @@ -1731,6 +2358,7 @@ localtime_timesub(const time_t *timep, int32_t offset, errno = EOVERFLOW; return NULL; } +#endif tmp->tm_yday = idays; /* ** The "extra" mods below avoid overflow problems. @@ -1758,7 +2386,9 @@ localtime_timesub(const time_t *timep, int32_t offset, idays -= ip[tmp->tm_mon]; tmp->tm_mday = idays + 1; tmp->tm_isdst = 0; - tmp->tm_gmtoff = offset; +#ifdef TM_GMTOFF + tmp->TM_GMTOFF = offset; +#endif /* defined TM_GMTOFF */ return tmp; } @@ -1772,7 +2402,7 @@ localtime_timesub(const time_t *timep, int32_t offset, */ #ifndef WRONG -#define WRONG (-1) +# define WRONG (-1) #endif /* !defined WRONG */ /* @@ -1782,13 +2412,11 @@ localtime_timesub(const time_t *timep, int32_t offset, forceinline bool increment_overflow(int *ip, int j) { -#if defined(__GNUC__) && __GNUC__ >= 6 - int i = *ip; - if (__builtin_add_overflow(i, j, &i)) return true; - *ip = i; - return false; +#ifdef ckd_add + return ckd_add(ip, *ip, j); #else register int const i = *ip; + /* ** If i >= 0 there can only be overflow if i + j > INT_MAX ** or if j > INT_MAX - i; given i >= 0, INT_MAX - i cannot overflow. @@ -1803,16 +2431,14 @@ increment_overflow(int *ip, int j) } forceinline bool -increment_overflow32(int32_t *const lp, int const m) +increment_overflow32(int_fast32_t *const lp, int const m) { -#if defined(__GNUC__) && __GNUC__ >= 6 - int32_t i = *lp; - if (__builtin_add_overflow(i, m, &i)) return true; - *lp = i; - return false; +#ifdef ckd_add + return ckd_add(lp, *lp, m); #else - register int32_t const l = *lp; - if ((l >= 0) ? (m > INT32_MAX - l) : (m < INT32_MIN - l)) + register int_fast32_t const l = *lp; + + if ((l >= 0) ? (m > INT_FAST32_MAX - l) : (m < INT_FAST32_MIN - l)) return true; *lp += m; return false; @@ -1820,13 +2446,10 @@ increment_overflow32(int32_t *const lp, int const m) } forceinline bool -increment_overflow_time(time_t *tp, int32_t j) +increment_overflow_time(time_t *tp, int_fast32_t j) { -#if defined(__GNUC__) && __GNUC__ >= 6 - time_t i = *tp; - if (__builtin_add_overflow(i, j, &i)) return true; - *tp = i; - return false; +#ifdef ckd_add + return ckd_add(tp, *tp, j); #else /* ** This is like @@ -1855,7 +2478,7 @@ normalize_overflow(int *const tensptr, int *const unitsptr, const int base) } static bool -normalize_overflow32(int32_t *tensptr, int *unitsptr, int base) +normalize_overflow32(int_fast32_t *tensptr, int *unitsptr, int base) { register int tensdelta; @@ -1882,29 +2505,46 @@ tmcomp(register const struct tm *const atmp, return result; } +/* Copy to *DEST from *SRC. Copy only the members needed for mktime, + as other members might not be initialized. */ +static void +mktmcpy(struct tm *dest, struct tm const *src) +{ + dest->tm_sec = src->tm_sec; + dest->tm_min = src->tm_min; + dest->tm_hour = src->tm_hour; + dest->tm_mday = src->tm_mday; + dest->tm_mon = src->tm_mon; + dest->tm_year = src->tm_year; + dest->tm_isdst = src->tm_isdst; +#if defined TM_GMTOFF && ! UNINIT_TRAP + dest->TM_GMTOFF = src->TM_GMTOFF; +#endif +} + static time_t -localtime_time2sub( - struct tm *const tmp, - struct tm *(*funcp)(struct state const *, time_t const *, - int32_t, struct tm *), - struct state const *sp, - const int32_t offset, - bool *okayp, - bool do_norm_secs) +time2sub(struct tm *const tmp, + struct tm *(*funcp)(struct state const *, time_t const *, + int_fast32_t, struct tm *), + struct state const *sp, + const int_fast32_t offset, + bool *okayp, + bool do_norm_secs) { register int dir; register int i, j; register int saved_seconds; - register int32_t li; + register int_fast32_t li; register time_t lo; register time_t hi; - int32_t y; + int_fast32_t y; time_t newt; time_t t; struct tm yourtm, mytm; *okayp = false; - yourtm = *tmp; + mktmcpy(&yourtm, tmp); + if (do_norm_secs) { if (normalize_overflow(&yourtm.tm_min, &yourtm.tm_sec, SECSPERMIN)) @@ -1946,14 +2586,19 @@ localtime_time2sub( return WRONG; } } +#ifdef ckd_add + if (ckd_add(&yourtm.tm_year, y, -TM_YEAR_BASE)) + return WRONG; +#else if (increment_overflow32(&y, -TM_YEAR_BASE)) return WRONG; if (! (INT_MIN <= y && y <= INT_MAX)) return WRONG; yourtm.tm_year = y; +#endif if (yourtm.tm_sec >= 0 && yourtm.tm_sec < SECSPERMIN) saved_seconds = 0; - else if (y + TM_YEAR_BASE < EPOCH_YEAR) { + else if (yourtm.tm_year < EPOCH_YEAR - TM_YEAR_BASE) { /* ** We can't set tm_sec to 0, because that might push the ** time below the minimum representable time. @@ -2013,10 +2658,10 @@ localtime_time2sub( && (yourtm.TM_GMTOFF < 0 ? (-SECSPERDAY <= yourtm.TM_GMTOFF && (mytm.TM_GMTOFF <= - (SMALLEST(INT32_MAX, LONG_MAX) + (min(INT_FAST32_MAX, LONG_MAX) + yourtm.TM_GMTOFF))) : (yourtm.TM_GMTOFF <= SECSPERDAY - && ((BIGGEST(INT32_MIN, LONG_MIN) + && ((max(INT_FAST32_MIN, LONG_MIN) + yourtm.TM_GMTOFF) <= mytm.TM_GMTOFF)))) { /* MYTM matches YOURTM except with the wrong UT offset. @@ -2024,7 +2669,7 @@ localtime_time2sub( It's OK if YOURTM.TM_GMTOFF contains uninitialized data, since the guess gets checked. */ time_t altt = t; - int32_t diff = mytm.TM_GMTOFF - yourtm.TM_GMTOFF; + int_fast32_t diff = mytm.TM_GMTOFF - yourtm.TM_GMTOFF; if (!increment_overflow_time(&altt, diff)) { struct tm alttm; if (funcp(sp, &altt, offset, &alttm) @@ -2083,13 +2728,12 @@ label: } static time_t -localtime_time2( - struct tm * const tmp, - struct tm *(*funcp)(struct state const *, time_t const *, - int32_t, struct tm *), - struct state const *sp, - const int32_t offset, - bool *okayp) +time2(struct tm * const tmp, + struct tm *(*funcp)(struct state const *, time_t const *, + int_fast32_t, struct tm *), + struct state const *sp, + const int_fast32_t offset, + bool *okayp) { time_t t; @@ -2098,17 +2742,16 @@ localtime_time2( ** (in case tm_sec contains a value associated with a leap second). ** If that fails, try with normalization of seconds. */ - t = localtime_time2sub(tmp, funcp, sp, offset, okayp, false); - return *okayp ? t : localtime_time2sub(tmp,funcp,sp,offset,okayp,true); + t = time2sub(tmp, funcp, sp, offset, okayp, false); + return *okayp ? t : time2sub(tmp, funcp, sp, offset, okayp, true); } static time_t -localtime_time1( - struct tm *const tmp, - struct tm *(*funcp)(struct state const *, time_t const *, - int32_t, struct tm *), - struct state const *sp, - const int32_t offset) +time1(struct tm *const tmp, + struct tm *(*funcp)(struct state const *, time_t const *, + int_fast32_t, struct tm *), + struct state const *sp, + const int_fast32_t offset) { register time_t t; register int samei, otheri; @@ -2125,7 +2768,7 @@ localtime_time1( } if (tmp->tm_isdst > 1) tmp->tm_isdst = 1; - t = localtime_time2(tmp, funcp, sp, offset, &okay); + t = time2(tmp, funcp, sp, offset, &okay); if (okay) return t; if (tmp->tm_isdst < 0) @@ -2164,7 +2807,7 @@ localtime_time1( tmp->tm_sec += (sp->ttis[otheri].tt_utoff - sp->ttis[samei].tt_utoff); tmp->tm_isdst = !tmp->tm_isdst; - t = localtime_time2(tmp, funcp, sp, offset, &okay); + t = time2(tmp, funcp, sp, offset, &okay); if (okay) return t; tmp->tm_sec -= (sp->ttis[otheri].tt_utoff @@ -2179,10 +2822,10 @@ static time_t mktime_tzname(struct state *sp, struct tm *tmp, bool setname) { if (sp) - return localtime_time1(tmp, localsub, sp, setname); + return time1(tmp, localsub, sp, setname); else { localtime_gmtcheck(); - return localtime_time1(tmp, gmtsub, gmtptr, 0); + return time1(tmp, gmtsub, gmtptr, 0); } } @@ -2197,6 +2840,8 @@ mktime(struct tm *tmp) return t; } +/* This function is obsolescent and may disapper in future releases. + Callers can instead use mktime. */ time_t timelocal(struct tm *tmp) { @@ -2205,22 +2850,31 @@ timelocal(struct tm *tmp) return mktime(tmp); } -time_t -timegm(struct tm *tmp) -{ - return timeoff(tmp, 0); -} - +/* This function is obsolescent and may disapper in future releases. + Callers can instead use mktime_z with a fixed-offset zone. */ time_t timeoff(struct tm *tmp, long offset) { if (tmp) tmp->tm_isdst = 0; - gmtcheck(); - return localtime_time1(tmp, gmtsub, gmtptr, offset); + localtime_gmtcheck(); + return time1(tmp, gmtsub, gmtptr, offset); } -static int32_t +time_t +timegm(struct tm *tmp) +{ + time_t t; + struct tm tmcpy; + mktmcpy(&tmcpy, tmp); + tmcpy.tm_wday = -1; + t = timeoff(&tmcpy, 0); + if (0 <= tmcpy.tm_wday) + *tmp = tmcpy; + return t; +} + +static int_fast32_t leapcorr(struct state const *sp, time_t t) { register struct lsinfo const * lp; diff --git a/third_party/tz/private.h b/third_party/tz/private.h new file mode 100644 index 000000000..f2a79cdf8 --- /dev/null +++ b/third_party/tz/private.h @@ -0,0 +1,165 @@ +#ifndef TZ_PRIVATE_H +#define TZ_PRIVATE_H +#include "libc/errno.h" +#include "libc/calls/weirdtypes.h" +#include "libc/time.h" +#include "libc/limits.h" + +#define ALL_STATE +#define HAVE_TZNAME 1 +#define HAVE_MALLOC_ERRNO 1 +#define TM_ZONE tm_zone +#define TM_GMTOFF tm_gmtoff + +/* The maximum size of any created object, as a signed integer. + Although the C standard does not outright prohibit larger objects, + behavior is undefined if the result of pointer subtraction does not + fit into ptrdiff_t, and the code assumes in several places that + pointer subtraction works. As a practical matter it's OK to not + support objects larger than this. */ +#define INDEX_MAX ((ptrdiff_t)min(PTRDIFF_MAX, SIZE_MAX)) + +#define ATTRIBUTE_MALLOC __attribute__((__malloc__)) +#define ATTRIBUTE_FORMAT(spec) __attribute__((__format__ spec)) +#define ATTRIBUTE_FALLTHROUGH __attribute__((__fallthrough__)) +#define ATTRIBUTE_MAYBE_UNUSED __attribute__((__unused__)) +#define ATTRIBUTE_NORETURN __attribute__((__noreturn__)) +#define ATTRIBUTE_REPRODUCIBLE __attribute__((__pure__)) +#define ATTRIBUTE_UNSEQUENCED __attribute__((__const__)) + +#define unreachable() __builtin_unreachable() + +/* +** Finally, some convenience items. +*/ + +#define TYPE_BIT(type) (CHAR_BIT * (ptrdiff_t)sizeof(type)) +#define TYPE_SIGNED(type) (((type) - 1) < 0) +#define TWOS_COMPLEMENT(t) ((t) ~(t)0 < 0) + +/* Minimum and maximum of two values. Use lower case to avoid + naming clashes with standard include files. */ +#define max(a, b) ((a) > (b) ? (a) : (b)) +#define min(a, b) ((a) < (b) ? (a) : (b)) + +/* Max and min values of the integer type T, of which only the bottom + B bits are used, and where the highest-order used bit is considered + to be a sign bit if T is signed. */ +#define MAXVAL(t, b) \ + ((t)(((t)1 << ((b) - 1 - TYPE_SIGNED(t))) - 1 + \ + ((t)1 << ((b) - 1 - TYPE_SIGNED(t))))) +#define MINVAL(t, b) \ + ((t)(TYPE_SIGNED(t) ? -TWOS_COMPLEMENT(t) - MAXVAL(t, b) : 0)) + +/* The extreme time values, assuming no padding. */ +#define TIME_T_MIN_NO_PADDING MINVAL(time_t, TYPE_BIT(time_t)) +#define TIME_T_MAX_NO_PADDING MAXVAL(time_t, TYPE_BIT(time_t)) + +/* +** 302 / 1000 is log10(2.0) rounded up. +** Subtract one for the sign bit if the type is signed; +** add one for integer division truncation; +** add one more for a minus sign if the type is signed. +*/ +#define INT_STRLEN_MAXIMUM(type) \ + ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type)) + +/* +** INITIALIZE(x) +*/ + +/* Whether memory access must strictly follow the C standard. + If 0, it's OK to read uninitialized storage so long as the value is + not relied upon. Defining it to 0 lets mktime access parts of + struct tm that might be uninitialized, as a heuristic when the + standard doesn't say what to return and when tm_gmtoff can help + mktime likely infer a better value. */ +#ifndef UNINIT_TRAP +#define UNINIT_TRAP 0 +#endif + +#if !defined TZ_DOMAIN && defined HAVE_GETTEXT +#define TZ_DOMAIN "tz" +#endif + +/* Handy macros that are independent of tzfile implementation. */ + +enum { + SECSPERMIN = 60, + MINSPERHOUR = 60, + SECSPERHOUR = SECSPERMIN * MINSPERHOUR, + HOURSPERDAY = 24, + DAYSPERWEEK = 7, + DAYSPERNYEAR = 365, + DAYSPERLYEAR = DAYSPERNYEAR + 1, + MONSPERYEAR = 12, + YEARSPERREPEAT = 400 /* years before a Gregorian repeat */ +}; + +#define SECSPERDAY ((int_fast32_t)SECSPERHOUR * HOURSPERDAY) + +#define DAYSPERREPEAT ((int_fast32_t)400 * 365 + 100 - 4 + 1) +#define SECSPERREPEAT ((int_fast64_t)DAYSPERREPEAT * SECSPERDAY) +#define AVGSECSPERYEAR (SECSPERREPEAT / YEARSPERREPEAT) + +/* How many years to generate (in zic.c) or search through (in localtime.c). + This is two years larger than the obvious 400, to avoid edge cases. + E.g., suppose a non-POSIX.1-2017 rule applies from 2012 on with transitions + in March and September, plus one-off transitions in November 2013. + If zic looked only at the last 400 years, it would set max_year=2413, + with the intent that the 400 years 2014 through 2413 will be repeated. + The last transition listed in the tzfile would be in 2413-09, + less than 400 years after the last one-off transition in 2013-11. + Two years is not overkill for localtime.c, as a one-year bump + would mishandle 2023d's America/Ciudad_Juarez for November 2422. */ +enum { years_of_observations = YEARSPERREPEAT + 2 }; + +enum { + TM_SUNDAY, + TM_MONDAY, + TM_TUESDAY, + TM_WEDNESDAY, + TM_THURSDAY, + TM_FRIDAY, + TM_SATURDAY +}; + +enum { + TM_JANUARY, + TM_FEBRUARY, + TM_MARCH, + TM_APRIL, + TM_MAY, + TM_JUNE, + TM_JULY, + TM_AUGUST, + TM_SEPTEMBER, + TM_OCTOBER, + TM_NOVEMBER, + TM_DECEMBER +}; + +enum { + TM_YEAR_BASE = 1900, + TM_WDAY_BASE = TM_MONDAY, + EPOCH_YEAR = 1970, + EPOCH_WDAY = TM_THURSDAY +}; + +#define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0)) + +/* +** Since everything in isleap is modulo 400 (or a factor of 400), we know that +** isleap(y) == isleap(y % 400) +** and so +** isleap(a + b) == isleap((a + b) % 400) +** or +** isleap(a + b) == isleap(a % 400 + b % 400) +** This is true even if % means modulo rather than Fortran remainder +** (which is allowed by C89 but not by C99 or later). +** We use this to avoid addition overflow problems. +*/ + +#define isleap_sum(a, b) isleap((a) % 400 + (b) % 400) + +#endif /* !defined TZ_PRIVATE_H */ diff --git a/libc/time/strftime.c b/third_party/tz/strftime.c similarity index 64% rename from libc/time/strftime.c rename to third_party/tz/strftime.c index 1a607b35e..372b98071 100644 --- a/libc/time/strftime.c +++ b/third_party/tz/strftime.c @@ -1,4 +1,4 @@ -/*-*- mode:c; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│ +/*-*- mode:c;indent-tabs-mode:t;c-basic-offset:8;tab-width:8;coding:utf-8 -*-│ │ vi: set noet ft=c ts=8 sw=8 fenc=utf-8 :vi │ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright (c) 1989 The Regents of the University of California. │ @@ -16,24 +16,19 @@ │ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/inttypes.h" -#include "libc/stdio/stdio.h" #include "libc/str/locale.h" -#include "libc/time/time.h" -#include "libc/time/tz.internal.h" -// clang-format off -// converts broken-down timestamp to string - -#define DIVISOR 100 +#include "libc/time.h" +#include "libc/runtime/runtime.h" +#include "libc/stdio/stdio.h" +#include "libc/inttypes.h" +#include "private.h" __notice(strftime_notice, "strftime (BSD-3)\n\ Copyright 1989 The Regents of the University of California"); -/* -** Based on the UCB version with the copyright notice appearing above. -** -** This is ANSIish only when "multibyte character == plain character". -*/ +#ifndef DEPRECATE_TWO_DIGIT_YEARS +# define DEPRECATE_TWO_DIGIT_YEARS false +#endif struct lc_time_T { const char * mon[MONSPERYEAR]; @@ -48,8 +43,6 @@ struct lc_time_T { const char * date_fmt; }; -#define Locale (&C_time_locale) - static const struct lc_time_T C_time_locale = { { "Jan", "Feb", "Mar", "Apr", "May", "Jun", @@ -99,11 +92,11 @@ static const struct lc_time_T C_time_locale = { enum warn { IN_NONE, IN_SOME, IN_THIS, IN_ALL }; #ifndef YEAR_2000_NAME -#define YEAR_2000_NAME "CHECK_STRFTIME_FORMATS_FOR_TWO_DIGIT_YEARS" +# define YEAR_2000_NAME "CHECK_STRFTIME_FORMATS_FOR_TWO_DIGIT_YEARS" #endif /* !defined YEAR_2000_NAME */ static char * -strftime_add(const char *str, char *pt, const char *ptlim) +_add(const char *str, char *pt, const char *ptlim) { while (pt < ptlim && (*pt = *str++) != '\0') ++pt; @@ -111,11 +104,12 @@ strftime_add(const char *str, char *pt, const char *ptlim) } static char * -strftime_conv(int n, const char *format, char *pt, const char *ptlim) +_conv(int n, const char *format, char *pt, const char *ptlim) { char buf[INT_STRLEN_MAXIMUM(int) + 1]; - (sprintf)(buf, format, n); - return strftime_add(buf, pt, ptlim); + + sprintf(buf, format, n); + return _add(buf, pt, ptlim); } /* @@ -127,17 +121,13 @@ strftime_conv(int n, const char *format, char *pt, const char *ptlim) */ static char * -strftime_yconv( - int a, - int b, - bool convert_top, - bool convert_yy, - char *pt, - const char *ptlim) +_yconv(int a, int b, bool convert_top, bool convert_yy, + char *pt, const char *ptlim) { register int lead; register int trail; + int DIVISOR = 100; trail = a % DIVISOR + b % DIVISOR; lead = a / DIVISOR + b / DIVISOR + trail / DIVISOR; trail %= DIVISOR; @@ -150,18 +140,20 @@ strftime_yconv( } if (convert_top) { if (lead == 0 && trail < 0) - pt = strftime_add("-0", pt, ptlim); - else pt = strftime_conv(lead, "%02d", pt, ptlim); + pt = _add("-0", pt, ptlim); + else pt = _conv(lead, "%02d", pt, ptlim); } if (convert_yy) - pt = strftime_conv(((trail < 0) ? -trail : trail), "%02d", pt, ptlim); + pt = _conv(((trail < 0) ? -trail : trail), "%02d", pt, ptlim); return pt; } static char * -strftime_fmt(const char *format, const struct tm *t, char *pt, - const char *ptlim, enum warn *warnp) +_fmt(const char *format, const struct tm *t, char *pt, + const char *ptlim, enum warn *warnp) { + struct lc_time_T const *Locale = &C_time_locale; + for ( ; *format; ++format) { if (*format == '%') { label: @@ -170,31 +162,27 @@ label: --format; break; case 'A': - pt = strftime_add( - (t->tm_wday < 0 || + pt = _add((t->tm_wday < 0 || t->tm_wday >= DAYSPERWEEK) ? "?" : Locale->weekday[t->tm_wday], pt, ptlim); continue; case 'a': - pt = strftime_add( - (t->tm_wday < 0 || - t->tm_wday >= DAYSPERWEEK) ? + pt = _add((t->tm_wday < 0 || + t->tm_wday >= DAYSPERWEEK) ? "?" : Locale->wday[t->tm_wday], pt, ptlim); continue; case 'B': - pt = strftime_add( - (t->tm_mon < 0 || - t->tm_mon >= MONSPERYEAR) ? + pt = _add((t->tm_mon < 0 || + t->tm_mon >= MONSPERYEAR) ? "?" : Locale->month[t->tm_mon], pt, ptlim); continue; case 'b': case 'h': - pt = strftime_add( - (t->tm_mon < 0 || - t->tm_mon >= MONSPERYEAR) ? + pt = _add((t->tm_mon < 0 || + t->tm_mon >= MONSPERYEAR) ? "?" : Locale->mon[t->tm_mon], pt, ptlim); continue; @@ -206,14 +194,14 @@ label: ** something completely different. ** (ado, 1993-05-24) */ - pt = strftime_yconv(t->tm_year, TM_YEAR_BASE, - true, false, pt, ptlim); + pt = _yconv(t->tm_year, TM_YEAR_BASE, + true, false, pt, ptlim); continue; case 'c': { enum warn warn2 = IN_SOME; - pt = strftime_fmt(Locale->c_fmt, t, pt, ptlim, &warn2); + pt = _fmt(Locale->c_fmt, t, pt, ptlim, &warn2); if (warn2 == IN_ALL) warn2 = IN_THIS; if (warn2 > *warnp) @@ -221,10 +209,10 @@ label: } continue; case 'D': - pt = strftime_fmt("%m/%d/%y", t, pt, ptlim, warnp); + pt = _fmt("%m/%d/%y", t, pt, ptlim, warnp); continue; case 'd': - pt = strftime_conv(t->tm_mday, "%02d", pt, ptlim); + pt = _conv(t->tm_mday, "%02d", pt, ptlim); continue; case 'E': case 'O': @@ -239,21 +227,21 @@ label: */ goto label; case 'e': - pt = strftime_conv(t->tm_mday, "%2d", pt, ptlim); + pt = _conv(t->tm_mday, "%2d", pt, ptlim); continue; case 'F': - pt = strftime_fmt("%Y-%m-%d", t, pt, ptlim, warnp); + pt = _fmt("%Y-%m-%d", t, pt, ptlim, warnp); continue; case 'H': - pt = strftime_conv(t->tm_hour, "%02d", pt, ptlim); + pt = _conv(t->tm_hour, "%02d", pt, ptlim); continue; case 'I': - pt = strftime_conv((t->tm_hour % 12) ? - (t->tm_hour % 12) : 12, - "%02d", pt, ptlim); + pt = _conv((t->tm_hour % 12) ? + (t->tm_hour % 12) : 12, + "%02d", pt, ptlim); continue; case 'j': - pt = strftime_conv(t->tm_yday + 1, "%03d", pt, ptlim); + pt = _conv(t->tm_yday + 1, "%03d", pt, ptlim); continue; case 'k': /* @@ -266,15 +254,14 @@ label: ** "%l" have been swapped. ** (ado, 1993-05-24) */ - pt = strftime_conv(t->tm_hour, "%2d", - pt, ptlim); + pt = _conv(t->tm_hour, "%2d", pt, ptlim); continue; #ifdef KITCHEN_SINK case 'K': /* ** After all this time, still unclaimed! */ - pt = strftime_add("kitchen sink", pt, ptlim); + pt = _add("kitchen sink", pt, ptlim); continue; #endif /* defined KITCHEN_SINK */ case 'l': @@ -287,38 +274,33 @@ label: ** "%l" have been swapped. ** (ado, 1993-05-24) */ - pt = strftime_conv((t->tm_hour % 12) ? - (t->tm_hour % 12) : 12, - "%2d", pt, ptlim); + pt = _conv((t->tm_hour % 12) ? + (t->tm_hour % 12) : 12, + "%2d", pt, ptlim); continue; case 'M': - pt = strftime_conv(t->tm_min, "%02d", - pt, ptlim); + pt = _conv(t->tm_min, "%02d", pt, ptlim); continue; case 'm': - pt = strftime_conv(t->tm_mon + 1, "%02d", - pt, ptlim); + pt = _conv(t->tm_mon + 1, "%02d", pt, ptlim); continue; case 'n': - pt = strftime_add("\n", pt, ptlim); + pt = _add("\n", pt, ptlim); continue; case 'p': - pt = strftime_add( - (t->tm_hour >= (HOURSPERDAY / 2)) ? + pt = _add((t->tm_hour >= (HOURSPERDAY / 2)) ? Locale->pm : Locale->am, pt, ptlim); continue; case 'R': - pt = strftime_fmt("%H:%M", t, pt, ptlim, warnp); + pt = _fmt("%H:%M", t, pt, ptlim, warnp); continue; case 'r': - pt = strftime_fmt("%I:%M:%S %p", t, pt, - ptlim, warnp); + pt = _fmt("%I:%M:%S %p", t, pt, ptlim, warnp); continue; case 'S': - pt = strftime_conv(t->tm_sec, "%02d", pt, - ptlim); + pt = _conv(t->tm_sec, "%02d", pt, ptlim); continue; case 's': { @@ -327,42 +309,42 @@ label: time_t) + 1]; time_t mkt; - tm = *t; - tm.tm_yday = -1; + tm.tm_sec = t->tm_sec; + tm.tm_min = t->tm_min; + tm.tm_hour = t->tm_hour; + tm.tm_mday = t->tm_mday; + tm.tm_mon = t->tm_mon; + tm.tm_year = t->tm_year; +#ifdef TM_GMTOFF + mkt = timeoff(&tm, t->TM_GMTOFF); +#else + tm.tm_isdst = t->tm_isdst; mkt = mktime(&tm); - if (mkt == (time_t) -1) { - /* Fail unless this -1 represents - a valid time. */ - struct tm tm_1; - if (!localtime_r(&mkt, &tm_1)) - return NULL; - if (!(tm.tm_year == tm_1.tm_year - && tm.tm_yday == tm_1.tm_yday - && tm.tm_hour == tm_1.tm_hour - && tm.tm_min == tm_1.tm_min - && tm.tm_sec == tm_1.tm_sec)) - return NULL; - } +#endif + /* If mktime fails, %s expands to the + value of (time_t) -1 as a failure + marker; this is better in practice + than strftime failing. */ if (TYPE_SIGNED(time_t)) { intmax_t n = mkt; - (sprintf)(buf, "%"PRIdMAX, n); + sprintf(buf, "%"PRIdMAX, n); } else { uintmax_t n = mkt; - (sprintf)(buf, "%"PRIuMAX, n); + sprintf(buf, "%"PRIuMAX, n); } - pt = strftime_add(buf, pt, ptlim); + pt = _add(buf, pt, ptlim); } continue; case 'T': - pt = strftime_fmt("%H:%M:%S", t, pt, ptlim, warnp); + pt = _fmt("%H:%M:%S", t, pt, ptlim, warnp); continue; case 't': - pt = strftime_add("\t", pt, ptlim); + pt = _add("\t", pt, ptlim); continue; case 'U': - pt = strftime_conv((t->tm_yday + DAYSPERWEEK - - t->tm_wday) / DAYSPERWEEK, - "%02d", pt, ptlim); + pt = _conv((t->tm_yday + DAYSPERWEEK - + t->tm_wday) / DAYSPERWEEK, + "%02d", pt, ptlim); continue; case 'u': /* @@ -371,9 +353,9 @@ label: ** [1 (Monday) - 7]" ** (ado, 1993-05-24) */ - pt = strftime_conv((t->tm_wday == 0) ? - DAYSPERWEEK : t->tm_wday, - "%d", pt, ptlim); + pt = _conv((t->tm_wday == 0) ? + DAYSPERWEEK : t->tm_wday, + "%d", pt, ptlim); continue; case 'V': /* ISO 8601 week number */ case 'G': /* ISO 8601 year (four digits) */ @@ -445,17 +427,24 @@ label: DAYSPERLYEAR : DAYSPERNYEAR; } +#ifdef XPG4_1994_04_09 + if ((w == 52 && + t->tm_mon == TM_JANUARY) || + (w == 1 && + t->tm_mon == TM_DECEMBER)) + w = 53; +#endif /* defined XPG4_1994_04_09 */ if (*format == 'V') - pt = strftime_conv(w, "%02d", - pt, ptlim); + pt = _conv(w, "%02d", + pt, ptlim); else if (*format == 'g') { *warnp = IN_ALL; - pt = strftime_yconv(year, base, - false, true, - pt, ptlim); - } else pt = strftime_yconv(year, base, - true, true, - pt, ptlim); + pt = _yconv(year, base, + false, true, + pt, ptlim); + } else pt = _yconv(year, base, + true, true, + pt, ptlim); } continue; case 'v': @@ -464,27 +453,26 @@ label: ** "date as dd-bbb-YYYY" ** (ado, 1993-05-24) */ - pt = strftime_fmt("%e-%b-%Y", t, pt, ptlim, warnp); + pt = _fmt("%e-%b-%Y", t, pt, ptlim, warnp); continue; case 'W': - pt = strftime_conv( - (t->tm_yday + DAYSPERWEEK - - (t->tm_wday ? - (t->tm_wday - 1) : - (DAYSPERWEEK - 1))) / DAYSPERWEEK, + pt = _conv((t->tm_yday + DAYSPERWEEK - + (t->tm_wday ? + (t->tm_wday - 1) : + (DAYSPERWEEK - 1))) / DAYSPERWEEK, "%02d", pt, ptlim); continue; case 'w': - pt = strftime_conv(t->tm_wday, "%d", pt, ptlim); + pt = _conv(t->tm_wday, "%d", pt, ptlim); continue; case 'X': - pt = strftime_fmt(Locale->X_fmt, t, pt, ptlim, warnp); + pt = _fmt(Locale->X_fmt, t, pt, ptlim, warnp); continue; case 'x': { enum warn warn2 = IN_SOME; - pt = strftime_fmt(Locale->x_fmt, t, pt, ptlim, &warn2); + pt = _fmt(Locale->x_fmt, t, pt, ptlim, &warn2); if (warn2 == IN_ALL) warn2 = IN_THIS; if (warn2 > *warnp) @@ -493,17 +481,23 @@ label: continue; case 'y': *warnp = IN_ALL; - pt = strftime_yconv(t->tm_year, TM_YEAR_BASE, - false, true, - pt, ptlim); + pt = _yconv(t->tm_year, TM_YEAR_BASE, + false, true, + pt, ptlim); continue; case 'Y': - pt = strftime_yconv(t->tm_year, TM_YEAR_BASE, - true, true, - pt, ptlim); + pt = _yconv(t->tm_year, TM_YEAR_BASE, + true, true, + pt, ptlim); continue; case 'Z': - pt = strftime_add(t->tm_zone, pt, ptlim); +#ifdef TM_ZONE + pt = _add(t->TM_ZONE, pt, ptlim); +#elif HAVE_TZNAME + if (t->tm_isdst >= 0) + pt = _add(tzname[t->tm_isdst != 0], + pt, ptlim); +#endif /* ** C99 and later say that %Z must be ** replaced by the empty string if the @@ -512,30 +506,76 @@ label: */ continue; case 'z': +#if defined TM_GMTOFF || USG_COMPAT || ALTZONE { long diff; char const * sign; bool negative; - diff = t->tm_gmtoff; +# ifdef TM_GMTOFF + diff = t->TM_GMTOFF; +# else + /* + ** C99 and later say that the UT offset must + ** be computed by looking only at + ** tm_isdst. This requirement is + ** incorrect, since it means the code + ** must rely on magic (in this case + ** altzone and timezone), and the + ** magic might not have the correct + ** offset. Doing things correctly is + ** tricky and requires disobeying the standard; + ** see GNU C strftime for details. + ** For now, punt and conform to the + ** standard, even though it's incorrect. + ** + ** C99 and later say that %z must be replaced by + ** the empty string if the time zone is not + ** determinable, so output nothing if the + ** appropriate variables are not available. + */ + if (t->tm_isdst < 0) + continue; + if (t->tm_isdst == 0) +# if USG_COMPAT + diff = -timezone; +# else + continue; +# endif + else +# if ALTZONE + diff = -altzone; +# else + continue; +# endif +# endif negative = diff < 0; if (diff == 0) { - negative = t->tm_zone[0] == '-'; +# ifdef TM_ZONE + negative = t->TM_ZONE[0] == '-'; +# else + negative = t->tm_isdst < 0; +# if HAVE_TZNAME + if (tzname[t->tm_isdst != 0][0] == '-') + negative = true; +# endif +# endif } if (negative) { sign = "-"; diff = -diff; } else sign = "+"; - pt = strftime_add(sign, pt, ptlim); + pt = _add(sign, pt, ptlim); diff /= SECSPERMIN; diff = (diff / MINSPERHOUR) * 100 + (diff % MINSPERHOUR); - pt = strftime_conv(diff, "%04d", pt, ptlim); + pt = _conv(diff, "%04d", pt, ptlim); } +#endif continue; case '+': - pt = strftime_fmt(Locale->date_fmt, t, pt, - ptlim, warnp); + pt = _fmt(Locale->date_fmt, t, pt, ptlim, + warnp); continue; case '%': /* @@ -569,18 +609,31 @@ label: * @see FormatHttpDateTime() */ size_t -strftime(char *s, size_t maxsize, const char *format, const struct tm *t) +strftime(char *restrict s, size_t maxsize, char const *restrict format, + struct tm const *restrict t) { char * p; int saved_errno = errno; enum warn warn = IN_NONE; tzset(); - p = strftime_fmt(format, t, s, s + maxsize, &warn); + p = _fmt(format, t, s, s + maxsize, &warn); if (!p) { errno = EOVERFLOW; return 0; } + if (DEPRECATE_TWO_DIGIT_YEARS + && warn != IN_NONE && getenv(YEAR_2000_NAME)) { + fprintf(stderr, "\n"); + fprintf(stderr, "strftime format \"%s\" ", format); + fprintf(stderr, "yields only two digits of years in "); + if (warn == IN_SOME) + fprintf(stderr, "some locales"); + else if (warn == IN_THIS) + fprintf(stderr, "the current locale"); + else fprintf(stderr, "all locales"); + fprintf(stderr, "\n"); + } if (p == s + maxsize) { errno = ERANGE; return 0; @@ -590,10 +643,4 @@ strftime(char *s, size_t maxsize, const char *format, const struct tm *t) return p - s; } -size_t -strftime_l(char *s, size_t maxsize, char const *format, struct tm const *t, - locale_t locale) -{ - /* Just call strftime, as only the C locale is supported. */ - return strftime(s, maxsize, format, t); -} +__weak_reference(strftime, strftime_l); diff --git a/third_party/tz/timezone.c b/third_party/tz/timezone.c new file mode 100644 index 000000000..64f726074 --- /dev/null +++ b/third_party/tz/timezone.c @@ -0,0 +1,6 @@ +/*-*- mode:c;indent-tabs-mode:t;c-basic-offset:8;tab-width:8;coding:utf-8 -*-│ +│ vi: set noet ft=c ts=8 sw=8 fenc=utf-8 :vi │ +╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/time.h" + +long timezone; diff --git a/third_party/tz/tzdir.h b/third_party/tz/tzdir.h new file mode 100644 index 000000000..4d5a701f6 --- /dev/null +++ b/third_party/tz/tzdir.h @@ -0,0 +1,6 @@ +#ifndef TZDEFAULT +#define TZDEFAULT "/etc/localtime" /* default zone */ +#endif +#ifndef TZDIR +#define TZDIR "/zip/usr/share/zoneinfo" /* TZif directory */ +#endif diff --git a/libc/time/tzfile.internal.h b/third_party/tz/tzfile.h similarity index 81% rename from libc/time/tzfile.internal.h rename to third_party/tz/tzfile.h index abab9923d..3155010ed 100644 --- a/libc/time/tzfile.internal.h +++ b/third_party/tz/tzfile.h @@ -1,8 +1,9 @@ -#ifndef TZFILE_H -#define TZFILE_H -/* clang-format off */ /* Layout and location of TZif files. */ +#ifndef TZFILE_H + +#define TZFILE_H + /* ** This file is in the public domain, so clarified as of ** 1996-06-05 by Arthur David Olson. @@ -20,16 +21,8 @@ ** Information about time zone files. */ -#ifndef TZDIR -#define TZDIR "/zip/usr/share/zoneinfo" /* Time zone object file directory */ -#endif /* !defined TZDIR */ - -#ifndef TZDEFAULT -#define TZDEFAULT "/etc/localtime" -#endif /* !defined TZDEFAULT */ - #ifndef TZDEFRULES -#define TZDEFRULES "US/Pacific" +# define TZDEFRULES "posixrules" #endif /* !defined TZDEFRULES */ @@ -85,11 +78,11 @@ struct tzhead { ** time uses 8 rather than 4 chars, ** then a POSIX-TZ-environment-variable-style string for use in handling ** instants after the last transition time stored in the file -** (with nothing between the newlines if there is no POSIX representation for -** such instants). +** (with nothing between the newlines if there is no POSIX.1-2017 +** representation for such instants). ** ** If tz_version is '3' or greater, the above is extended as follows. -** First, the POSIX TZ string's hour offset may range from -167 +** First, the TZ string's hour offset may range from -167 ** through 167 as compared to the POSIX-required 0 through 24. ** Second, its DST start time may be January 1 at 00:00 and its stop ** time December 31 at 24:00 plus the difference between DST and @@ -102,21 +95,25 @@ struct tzhead { */ #ifndef TZ_MAX_TIMES -#define TZ_MAX_TIMES 2000 +/* This must be at least 242 for Europe/London with 'zic -b fat'. */ +# define TZ_MAX_TIMES 2000 #endif /* !defined TZ_MAX_TIMES */ #ifndef TZ_MAX_TYPES -/* This must be at least 17 for Europe/Samara and Europe/Vilnius. */ -#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */ +/* This must be at least 18 for Europe/Vilnius with 'zic -b fat'. */ +# define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */ #endif /* !defined TZ_MAX_TYPES */ #ifndef TZ_MAX_CHARS -#define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */ +/* This must be at least 40 for America/Anchorage. */ +# define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */ /* (limited by what unsigned chars can hold) */ #endif /* !defined TZ_MAX_CHARS */ #ifndef TZ_MAX_LEAPS -#define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */ +/* This must be at least 27 for leap seconds from 1972 through mid-2023. + There's a plan to discontinue leap seconds by 2035. */ +# define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */ #endif /* !defined TZ_MAX_LEAPS */ #endif /* !defined TZFILE_H */ diff --git a/third_party/tz/tzname.c b/third_party/tz/tzname.c new file mode 100644 index 000000000..d21243a61 --- /dev/null +++ b/third_party/tz/tzname.c @@ -0,0 +1,6 @@ +/*-*- mode:c;indent-tabs-mode:t;c-basic-offset:8;tab-width:8;coding:utf-8 -*-│ +│ vi: set noet ft=c ts=8 sw=8 fenc=utf-8 :vi │ +╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/time.h" + +char *tzname[2]; diff --git a/third_party/tz/windows.py b/third_party/tz/windows.py new file mode 100644 index 000000000..633c78093 --- /dev/null +++ b/third_party/tz/windows.py @@ -0,0 +1,163 @@ +# Thank you Alejandro Zeise for collecting this information +# https://gist.github.com/alejzeis/ad5827eb14b5c22109ba652a1a267af5 + +SUPPORTED = set(( + 'Africa/Algiers', + 'Africa/Cairo', + 'Africa/Johannesburg', + 'Africa/Lagos', + 'Africa/Nairobi', + 'America/Anchorage', + 'America/Argentina/Buenos_Aires', + 'America/Bogota', + 'America/Chicago', + 'America/Denver', + 'America/Lima', + 'America/Los_Angeles', + 'America/Mexico_City', + 'America/New_York', + 'America/Phoenix', + 'America/Santiago', + 'America/Sao_Paulo', + 'Asia/Bangkok', + 'Asia/Dhaka', + 'Asia/Dubai', + 'Asia/Hong_Kong', + 'Asia/Jakarta', + 'Asia/Jerusalem', + 'Asia/Kabul', + 'Asia/Karachi', + 'Asia/Kolkata', + 'Asia/Manila', + 'Asia/Seoul', + 'Asia/Shanghai', + 'Asia/Singapore', + 'Asia/Taipei', + 'Asia/Tehran', + 'Asia/Tokyo', + 'Australia/Adelaide', + 'Australia/Brisbane', + 'Australia/Melbourne', + 'Australia/Perth', + 'Australia/Sydney', + 'CET', + 'CST6CDT', + 'EET', + 'EST', + 'EST5EDT', + 'Etc/GMT', + 'Etc/GMT+1', + 'Etc/GMT+10', + 'Etc/GMT+11', + 'Etc/GMT+12', + 'Etc/GMT+2', + 'Etc/GMT+3', + 'Etc/GMT+4', + 'Etc/GMT+5', + 'Etc/GMT+6', + 'Etc/GMT+7', + 'Etc/GMT+8', + 'Etc/GMT+9', + 'Etc/GMT-1', + 'Etc/GMT-10', + 'Etc/GMT-11', + 'Etc/GMT-12', + 'Etc/GMT-13', + 'Etc/GMT-14', + 'Etc/GMT-2', + 'Etc/GMT-3', + 'Etc/GMT-4', + 'Etc/GMT-5', + 'Etc/GMT-6', + 'Etc/GMT-7', + 'Etc/GMT-8', + 'Etc/GMT-9', + 'Etc/UTC', + 'Europe/Berlin', + 'Europe/Brussels', + 'Europe/Budapest', + 'Europe/Dublin', + 'Europe/Istanbul', + 'Europe/Kyiv', + 'Europe/London', + 'Europe/Madrid', + 'Europe/Moscow', + 'Europe/Paris', + 'Europe/Prague', + 'Europe/Rome', + 'Europe/Vienna', + 'Europe/Warsaw', + 'Europe/Zurich', + 'GMT', + 'HST', + 'MET', + 'MST', + 'MST7MDT', + 'PST8PDT', + 'Pacific/Auckland', + 'Pacific/Fiji', + 'Pacific/Guam', + 'Pacific/Honolulu', + 'Pacific/Port_Moresby', + 'WET', +)) + +import re +import os +import subprocess + +NAMES = set() +ZONES = set() +SUPERFLUOUS = set() +TABLE1 = [] +TABLE2 = [] + +with open("/home/jart/scratch/windows-timezone-mappings.csv") as f: + for line in f: + line = line.strip() + if not line: + break + name, what, zone = line.split(',') + if name in NAMES: + continue + ZZ = zone.split() # has superfluous zones + ZZ = [z for z in ZZ if z in SUPPORTED] + [z for z in ZZ if z not in SUPPORTED] + zone = ZZ[0] + rest = ZZ[1:] + NAMES.add(name) + ZONES.add(ZZ[0]) + SUPERFLUOUS |= set(rest) + os.environ['TZ'] = zone + p = subprocess.Popen(['date', '+%z@%Z'], stdout=subprocess.PIPE) + z, Z = p.stdout.read().decode('utf-8').strip().split('@') + print("%-35s %-5s %-10s %-10s %-30s" % (name, what, z, Z, zone)) + if zone in SUPPORTED: + TABLE1.append((name, zone, z, Z)) + else: + TABLE2.append((name, zone, z, Z)) + +print() +TABLE1.sort() +TABLE2.sort() +for k, v, z, Z in TABLE1: + print('{"%s", "%s"}, // %s %s' % (k, v, z, Z)) +print('#ifdef EMBED_EVERY_TIME_ZONE') +for k, v, z, Z in TABLE2: + print('{"%s", "%s"}, // %s %s' % (k, v, z, Z)) +print('#endif') + +# print() +# TABLE.sort(key=lambda x: (int(x[2]), x[1])) +# for k, v, z, Z in TABLE: +# if re.search(r'[A-Z]', Z): +# Z = ' ' + Z +# else: +# Z = '' +# print('__static_yoink("usr/share/zoneinfo/%s"); // %s%s (%s)' % (v, z, Z, k)) +# print('#ifdef EMBED_EVERY_TIME_ZONE') +# print('#endif') + +# print() +# SUPERFLUOUS -= ZONES +# for z in SUPERFLUOUS: +# print(z) diff --git a/third_party/unzip/BUILD.mk b/third_party/unzip/BUILD.mk index 945aef41c..b1db75282 100644 --- a/third_party/unzip/BUILD.mk +++ b/third_party/unzip/BUILD.mk @@ -23,8 +23,8 @@ THIRD_PARTY_UNZIP_A_DIRECTDEPS = \ LIBC_STDIO \ LIBC_STR \ LIBC_SYSV \ - LIBC_TIME \ - THIRD_PARTY_BZIP2 + THIRD_PARTY_BZIP2 \ + THIRD_PARTY_TZ THIRD_PARTY_UNZIP_A_DEPS := \ $(call uniq,$(foreach x,$(THIRD_PARTY_UNZIP_A_DIRECTDEPS),$($(x)))) diff --git a/third_party/unzip/timezone.c b/third_party/unzip/timezone.c index 95cf80652..8edd5bcf5 100644 --- a/third_party/unzip/timezone.c +++ b/third_party/unzip/timezone.c @@ -36,7 +36,7 @@ #include "third_party/unzip/zip.h" -#include "libc/time/struct/tm.h" +#include "libc/time.h" #include "third_party/unzip/timezone.h" #ifdef IZTZ_DEFINESTDGLOBALS diff --git a/third_party/unzip/unix.c b/third_party/unzip/unix.c index 6e15a11e0..a5a35f32e 100644 --- a/third_party/unzip/unix.c +++ b/third_party/unzip/unix.c @@ -30,9 +30,9 @@ #define UNZIP_INTERNAL #include "libc/calls/struct/dirent.h" #include "libc/log/log.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/unzip/unzip.h" -#include "libc/time/struct/utimbuf.h" +#include "libc/utime.h" #include "third_party/unzip/globals.h" #ifdef USE_ICONV_MAPPING diff --git a/third_party/unzip/unxcfg.h b/third_party/unzip/unxcfg.h index a3ba26301..c4d13dbb8 100644 --- a/third_party/unzip/unxcfg.h +++ b/third_party/unzip/unxcfg.h @@ -15,7 +15,7 @@ #include "libc/calls/struct/stat.h" #include "libc/sysv/consts/o.h" #include "libc/str/str.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "libc/calls/weirdtypes.h" diff --git a/third_party/xxhash/BUILD.mk b/third_party/xxhash/BUILD.mk index 2cfc33615..01c13ca84 100644 --- a/third_party/xxhash/BUILD.mk +++ b/third_party/xxhash/BUILD.mk @@ -21,7 +21,7 @@ THIRD_PARTY_XXHASH_A_DIRECTDEPS = \ LIBC_STDIO \ LIBC_STR \ LIBC_SYSV \ - LIBC_TIME + THIRD_PARTY_TZ THIRD_PARTY_XXHASH_A_DEPS := \ $(call uniq,$(foreach x,$(THIRD_PARTY_XXHASH_A_DIRECTDEPS),$($(x)))) diff --git a/third_party/xxhash/cli/xsum_bench.c b/third_party/xxhash/cli/xsum_bench.c index 12f0e2c0b..8e56eea25 100644 --- a/third_party/xxhash/cli/xsum_bench.c +++ b/third_party/xxhash/cli/xsum_bench.c @@ -61,8 +61,7 @@ #include "libc/sysv/consts/clock.h" #include "libc/sysv/consts/sched.h" #include "libc/sysv/consts/timer.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" /* clock_t, clock, CLOCKS_PER_SEC */ +#include "libc/time.h" /* clock_t, clock, CLOCKS_PER_SEC */ #include "libc/errno.h" /* errno */ #define TIMELOOP_S 1 diff --git a/third_party/xxhash/cli/xsum_config.h b/third_party/xxhash/cli/xsum_config.h index a30cf28a4..f926284c5 100644 --- a/third_party/xxhash/cli/xsum_config.h +++ b/third_party/xxhash/cli/xsum_config.h @@ -87,7 +87,7 @@ #include "libc/sysv/consts/fileno.h" #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/ok.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/musl/crypt.h" #include "third_party/musl/lockf.h" /* declares _POSIX_VERSION */ # if defined(_POSIX_VERSION) /* POSIX compliant */ @@ -138,7 +138,7 @@ #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/str/unicode.h" -#include "libc/time/time.h" +#include "libc/time.h" # if WCHAR_MAX == 0xFFFFU /* UTF-16 wchar_t */ # define XSUM_WIN32_USE_WCHAR 1 # else diff --git a/third_party/xxhash/cli/xsum_os_specific.c b/third_party/xxhash/cli/xsum_os_specific.c index 1a767a16b..3b5fb88fe 100644 --- a/third_party/xxhash/cli/xsum_os_specific.c +++ b/third_party/xxhash/cli/xsum_os_specific.c @@ -31,7 +31,7 @@ #include "libc/calls/weirdtypes.h" #include "libc/sysv/consts/s.h" #include "libc/sysv/consts/utime.h" -#include "libc/time/time.h" /* stat() / _stat64() */ +#include "libc/time.h" /* stat() / _stat64() */ /* * This file contains all of the ugly boilerplate to make xxhsum work across @@ -60,7 +60,7 @@ #include "libc/sysv/consts/fileno.h" #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/ok.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/musl/crypt.h" #include "third_party/musl/lockf.h" /* isatty */ # define XSUM_IS_CONSOLE(stdStream) isatty(fileno(stdStream)) @@ -207,7 +207,7 @@ int main(int argc, const char* argv[]) #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/str/unicode.h" -#include "libc/time/time.h" +#include "libc/time.h" /***************************************************************************** * Unicode conversion tools diff --git a/third_party/xxhash/tests/bench/timefn.h b/third_party/xxhash/tests/bench/timefn.h index ce52d1265..2ab164ab9 100644 --- a/third_party/xxhash/tests/bench/timefn.h +++ b/third_party/xxhash/tests/bench/timefn.h @@ -30,8 +30,7 @@ extern "C" { #if defined(_MSC_VER) // MISSING #include /* utime */ #else -#include "libc/time/struct/utimbuf.h" -#include "libc/time/time.h" /* utime */ +#include "libc/time.h" /* utime */ #endif #include "libc/calls/calls.h" #include "libc/calls/struct/timespec.h" @@ -40,8 +39,7 @@ extern "C" { #include "libc/sysv/consts/clock.h" #include "libc/sysv/consts/sched.h" #include "libc/sysv/consts/timer.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" /* clock_t, clock, CLOCKS_PER_SEC */ +#include "libc/time.h" /* clock_t, clock, CLOCKS_PER_SEC */ diff --git a/third_party/xxhash/tests/collisions/main.c b/third_party/xxhash/tests/collisions/main.c index 8970021c2..bb6499d1d 100644 --- a/third_party/xxhash/tests/collisions/main.c +++ b/third_party/xxhash/tests/collisions/main.c @@ -506,8 +506,7 @@ static inline int Filter_check(const Filter* bf, int bflog, uint64_t hash) #include "libc/sysv/consts/clock.h" #include "libc/sysv/consts/sched.h" #include "libc/sysv/consts/timer.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" /* clock_t, clock, time_t, time, difftime */ +#include "libc/time.h" /* clock_t, clock, time_t, time, difftime */ void update_indicator(uint64_t v, uint64_t total) { diff --git a/third_party/zip/BUILD.mk b/third_party/zip/BUILD.mk index 3ca3d80c9..d0a163fc3 100644 --- a/third_party/zip/BUILD.mk +++ b/third_party/zip/BUILD.mk @@ -90,9 +90,9 @@ THIRD_PARTY_ZIP_DIRECTDEPS = \ LIBC_PROC \ LIBC_STR \ LIBC_SYSV \ - LIBC_TIME \ LIBC_X \ THIRD_PARTY_BZIP2 \ + THIRD_PARTY_TZ \ THIRD_PARTY_ZLIB THIRD_PARTY_ZIP_DEPS := \ diff --git a/third_party/zip/crypt.c b/third_party/zip/crypt.c index bfb702905..e1d9e89d5 100644 --- a/third_party/zip/crypt.c +++ b/third_party/zip/crypt.c @@ -80,8 +80,7 @@ #include "libc/sysv/consts/clock.h" #include "libc/sysv/consts/sched.h" #include "libc/sysv/consts/timer.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" /* time() function supplies first part of crypt seed */ +#include "libc/time.h" /* time() function supplies first part of crypt seed */ /* "last resort" source for second part of crypt seed pattern */ # ifndef ZCR_SEED2 # define ZCR_SEED2 (unsigned)3141592654L /* use PI as default pattern */ diff --git a/third_party/zip/fileio.c b/third_party/zip/fileio.c index 0e4ee237e..cb988b030 100644 --- a/third_party/zip/fileio.c +++ b/third_party/zip/fileio.c @@ -30,8 +30,7 @@ #include "libc/sysv/consts/clock.h" #include "libc/sysv/consts/sched.h" #include "libc/sysv/consts/timer.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" +#include "libc/time.h" #ifdef NO_MKTIME time_t mktime OF((struct tm *)); diff --git a/third_party/zip/osdep.h b/third_party/zip/osdep.h index c002669db..a7299afac 100644 --- a/third_party/zip/osdep.h +++ b/third_party/zip/osdep.h @@ -41,7 +41,7 @@ #include "libc/calls/weirdtypes.h" #include "libc/sysv/consts/s.h" #include "libc/sysv/consts/utime.h" -#include "libc/time/time.h" +#include "libc/time.h" /* printf format size prefix for zoff_t values */ #ifdef LARGE_FILE_SUPPORT diff --git a/third_party/zip/tailor.h b/third_party/zip/tailor.h index 34dc03491..248fbb12b 100644 --- a/third_party/zip/tailor.h +++ b/third_party/zip/tailor.h @@ -258,7 +258,7 @@ #include "libc/sysv/consts/fileno.h" #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/ok.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/musl/crypt.h" #include "third_party/musl/lockf.h" /* usually defines _POSIX_VERSION */ #endif /* !NO_UNISTD_H */ @@ -382,7 +382,7 @@ IZ_IMP char *mktemp(); #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/str/unicode.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "libc/calls/calls.h" #include "libc/fmt/conv.h" #include "libc/str/str.h" diff --git a/third_party/zip/unix.c b/third_party/zip/unix.c index ef9593e99..a1b08b5dc 100644 --- a/third_party/zip/unix.c +++ b/third_party/zip/unix.c @@ -19,8 +19,7 @@ #include "libc/sysv/consts/clock.h" #include "libc/sysv/consts/sched.h" #include "libc/sysv/consts/timer.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" +#include "libc/time.h" #if defined(MINIX) || defined(__mpexl) # ifdef S_IWRITE @@ -60,8 +59,7 @@ /* Library functions not in (most) header files */ #ifdef _POSIX_VERSION -#include "libc/time/struct/utimbuf.h" -#include "libc/time/time.h" +#include "libc/utime.h" #else int utime OF((char *, time_t *)); #endif diff --git a/third_party/zip/zip.c b/third_party/zip/zip.c index baf29593e..8b064dd9e 100644 --- a/third_party/zip/zip.c +++ b/third_party/zip/zip.c @@ -20,8 +20,7 @@ #include "libc/sysv/consts/clock.h" #include "libc/sysv/consts/sched.h" #include "libc/sysv/consts/timer.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" /* for tzset() declaration */ +#include "libc/time.h" /* for tzset() declaration */ #if defined(WIN32) || defined(WINDLL) # define WIN32_LEAN_AND_MEAN #include "libc/nt/accounting.h" diff --git a/third_party/zstd/BUILD.mk b/third_party/zstd/BUILD.mk index 2bf4f894d..1216ed9a4 100644 --- a/third_party/zstd/BUILD.mk +++ b/third_party/zstd/BUILD.mk @@ -124,7 +124,6 @@ THIRD_PARTY_ZSTD_A_DIRECTDEPS = \ LIBC_STDIO \ LIBC_STR \ LIBC_THREAD \ - LIBC_TIME \ LIBC_SYSV THIRD_PARTY_ZSTD_A_DEPS := \ diff --git a/third_party/zstd/lib/compress/zstdmt_compress.c b/third_party/zstd/lib/compress/zstdmt_compress.c index 6d15654f4..35fd48ad3 100644 --- a/third_party/zstd/lib/compress/zstdmt_compress.c +++ b/third_party/zstd/lib/compress/zstdmt_compress.c @@ -55,7 +55,7 @@ #include "libc/sysv/consts/fileno.h" #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/ok.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/musl/crypt.h" #include "third_party/musl/lockf.h" #include "libc/calls/calls.h" diff --git a/third_party/zstd/lib/dictBuilder/cover.c b/third_party/zstd/lib/dictBuilder/cover.c index da4f1e2ba..46a4201e8 100644 --- a/third_party/zstd/lib/dictBuilder/cover.c +++ b/third_party/zstd/lib/dictBuilder/cover.c @@ -52,8 +52,7 @@ #include "libc/sysv/consts/clock.h" #include "libc/sysv/consts/sched.h" #include "libc/sysv/consts/timer.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" /* clock */ +#include "libc/time.h" /* clock */ #ifndef ZDICT_STATIC_LINKING_ONLY # define ZDICT_STATIC_LINKING_ONLY diff --git a/third_party/zstd/lib/dictBuilder/cover.h b/third_party/zstd/lib/dictBuilder/cover.h index a5148b0eb..ec5e7d1e8 100644 --- a/third_party/zstd/lib/dictBuilder/cover.h +++ b/third_party/zstd/lib/dictBuilder/cover.h @@ -43,8 +43,7 @@ #include "libc/sysv/consts/clock.h" #include "libc/sysv/consts/sched.h" #include "libc/sysv/consts/timer.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" /* clock */ +#include "libc/time.h" /* clock */ #include "third_party/zstd/lib/common/mem.h" /* read */ #include "third_party/zstd/lib/common/pool.h" #include "third_party/zstd/lib/common/threading.h" diff --git a/third_party/zstd/lib/dictBuilder/fastcover.c b/third_party/zstd/lib/dictBuilder/fastcover.c index 877ce5392..39bd0949d 100644 --- a/third_party/zstd/lib/dictBuilder/fastcover.c +++ b/third_party/zstd/lib/dictBuilder/fastcover.c @@ -42,8 +42,7 @@ #include "libc/sysv/consts/clock.h" #include "libc/sysv/consts/sched.h" #include "libc/sysv/consts/timer.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" /* clock */ +#include "libc/time.h" /* clock */ #ifndef ZDICT_STATIC_LINKING_ONLY # define ZDICT_STATIC_LINKING_ONLY diff --git a/third_party/zstd/lib/dictBuilder/zdict.c b/third_party/zstd/lib/dictBuilder/zdict.c index eafcb3578..479937ae5 100644 --- a/third_party/zstd/lib/dictBuilder/zdict.c +++ b/third_party/zstd/lib/dictBuilder/zdict.c @@ -67,8 +67,7 @@ #include "libc/sysv/consts/clock.h" #include "libc/sysv/consts/sched.h" #include "libc/sysv/consts/timer.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" /* clock */ +#include "libc/time.h" /* clock */ #ifndef ZDICT_STATIC_LINKING_ONLY # define ZDICT_STATIC_LINKING_ONLY diff --git a/third_party/zstd/programs/fileio.c b/third_party/zstd/programs/fileio.c index 22c264b8f..248893ae9 100644 --- a/third_party/zstd/programs/fileio.c +++ b/third_party/zstd/programs/fileio.c @@ -56,8 +56,7 @@ #include "libc/sysv/consts/clock.h" #include "libc/sysv/consts/sched.h" #include "libc/sysv/consts/timer.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" /* clock_t, to measure process time */ +#include "libc/time.h" /* clock_t, to measure process time */ #include "libc/calls/calls.h" #include "libc/calls/struct/flock.h" #include "libc/calls/weirdtypes.h" @@ -94,7 +93,7 @@ #include "libc/calls/weirdtypes.h" #include "libc/sysv/consts/s.h" #include "libc/sysv/consts/utime.h" -#include "libc/time/time.h" +#include "libc/time.h" // MISSING #include #endif diff --git a/third_party/zstd/programs/fileio_asyncio.c b/third_party/zstd/programs/fileio_asyncio.c index 7630b2f17..646477be3 100644 --- a/third_party/zstd/programs/fileio_asyncio.c +++ b/third_party/zstd/programs/fileio_asyncio.c @@ -41,7 +41,7 @@ #include "libc/calls/weirdtypes.h" #include "libc/sysv/consts/s.h" #include "libc/sysv/consts/utime.h" -#include "libc/time/time.h" +#include "libc/time.h" // MISSING #include #endif diff --git a/third_party/zstd/programs/platform.h b/third_party/zstd/programs/platform.h index 3e3c9f07a..ea93039d7 100644 --- a/third_party/zstd/programs/platform.h +++ b/third_party/zstd/programs/platform.h @@ -92,7 +92,7 @@ extern "C" { #include "libc/sysv/consts/fileno.h" #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/ok.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/musl/crypt.h" #include "third_party/musl/lockf.h" whenever target OS is not unix-like * otherwise it will block preprocessing stage. @@ -105,7 +105,7 @@ extern "C" { #include "libc/sysv/consts/fileno.h" #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/ok.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/getopt/getopt.internal.h" #include "third_party/musl/crypt.h" #include "third_party/musl/lockf.h" @@ -128,7 +128,7 @@ extern "C" { #include "libc/sysv/consts/fileno.h" #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/ok.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/getopt/getopt.internal.h" #include "third_party/musl/crypt.h" #include "third_party/musl/lockf.h" /* declares _POSIX_VERSION */ @@ -179,7 +179,7 @@ extern "C" { #include "libc/sysv/consts/fileno.h" #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/ok.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/getopt/getopt.internal.h" #include "third_party/musl/crypt.h" #include "third_party/musl/lockf.h" /* isatty */ diff --git a/third_party/zstd/programs/timefn.c b/third_party/zstd/programs/timefn.c index 7b4b47871..ee8a5bed7 100644 --- a/third_party/zstd/programs/timefn.c +++ b/third_party/zstd/programs/timefn.c @@ -20,8 +20,7 @@ #include "libc/sysv/consts/clock.h" #include "libc/sysv/consts/sched.h" #include "libc/sysv/consts/timer.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" /* CLOCK_MONOTONIC, TIME_UTC */ +#include "libc/time.h" /* CLOCK_MONOTONIC, TIME_UTC */ /*-**************************************** * Time functions diff --git a/third_party/zstd/programs/util.c b/third_party/zstd/programs/util.c index 2bf785640..1e53f23c2 100644 --- a/third_party/zstd/programs/util.c +++ b/third_party/zstd/programs/util.c @@ -45,8 +45,7 @@ extern "C" { #include "libc/sysv/consts/clock.h" #include "libc/sysv/consts/sched.h" #include "libc/sysv/consts/timer.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" /* clock_t, clock, CLOCKS_PER_SEC, nanosleep */ +#include "libc/time.h" /* clock_t, clock, CLOCKS_PER_SEC, nanosleep */ #include "libc/errno.h" #include "libc/assert.h" @@ -63,13 +62,13 @@ extern "C" { #include "libc/sysv/consts/fileno.h" #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/ok.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/getopt/getopt.internal.h" #include "third_party/musl/crypt.h" #include "third_party/musl/lockf.h" /* chown, stat */ # if PLATFORM_POSIX_VERSION < 200809L || !defined(st_mtime) -#include "libc/time/struct/utimbuf.h" -#include "libc/time/time.h" /* utime */ +#include "libc/utime.h" +#include "libc/time.h" /* utime */ # else #include "libc/calls/calls.h" #include "libc/calls/struct/flock.h" @@ -88,7 +87,7 @@ extern "C" { #include "libc/calls/weirdtypes.h" #include "libc/sysv/consts/s.h" #include "libc/sysv/consts/utime.h" -#include "libc/time/time.h" /* utimensat */ +#include "libc/time.h" /* utimensat */ # endif #endif diff --git a/third_party/zstd/programs/util.h b/third_party/zstd/programs/util.h index d7a7a0ee8..bd39d78f6 100644 --- a/third_party/zstd/programs/util.h +++ b/third_party/zstd/programs/util.h @@ -36,7 +36,7 @@ extern "C" { #include "libc/calls/weirdtypes.h" #include "libc/sysv/consts/s.h" #include "libc/sysv/consts/utime.h" -#include "libc/time/time.h" /* stat, chmod */ +#include "libc/time.h" /* stat, chmod */ #include "third_party/zstd/lib/common/mem.h" /* U64 */ @@ -91,7 +91,7 @@ extern "C" { #include "libc/sysv/consts/fileno.h" #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/ok.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/musl/crypt.h" #include "third_party/musl/lockf.h" /* sleep */ # define UTIL_sleep(s) sleep(s) diff --git a/tool/build/BUILD.mk b/tool/build/BUILD.mk index 1810aed74..844a0ab28 100644 --- a/tool/build/BUILD.mk +++ b/tool/build/BUILD.mk @@ -45,7 +45,6 @@ TOOL_BUILD_DIRECTDEPS = \ LIBC_SYSV \ LIBC_SYSV_CALLS \ LIBC_THREAD \ - LIBC_TIME \ LIBC_TINYMATH \ LIBC_X \ NET_HTTP \ @@ -57,6 +56,7 @@ TOOL_BUILD_DIRECTDEPS = \ THIRD_PARTY_MUSL \ THIRD_PARTY_REGEX \ THIRD_PARTY_STB \ + THIRD_PARTY_TZ \ THIRD_PARTY_XED \ THIRD_PARTY_ZLIB \ THIRD_PARTY_ZLIB_GZ \ diff --git a/tool/build/compile.c b/tool/build/compile.c index 6707351d3..3fbecc55c 100644 --- a/tool/build/compile.c +++ b/tool/build/compile.c @@ -61,7 +61,7 @@ #include "libc/sysv/consts/sig.h" #include "libc/sysv/consts/termios.h" #include "libc/thread/thread.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "libc/x/x.h" #include "third_party/getopt/getopt.internal.h" diff --git a/tool/build/lib/BUILD.mk b/tool/build/lib/BUILD.mk index 0d40181f2..9fe70e019 100644 --- a/tool/build/lib/BUILD.mk +++ b/tool/build/lib/BUILD.mk @@ -46,7 +46,6 @@ TOOL_BUILD_LIB_A_DIRECTDEPS = \ LIBC_SYSV_CALLS \ LIBC_PROC \ LIBC_THREAD \ - LIBC_TIME \ LIBC_TINYMATH \ LIBC_X \ NET_HTTP \ @@ -54,7 +53,8 @@ TOOL_BUILD_LIB_A_DIRECTDEPS = \ THIRD_PARTY_COMPILER_RT \ THIRD_PARTY_MBEDTLS \ THIRD_PARTY_XED \ - THIRD_PARTY_ZLIB + THIRD_PARTY_ZLIB \ + THIRD_PARTY_TZ TOOL_BUILD_LIB_A_DEPS := \ $(call uniq,$(foreach x,$(TOOL_BUILD_LIB_A_DIRECTDEPS),$($(x)))) diff --git a/tool/build/lib/elfwriter_zip.c b/tool/build/lib/elfwriter_zip.c index 7264c8f83..dbe1562d1 100644 --- a/tool/build/lib/elfwriter_zip.c +++ b/tool/build/lib/elfwriter_zip.c @@ -22,7 +22,6 @@ #include "libc/limits.h" #include "libc/log/check.h" #include "libc/mem/gc.h" -#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/nexgen32e/crc32.h" #include "libc/nt/enum/fileflagandattributes.h" @@ -31,7 +30,7 @@ #include "libc/stdio/rand.h" #include "libc/str/str.h" #include "libc/sysv/consts/s.h" -#include "libc/time/struct/tm.h" +#include "libc/time.h" #include "libc/x/x.h" #include "libc/x/xasprintf.h" #include "libc/zip.internal.h" diff --git a/tool/build/runitd.c b/tool/build/runitd.c index 7c8023499..14b1a7e7e 100644 --- a/tool/build/runitd.c +++ b/tool/build/runitd.c @@ -71,8 +71,7 @@ #include "libc/temp.h" #include "libc/thread/thread.h" #include "libc/thread/thread2.h" -#include "libc/time/struct/tm.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "libc/x/x.h" #include "libc/x/xsigaction.h" #include "net/http/escape.h" diff --git a/tool/build/zipobj.c b/tool/build/zipobj.c index f07193539..37cb3ef89 100644 --- a/tool/build/zipobj.c +++ b/tool/build/zipobj.c @@ -37,7 +37,7 @@ #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/prot.h" #include "libc/sysv/consts/s.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "libc/x/x.h" #include "libc/zip.internal.h" #include "third_party/getopt/getopt.internal.h" diff --git a/tool/curl/BUILD.mk b/tool/curl/BUILD.mk index d020ec1df..93b739325 100644 --- a/tool/curl/BUILD.mk +++ b/tool/curl/BUILD.mk @@ -24,12 +24,12 @@ TOOL_CURL_DIRECTDEPS = \ LIBC_STDIO \ LIBC_STR \ LIBC_SYSV \ - LIBC_TIME \ NET_HTTP \ NET_HTTPS \ THIRD_PARTY_GETOPT \ THIRD_PARTY_MBEDTLS \ - THIRD_PARTY_MUSL + THIRD_PARTY_MUSL \ + THIRD_PARTY_TZ TOOL_CURL_DEPS := \ $(call uniq,$(foreach x,$(TOOL_CURL_DIRECTDEPS),$($(x)))) diff --git a/tool/decode/BUILD.mk b/tool/decode/BUILD.mk index e5d2e9eb2..00318107c 100644 --- a/tool/decode/BUILD.mk +++ b/tool/decode/BUILD.mk @@ -33,11 +33,11 @@ TOOL_DECODE_DIRECTDEPS = \ LIBC_STR \ LIBC_SYSV \ LIBC_SYSV_CALLS \ - LIBC_TIME \ LIBC_TINYMATH \ LIBC_X \ THIRD_PARTY_GDTOA \ THIRD_PARTY_GETOPT \ + THIRD_PARTY_TZ \ THIRD_PARTY_XED \ TOOL_DECODE_LIB diff --git a/tool/decode/zip.c b/tool/decode/zip.c index f83f99ff3..e0f8101f4 100644 --- a/tool/decode/zip.c +++ b/tool/decode/zip.c @@ -16,6 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/assert.h" #include "libc/calls/calls.h" #include "libc/calls/struct/stat.h" #include "libc/fmt/libgen.h" @@ -36,8 +37,8 @@ #include "libc/sysv/consts/map.h" #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/prot.h" +#include "libc/time.h" #include "libc/x/xasprintf.h" -#include "libc/x/xiso8601.h" #include "libc/zip.internal.h" #include "tool/decode/lib/asmcodegen.h" #include "tool/decode/lib/disassemblehex.h" @@ -63,6 +64,24 @@ static __wur char *FormatDosTime(uint16_t dostime) { (dostime >> 5) & 0b111111, (dostime << 1) & 0b111110); } +char *xiso8601(struct timespec ts) { + struct tm tm; + if (!localtime_r(&ts.tv_sec, &tm)) + return 0; + int len = 128; + char *res = malloc(len); + char *ptr = res; + char *end = res + len; + if (!res) + return 0; + ptr += strftime(ptr, end - ptr, "%Y-%m-%dT%H:%M:%S", &tm); + ptr += snprintf(ptr, end - ptr, "%09ld", ts.tv_nsec); + ptr += strftime(ptr, end - ptr, "%z", &tm); + unassert(ptr + 1 <= end); + unassert(realloc_in_place(res, ptr - end) == res); + return res; +} + void AdvancePosition(uint8_t *map, size_t *pos, size_t off) { if (off > *pos) { /* printf("\n/\t<%s>\n", "LIMBO"); */ @@ -108,13 +127,13 @@ void ShowNtfs(uint8_t *ntfs, size_t n) { "ntfs attribute tag value #1"); show(".short", gc(xasprintf("%hu", READ16LE(ntfs + 6))), "ntfs attribute tag size"); - show(".quad", gc(xasprintf("%lu", READ64LE(ntfs + 8))), - gc(xasprintf("%s (%s)", "ntfs last modified time", - gc(xiso8601(&mtime))))); + show( + ".quad", gc(xasprintf("%lu", READ64LE(ntfs + 8))), + gc(xasprintf("%s (%s)", "ntfs last modified time", gc(xiso8601(mtime))))); show(".quad", gc(xasprintf("%lu", READ64LE(ntfs + 16))), - gc(xasprintf("%s (%s)", "ntfs last access time", gc(xiso8601(&atime))))); + gc(xasprintf("%s (%s)", "ntfs last access time", gc(xiso8601(atime))))); show(".quad", gc(xasprintf("%lu", READ64LE(ntfs + 24))), - gc(xasprintf("%s (%s)", "ntfs creation time", gc(xiso8601(&ctime))))); + gc(xasprintf("%s (%s)", "ntfs creation time", gc(xiso8601(ctime))))); } void ShowExtendedTimestamp(uint8_t *p, size_t n, bool islocal) { @@ -126,7 +145,7 @@ void ShowExtendedTimestamp(uint8_t *p, size_t n, bool islocal) { if ((flag & 1) && n >= 4) { show(".long", gc(xasprintf("%u", READ32LE(p))), gc(xasprintf("%s (%s)", "last modified", - gc(xiso8601(&(struct timespec){READ32LE(p)}))))); + gc(xiso8601((struct timespec){READ32LE(p)}))))); p += 4; n -= 4; } @@ -135,7 +154,7 @@ void ShowExtendedTimestamp(uint8_t *p, size_t n, bool islocal) { if ((flag & 1) && n >= 4) { show(".long", gc(xasprintf("%u", READ32LE(p))), gc(xasprintf("%s (%s)", "access time", - gc(xiso8601(&(struct timespec){READ32LE(p)}))))); + gc(xiso8601((struct timespec){READ32LE(p)}))))); p += 4; n -= 4; } @@ -143,7 +162,7 @@ void ShowExtendedTimestamp(uint8_t *p, size_t n, bool islocal) { if ((flag & 1) && n >= 4) { show(".long", gc(xasprintf("%u", READ32LE(p))), gc(xasprintf("%s (%s)", "creation time", - gc(xiso8601(&(struct timespec){READ32LE(p)}))))); + gc(xiso8601((struct timespec){READ32LE(p)}))))); p += 4; n -= 4; } diff --git a/tool/emacs/cosmo-stuff.el b/tool/emacs/cosmo-stuff.el index bfca961fe..d8dc17376 100644 --- a/tool/emacs/cosmo-stuff.el +++ b/tool/emacs/cosmo-stuff.el @@ -719,7 +719,7 @@ (default-directory root) (compile-command (cosmo--compile-command this root nil mode "" "" ".runs"))) (compile compile-command) - (gdb (format "gdb -q -nh -i=mi %s -ex run" exec)))))) + (gdb (format "gdb -q -i=mi %s -ex run" exec)))))) (progn (define-key asm-mode-map (kbd "C-c C-d") 'cosmo-debug) diff --git a/tool/net/BUILD.mk b/tool/net/BUILD.mk index 1c7219492..52d55f7ec 100644 --- a/tool/net/BUILD.mk +++ b/tool/net/BUILD.mk @@ -47,7 +47,6 @@ TOOL_NET_DIRECTDEPS = \ LIBC_STR \ LIBC_SYSV \ LIBC_SYSV_CALLS \ - LIBC_TIME \ LIBC_THREAD \ LIBC_TINYMATH \ LIBC_X \ @@ -66,6 +65,7 @@ TOOL_NET_DIRECTDEPS = \ THIRD_PARTY_MBEDTLS \ THIRD_PARTY_REGEX \ THIRD_PARTY_SQLITE3 \ + THIRD_PARTY_TZ \ THIRD_PARTY_ZLIB \ TOOL_ARGS \ TOOL_BUILD_LIB \ diff --git a/tool/net/lfuncs.c b/tool/net/lfuncs.c index 7629d9e9b..e8d566d94 100644 --- a/tool/net/lfuncs.c +++ b/tool/net/lfuncs.c @@ -52,7 +52,7 @@ #include "libc/sysv/consts/rusage.h" #include "libc/sysv/consts/sock.h" #include "libc/thread/thread.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "libc/x/x.h" #include "net/http/escape.h" #include "net/http/http.h" diff --git a/tool/plinko/lib/plinko.c b/tool/plinko/lib/plinko.c index 9766469b8..80417f1f6 100644 --- a/tool/plinko/lib/plinko.c +++ b/tool/plinko/lib/plinko.c @@ -38,7 +38,6 @@ #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/prot.h" #include "libc/sysv/consts/sig.h" -#include "libc/time/clockstonanos.internal.h" #include "third_party/getopt/getopt.internal.h" #include "tool/build/lib/case.h" #include "tool/plinko/lib/char.h" @@ -59,6 +58,13 @@ STATIC_STACK_SIZE(0x100000); #define DISPATCH(ea, tm, r, p1, p2) \ GetDispatchFn(LO(ea))(ea, tm, r, p1, p2, GetShadow(LO(ea))) +static inline uint64_t ClocksToNanos(uint64_t x, uint64_t y) { + // approximation of round(x*.323018) which is usually + // the ratio between inva rdtsc ticks and nanoseconds + uint128_t difference = x - y; + return (difference * 338709) >> 20; +} + static void Unwind(int S) { int s; dword t; diff --git a/tool/plinko/lib/printf.c b/tool/plinko/lib/printf.c index ddc4c50be..09b7da750 100644 --- a/tool/plinko/lib/printf.c +++ b/tool/plinko/lib/printf.c @@ -21,11 +21,17 @@ #include "libc/nexgen32e/rdtsc.h" #include "libc/runtime/runtime.h" #include "libc/str/str.h" -#include "libc/time/clockstonanos.internal.h" #include "tool/plinko/lib/char.h" #include "tool/plinko/lib/plinko.h" #include "tool/plinko/lib/print.h" +static inline uint64_t ClocksToNanos(uint64_t x, uint64_t y) { + // approximation of round(x*.323018) which is usually + // the ratio between inva rdtsc ticks and nanoseconds + uint128_t difference = x - y; + return (difference * 338709) >> 20; +} + static inline long GetVarInt(va_list va, signed char t) { if (t <= 0) return va_arg(va, int); diff --git a/tool/viz/BUILD.mk b/tool/viz/BUILD.mk index 73473d3f3..a087fbf8e 100644 --- a/tool/viz/BUILD.mk +++ b/tool/viz/BUILD.mk @@ -38,7 +38,6 @@ TOOL_VIZ_DIRECTDEPS = \ LIBC_SYSV \ LIBC_SYSV_CALLS \ LIBC_THREAD \ - LIBC_TIME \ LIBC_TINYMATH \ LIBC_VGA \ LIBC_X \ @@ -50,6 +49,7 @@ TOOL_VIZ_DIRECTDEPS = \ THIRD_PARTY_MAXMIND \ THIRD_PARTY_MUSL \ THIRD_PARTY_STB \ + THIRD_PARTY_TZ \ THIRD_PARTY_XED \ THIRD_PARTY_ZLIB \ TOOL_DECODE_LIB \ diff --git a/tool/viz/cpuid.c b/tool/viz/cpuid.c index 657296118..0384d4f30 100644 --- a/tool/viz/cpuid.c +++ b/tool/viz/cpuid.c @@ -26,7 +26,7 @@ #include "libc/nexgen32e/x86info.h" #include "libc/runtime/runtime.h" #include "libc/stdio/stdio.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "libc/x/xasprintf.h" #include "tool/decode/lib/idname.h" #include "tool/decode/lib/x86idnames.h" diff --git a/tool/viz/lib/BUILD.mk b/tool/viz/lib/BUILD.mk index a26d88ed3..92512372c 100644 --- a/tool/viz/lib/BUILD.mk +++ b/tool/viz/lib/BUILD.mk @@ -38,12 +38,12 @@ TOOL_VIZ_LIB_A_DIRECTDEPS = \ LIBC_STR \ LIBC_SYSV \ LIBC_TESTLIB \ - LIBC_TIME \ LIBC_TINYMATH \ LIBC_X \ THIRD_PARTY_COMPILER_RT \ THIRD_PARTY_DLMALLOC \ - THIRD_PARTY_GDTOA + THIRD_PARTY_GDTOA \ + THIRD_PARTY_TZ TOOL_VIZ_LIB_A_DEPS := \ $(call uniq,$(foreach x,$(TOOL_VIZ_LIB_A_DIRECTDEPS),$($(x)))) diff --git a/tool/viz/lib/sharpen.c b/tool/viz/lib/sharpen.c index 55bd5cdd0..eec139e4d 100644 --- a/tool/viz/lib/sharpen.c +++ b/tool/viz/lib/sharpen.c @@ -21,7 +21,7 @@ #include "libc/mem/mem.h" #include "libc/str/str.h" #include "libc/sysv/errfuns.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "libc/x/x.h" #include "tool/viz/lib/convolution.h" #include "tool/viz/lib/graphic.h" diff --git a/tool/viz/lib/unsharp.c b/tool/viz/lib/unsharp.c index 1c1eb9cb4..e4a29ca01 100644 --- a/tool/viz/lib/unsharp.c +++ b/tool/viz/lib/unsharp.c @@ -20,7 +20,7 @@ #include "libc/mem/mem.h" #include "libc/str/str.h" #include "libc/sysv/errfuns.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "libc/x/x.h" #include "tool/viz/lib/convolution.h" #include "tool/viz/lib/graphic.h" diff --git a/tool/viz/lib/ycbcr2rgb3.c b/tool/viz/lib/ycbcr2rgb3.c index 4e8e84b63..96d7d52ff 100644 --- a/tool/viz/lib/ycbcr2rgb3.c +++ b/tool/viz/lib/ycbcr2rgb3.c @@ -44,7 +44,7 @@ #include "libc/str/str.h" #include "libc/sysv/consts/sig.h" #include "libc/sysv/errfuns.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "libc/x/x.h" #include "tool/viz/lib/graphic.h" #include "tool/viz/lib/knobs.h" diff --git a/tool/viz/life.c b/tool/viz/life.c index a57ebbe6c..896e19034 100644 --- a/tool/viz/life.c +++ b/tool/viz/life.c @@ -67,7 +67,7 @@ #include "libc/sysv/consts/poll.h" #include "libc/sysv/consts/sig.h" #include "libc/sysv/consts/termios.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/getopt/getopt.internal.h" /** diff --git a/tool/viz/memzoom.c b/tool/viz/memzoom.c index 8c4eebf7c..fc19e835e 100644 --- a/tool/viz/memzoom.c +++ b/tool/viz/memzoom.c @@ -52,7 +52,7 @@ #include "libc/sysv/consts/prot.h" #include "libc/sysv/consts/sig.h" #include "libc/sysv/consts/termios.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "third_party/getopt/getopt.internal.h" #define USAGE \ diff --git a/tool/viz/printpeb.c b/tool/viz/printpeb.c index a92ab375d..e311b4932 100644 --- a/tool/viz/printpeb.c +++ b/tool/viz/printpeb.c @@ -38,7 +38,7 @@ #include "libc/stdio/stdio.h" #include "libc/sysv/consts/madv.h" #include "libc/sysv/consts/o.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "tool/decode/lib/flagger.h" #include "tool/decode/lib/idname.h" #if defined(__x86_64__) && SupportsWindows() diff --git a/tool/viz/printvideo.c b/tool/viz/printvideo.c index 7d5c04127..6216174c8 100644 --- a/tool/viz/printvideo.c +++ b/tool/viz/printvideo.c @@ -89,7 +89,7 @@ #include "libc/sysv/consts/w.h" #include "libc/sysv/errfuns.h" #include "libc/thread/thread.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "libc/x/xsigaction.h" #include "third_party/getopt/getopt.internal.h" #include "third_party/stb/stb_image_resize.h" diff --git a/tool/viz/tailf.c b/tool/viz/tailf.c index 054feed29..f50a0f153 100644 --- a/tool/viz/tailf.c +++ b/tool/viz/tailf.c @@ -25,7 +25,7 @@ #include "libc/str/str.h" #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/sig.h" -#include "libc/time/time.h" +#include "libc/time.h" #include "libc/x/xsigaction.h" /** diff --git a/usr/share/zoneinfo/Africa/Abidjan b/usr/share/zoneinfo/Africa/Abidjan new file mode 100644 index 000000000..8906e88c8 Binary files /dev/null and b/usr/share/zoneinfo/Africa/Abidjan differ diff --git a/usr/share/zoneinfo/Africa/Algiers b/usr/share/zoneinfo/Africa/Algiers new file mode 100644 index 000000000..56a4dd2a1 Binary files /dev/null and b/usr/share/zoneinfo/Africa/Algiers differ diff --git a/usr/share/zoneinfo/Africa/Bissau b/usr/share/zoneinfo/Africa/Bissau new file mode 100644 index 000000000..0da1d1e21 Binary files /dev/null and b/usr/share/zoneinfo/Africa/Bissau differ diff --git a/usr/share/zoneinfo/Africa/Cairo b/usr/share/zoneinfo/Africa/Cairo new file mode 100644 index 000000000..1e6d48d1c Binary files /dev/null and b/usr/share/zoneinfo/Africa/Cairo differ diff --git a/usr/share/zoneinfo/Africa/Casablanca b/usr/share/zoneinfo/Africa/Casablanca new file mode 100644 index 000000000..240ebb2bf Binary files /dev/null and b/usr/share/zoneinfo/Africa/Casablanca differ diff --git a/usr/share/zoneinfo/Africa/Ceuta b/usr/share/zoneinfo/Africa/Ceuta new file mode 100644 index 000000000..a461dceaa Binary files /dev/null and b/usr/share/zoneinfo/Africa/Ceuta differ diff --git a/usr/share/zoneinfo/Africa/El_Aaiun b/usr/share/zoneinfo/Africa/El_Aaiun new file mode 100644 index 000000000..909c5f968 Binary files /dev/null and b/usr/share/zoneinfo/Africa/El_Aaiun differ diff --git a/usr/share/zoneinfo/Africa/Johannesburg b/usr/share/zoneinfo/Africa/Johannesburg new file mode 100644 index 000000000..bada0638f Binary files /dev/null and b/usr/share/zoneinfo/Africa/Johannesburg differ diff --git a/usr/share/zoneinfo/Africa/Juba b/usr/share/zoneinfo/Africa/Juba new file mode 100644 index 000000000..0aba9ffd8 Binary files /dev/null and b/usr/share/zoneinfo/Africa/Juba differ diff --git a/usr/share/zoneinfo/Africa/Khartoum b/usr/share/zoneinfo/Africa/Khartoum new file mode 100644 index 000000000..3f8e44b8a Binary files /dev/null and b/usr/share/zoneinfo/Africa/Khartoum differ diff --git a/usr/share/zoneinfo/Africa/Lagos b/usr/share/zoneinfo/Africa/Lagos new file mode 100644 index 000000000..3d7a71ba0 Binary files /dev/null and b/usr/share/zoneinfo/Africa/Lagos differ diff --git a/usr/share/zoneinfo/Africa/Maputo b/usr/share/zoneinfo/Africa/Maputo new file mode 100644 index 000000000..581bb0e08 Binary files /dev/null and b/usr/share/zoneinfo/Africa/Maputo differ diff --git a/usr/share/zoneinfo/Africa/Monrovia b/usr/share/zoneinfo/Africa/Monrovia new file mode 100644 index 000000000..837780922 Binary files /dev/null and b/usr/share/zoneinfo/Africa/Monrovia differ diff --git a/usr/share/zoneinfo/Africa/Nairobi b/usr/share/zoneinfo/Africa/Nairobi new file mode 100644 index 000000000..5f4ebcb7f Binary files /dev/null and b/usr/share/zoneinfo/Africa/Nairobi differ diff --git a/usr/share/zoneinfo/Africa/Ndjamena b/usr/share/zoneinfo/Africa/Ndjamena new file mode 100644 index 000000000..ecbc0966d Binary files /dev/null and b/usr/share/zoneinfo/Africa/Ndjamena differ diff --git a/usr/share/zoneinfo/Africa/Sao_Tome b/usr/share/zoneinfo/Africa/Sao_Tome new file mode 100644 index 000000000..425ad3fda Binary files /dev/null and b/usr/share/zoneinfo/Africa/Sao_Tome differ diff --git a/usr/share/zoneinfo/Africa/Tripoli b/usr/share/zoneinfo/Africa/Tripoli new file mode 100644 index 000000000..e0c89971a Binary files /dev/null and b/usr/share/zoneinfo/Africa/Tripoli differ diff --git a/usr/share/zoneinfo/Africa/Tunis b/usr/share/zoneinfo/Africa/Tunis new file mode 100644 index 000000000..ca324cb4c Binary files /dev/null and b/usr/share/zoneinfo/Africa/Tunis differ diff --git a/usr/share/zoneinfo/Africa/Windhoek b/usr/share/zoneinfo/Africa/Windhoek new file mode 100644 index 000000000..0edc52b9b Binary files /dev/null and b/usr/share/zoneinfo/Africa/Windhoek differ diff --git a/usr/share/zoneinfo/US/Aleutian b/usr/share/zoneinfo/America/Adak similarity index 100% rename from usr/share/zoneinfo/US/Aleutian rename to usr/share/zoneinfo/America/Adak diff --git a/usr/share/zoneinfo/US/Alaska b/usr/share/zoneinfo/America/Anchorage similarity index 100% rename from usr/share/zoneinfo/US/Alaska rename to usr/share/zoneinfo/America/Anchorage diff --git a/usr/share/zoneinfo/America/Araguaina b/usr/share/zoneinfo/America/Araguaina new file mode 100644 index 000000000..f66c9f79d Binary files /dev/null and b/usr/share/zoneinfo/America/Araguaina differ diff --git a/usr/share/zoneinfo/America/Argentina/Buenos_Aires b/usr/share/zoneinfo/America/Argentina/Buenos_Aires new file mode 100644 index 000000000..d6f999b86 Binary files /dev/null and b/usr/share/zoneinfo/America/Argentina/Buenos_Aires differ diff --git a/usr/share/zoneinfo/America/Argentina/Catamarca b/usr/share/zoneinfo/America/Argentina/Catamarca new file mode 100644 index 000000000..1dcc8d854 Binary files /dev/null and b/usr/share/zoneinfo/America/Argentina/Catamarca differ diff --git a/usr/share/zoneinfo/America/Argentina/Cordoba b/usr/share/zoneinfo/America/Argentina/Cordoba new file mode 100644 index 000000000..35a52e53d Binary files /dev/null and b/usr/share/zoneinfo/America/Argentina/Cordoba differ diff --git a/usr/share/zoneinfo/America/Argentina/Jujuy b/usr/share/zoneinfo/America/Argentina/Jujuy new file mode 100644 index 000000000..b275f27c0 Binary files /dev/null and b/usr/share/zoneinfo/America/Argentina/Jujuy differ diff --git a/usr/share/zoneinfo/America/Argentina/La_Rioja b/usr/share/zoneinfo/America/Argentina/La_Rioja new file mode 100644 index 000000000..23fca1220 Binary files /dev/null and b/usr/share/zoneinfo/America/Argentina/La_Rioja differ diff --git a/usr/share/zoneinfo/America/Argentina/Mendoza b/usr/share/zoneinfo/America/Argentina/Mendoza new file mode 100644 index 000000000..691c56978 Binary files /dev/null and b/usr/share/zoneinfo/America/Argentina/Mendoza differ diff --git a/usr/share/zoneinfo/America/Argentina/Rio_Gallegos b/usr/share/zoneinfo/America/Argentina/Rio_Gallegos new file mode 100644 index 000000000..991d1fae6 Binary files /dev/null and b/usr/share/zoneinfo/America/Argentina/Rio_Gallegos differ diff --git a/usr/share/zoneinfo/America/Argentina/Salta b/usr/share/zoneinfo/America/Argentina/Salta new file mode 100644 index 000000000..58863e043 Binary files /dev/null and b/usr/share/zoneinfo/America/Argentina/Salta differ diff --git a/usr/share/zoneinfo/America/Argentina/San_Juan b/usr/share/zoneinfo/America/Argentina/San_Juan new file mode 100644 index 000000000..7eba33c1c Binary files /dev/null and b/usr/share/zoneinfo/America/Argentina/San_Juan differ diff --git a/usr/share/zoneinfo/America/Argentina/San_Luis b/usr/share/zoneinfo/America/Argentina/San_Luis new file mode 100644 index 000000000..0a81cbddf Binary files /dev/null and b/usr/share/zoneinfo/America/Argentina/San_Luis differ diff --git a/usr/share/zoneinfo/America/Argentina/Tucuman b/usr/share/zoneinfo/America/Argentina/Tucuman new file mode 100644 index 000000000..10556d5d8 Binary files /dev/null and b/usr/share/zoneinfo/America/Argentina/Tucuman differ diff --git a/usr/share/zoneinfo/America/Argentina/Ushuaia b/usr/share/zoneinfo/America/Argentina/Ushuaia new file mode 100644 index 000000000..e03175027 Binary files /dev/null and b/usr/share/zoneinfo/America/Argentina/Ushuaia differ diff --git a/usr/share/zoneinfo/America/Asuncion b/usr/share/zoneinfo/America/Asuncion new file mode 100644 index 000000000..622503674 Binary files /dev/null and b/usr/share/zoneinfo/America/Asuncion differ diff --git a/usr/share/zoneinfo/America/Bahia b/usr/share/zoneinfo/America/Bahia new file mode 100644 index 000000000..7969e3076 Binary files /dev/null and b/usr/share/zoneinfo/America/Bahia differ diff --git a/usr/share/zoneinfo/America/Bahia_Banderas b/usr/share/zoneinfo/America/Bahia_Banderas new file mode 100644 index 000000000..48faea2ec Binary files /dev/null and b/usr/share/zoneinfo/America/Bahia_Banderas differ diff --git a/usr/share/zoneinfo/America/Barbados b/usr/share/zoneinfo/America/Barbados new file mode 100644 index 000000000..720c9863f Binary files /dev/null and b/usr/share/zoneinfo/America/Barbados differ diff --git a/usr/share/zoneinfo/America/Belem b/usr/share/zoneinfo/America/Belem new file mode 100644 index 000000000..e0d7653c6 Binary files /dev/null and b/usr/share/zoneinfo/America/Belem differ diff --git a/usr/share/zoneinfo/America/Belize b/usr/share/zoneinfo/America/Belize new file mode 100644 index 000000000..bfc19f4e5 Binary files /dev/null and b/usr/share/zoneinfo/America/Belize differ diff --git a/usr/share/zoneinfo/America/Boa_Vista b/usr/share/zoneinfo/America/Boa_Vista new file mode 100644 index 000000000..fca97207b Binary files /dev/null and b/usr/share/zoneinfo/America/Boa_Vista differ diff --git a/usr/share/zoneinfo/America/Bogota b/usr/share/zoneinfo/America/Bogota new file mode 100644 index 000000000..85b903333 Binary files /dev/null and b/usr/share/zoneinfo/America/Bogota differ diff --git a/usr/share/zoneinfo/America/Boise b/usr/share/zoneinfo/America/Boise new file mode 100644 index 000000000..72fec9e8c Binary files /dev/null and b/usr/share/zoneinfo/America/Boise differ diff --git a/usr/share/zoneinfo/America/Cambridge_Bay b/usr/share/zoneinfo/America/Cambridge_Bay new file mode 100644 index 000000000..1092f4b61 Binary files /dev/null and b/usr/share/zoneinfo/America/Cambridge_Bay differ diff --git a/usr/share/zoneinfo/America/Campo_Grande b/usr/share/zoneinfo/America/Campo_Grande new file mode 100644 index 000000000..6855e4e9f Binary files /dev/null and b/usr/share/zoneinfo/America/Campo_Grande differ diff --git a/usr/share/zoneinfo/America/Cancun b/usr/share/zoneinfo/America/Cancun new file mode 100644 index 000000000..640b259fd Binary files /dev/null and b/usr/share/zoneinfo/America/Cancun differ diff --git a/usr/share/zoneinfo/America/Caracas b/usr/share/zoneinfo/America/Caracas new file mode 100644 index 000000000..8dbe6ff74 Binary files /dev/null and b/usr/share/zoneinfo/America/Caracas differ diff --git a/usr/share/zoneinfo/America/Cayenne b/usr/share/zoneinfo/America/Cayenne new file mode 100644 index 000000000..cd49f0534 Binary files /dev/null and b/usr/share/zoneinfo/America/Cayenne differ diff --git a/usr/share/zoneinfo/US/Central b/usr/share/zoneinfo/America/Chicago similarity index 100% rename from usr/share/zoneinfo/US/Central rename to usr/share/zoneinfo/America/Chicago diff --git a/usr/share/zoneinfo/America/Chihuahua b/usr/share/zoneinfo/America/Chihuahua new file mode 100644 index 000000000..5e0a54f00 Binary files /dev/null and b/usr/share/zoneinfo/America/Chihuahua differ diff --git a/usr/share/zoneinfo/America/Ciudad_Juarez b/usr/share/zoneinfo/America/Ciudad_Juarez new file mode 100644 index 000000000..f636ee643 Binary files /dev/null and b/usr/share/zoneinfo/America/Ciudad_Juarez differ diff --git a/usr/share/zoneinfo/America/Costa_Rica b/usr/share/zoneinfo/America/Costa_Rica new file mode 100644 index 000000000..08f0128ee Binary files /dev/null and b/usr/share/zoneinfo/America/Costa_Rica differ diff --git a/usr/share/zoneinfo/America/Cuiaba b/usr/share/zoneinfo/America/Cuiaba new file mode 100644 index 000000000..c09a87558 Binary files /dev/null and b/usr/share/zoneinfo/America/Cuiaba differ diff --git a/usr/share/zoneinfo/America/Danmarkshavn b/usr/share/zoneinfo/America/Danmarkshavn new file mode 100644 index 000000000..8718efcce Binary files /dev/null and b/usr/share/zoneinfo/America/Danmarkshavn differ diff --git a/usr/share/zoneinfo/America/Dawson b/usr/share/zoneinfo/America/Dawson new file mode 100644 index 000000000..07e4c5f4a Binary files /dev/null and b/usr/share/zoneinfo/America/Dawson differ diff --git a/usr/share/zoneinfo/America/Dawson_Creek b/usr/share/zoneinfo/America/Dawson_Creek new file mode 100644 index 000000000..761d1d9af Binary files /dev/null and b/usr/share/zoneinfo/America/Dawson_Creek differ diff --git a/usr/share/zoneinfo/US/Mountain b/usr/share/zoneinfo/America/Denver similarity index 100% rename from usr/share/zoneinfo/US/Mountain rename to usr/share/zoneinfo/America/Denver diff --git a/usr/share/zoneinfo/US/Michigan b/usr/share/zoneinfo/America/Detroit similarity index 100% rename from usr/share/zoneinfo/US/Michigan rename to usr/share/zoneinfo/America/Detroit diff --git a/usr/share/zoneinfo/America/Edmonton b/usr/share/zoneinfo/America/Edmonton new file mode 100644 index 000000000..645ee9453 Binary files /dev/null and b/usr/share/zoneinfo/America/Edmonton differ diff --git a/usr/share/zoneinfo/America/Eirunepe b/usr/share/zoneinfo/America/Eirunepe new file mode 100644 index 000000000..7da4b98fe Binary files /dev/null and b/usr/share/zoneinfo/America/Eirunepe differ diff --git a/usr/share/zoneinfo/America/El_Salvador b/usr/share/zoneinfo/America/El_Salvador new file mode 100644 index 000000000..43484117e Binary files /dev/null and b/usr/share/zoneinfo/America/El_Salvador differ diff --git a/usr/share/zoneinfo/America/Fort_Nelson b/usr/share/zoneinfo/America/Fort_Nelson new file mode 100644 index 000000000..2a49c6c50 Binary files /dev/null and b/usr/share/zoneinfo/America/Fort_Nelson differ diff --git a/usr/share/zoneinfo/America/Fortaleza b/usr/share/zoneinfo/America/Fortaleza new file mode 100644 index 000000000..092e40d70 Binary files /dev/null and b/usr/share/zoneinfo/America/Fortaleza differ diff --git a/usr/share/zoneinfo/America/Glace_Bay b/usr/share/zoneinfo/America/Glace_Bay new file mode 100644 index 000000000..f85eb3415 Binary files /dev/null and b/usr/share/zoneinfo/America/Glace_Bay differ diff --git a/usr/share/zoneinfo/America/Goose_Bay b/usr/share/zoneinfo/America/Goose_Bay new file mode 100644 index 000000000..e2cc3eefc Binary files /dev/null and b/usr/share/zoneinfo/America/Goose_Bay differ diff --git a/usr/share/zoneinfo/America/Grand_Turk b/usr/share/zoneinfo/America/Grand_Turk new file mode 100644 index 000000000..9d90e745b Binary files /dev/null and b/usr/share/zoneinfo/America/Grand_Turk differ diff --git a/usr/share/zoneinfo/America/Guatemala b/usr/share/zoneinfo/America/Guatemala new file mode 100644 index 000000000..8aa8e588e Binary files /dev/null and b/usr/share/zoneinfo/America/Guatemala differ diff --git a/usr/share/zoneinfo/America/Guayaquil b/usr/share/zoneinfo/America/Guayaquil new file mode 100644 index 000000000..381ae6c46 Binary files /dev/null and b/usr/share/zoneinfo/America/Guayaquil differ diff --git a/usr/share/zoneinfo/America/Guyana b/usr/share/zoneinfo/America/Guyana new file mode 100644 index 000000000..bcc66881c Binary files /dev/null and b/usr/share/zoneinfo/America/Guyana differ diff --git a/usr/share/zoneinfo/America/Halifax b/usr/share/zoneinfo/America/Halifax new file mode 100644 index 000000000..9fa850a7d Binary files /dev/null and b/usr/share/zoneinfo/America/Halifax differ diff --git a/usr/share/zoneinfo/America/Havana b/usr/share/zoneinfo/America/Havana new file mode 100644 index 000000000..e06629d36 Binary files /dev/null and b/usr/share/zoneinfo/America/Havana differ diff --git a/usr/share/zoneinfo/America/Hermosillo b/usr/share/zoneinfo/America/Hermosillo new file mode 100644 index 000000000..5c92e2967 Binary files /dev/null and b/usr/share/zoneinfo/America/Hermosillo differ diff --git a/usr/share/zoneinfo/US/East-Indiana b/usr/share/zoneinfo/America/Indiana/Indianapolis similarity index 100% rename from usr/share/zoneinfo/US/East-Indiana rename to usr/share/zoneinfo/America/Indiana/Indianapolis diff --git a/usr/share/zoneinfo/US/Indiana-Starke b/usr/share/zoneinfo/America/Indiana/Knox similarity index 100% rename from usr/share/zoneinfo/US/Indiana-Starke rename to usr/share/zoneinfo/America/Indiana/Knox diff --git a/usr/share/zoneinfo/America/Indiana/Marengo b/usr/share/zoneinfo/America/Indiana/Marengo new file mode 100644 index 000000000..a730fe666 Binary files /dev/null and b/usr/share/zoneinfo/America/Indiana/Marengo differ diff --git a/usr/share/zoneinfo/America/Indiana/Petersburg b/usr/share/zoneinfo/America/Indiana/Petersburg new file mode 100644 index 000000000..341a0235e Binary files /dev/null and b/usr/share/zoneinfo/America/Indiana/Petersburg differ diff --git a/usr/share/zoneinfo/America/Indiana/Tell_City b/usr/share/zoneinfo/America/Indiana/Tell_City new file mode 100644 index 000000000..76e1f6285 Binary files /dev/null and b/usr/share/zoneinfo/America/Indiana/Tell_City differ diff --git a/usr/share/zoneinfo/America/Indiana/Vevay b/usr/share/zoneinfo/America/Indiana/Vevay new file mode 100644 index 000000000..f2acf6cbb Binary files /dev/null and b/usr/share/zoneinfo/America/Indiana/Vevay differ diff --git a/usr/share/zoneinfo/America/Indiana/Vincennes b/usr/share/zoneinfo/America/Indiana/Vincennes new file mode 100644 index 000000000..c255f89b6 Binary files /dev/null and b/usr/share/zoneinfo/America/Indiana/Vincennes differ diff --git a/usr/share/zoneinfo/America/Indiana/Winamac b/usr/share/zoneinfo/America/Indiana/Winamac new file mode 100644 index 000000000..679d321e3 Binary files /dev/null and b/usr/share/zoneinfo/America/Indiana/Winamac differ diff --git a/usr/share/zoneinfo/America/Inuvik b/usr/share/zoneinfo/America/Inuvik new file mode 100644 index 000000000..86639f6ec Binary files /dev/null and b/usr/share/zoneinfo/America/Inuvik differ diff --git a/usr/share/zoneinfo/America/Iqaluit b/usr/share/zoneinfo/America/Iqaluit new file mode 100644 index 000000000..95e055cb5 Binary files /dev/null and b/usr/share/zoneinfo/America/Iqaluit differ diff --git a/usr/share/zoneinfo/America/Jamaica b/usr/share/zoneinfo/America/Jamaica new file mode 100644 index 000000000..be6b1b6f1 Binary files /dev/null and b/usr/share/zoneinfo/America/Jamaica differ diff --git a/usr/share/zoneinfo/America/Juneau b/usr/share/zoneinfo/America/Juneau new file mode 100644 index 000000000..e347b369f Binary files /dev/null and b/usr/share/zoneinfo/America/Juneau differ diff --git a/usr/share/zoneinfo/America/Kentucky/Louisville b/usr/share/zoneinfo/America/Kentucky/Louisville new file mode 100644 index 000000000..f2136d6ed Binary files /dev/null and b/usr/share/zoneinfo/America/Kentucky/Louisville differ diff --git a/usr/share/zoneinfo/America/Kentucky/Monticello b/usr/share/zoneinfo/America/Kentucky/Monticello new file mode 100644 index 000000000..d9f54a18b Binary files /dev/null and b/usr/share/zoneinfo/America/Kentucky/Monticello differ diff --git a/usr/share/zoneinfo/America/La_Paz b/usr/share/zoneinfo/America/La_Paz new file mode 100644 index 000000000..68ddaae76 Binary files /dev/null and b/usr/share/zoneinfo/America/La_Paz differ diff --git a/usr/share/zoneinfo/America/Lima b/usr/share/zoneinfo/America/Lima new file mode 100644 index 000000000..b643c5517 Binary files /dev/null and b/usr/share/zoneinfo/America/Lima differ diff --git a/usr/share/zoneinfo/US/Pacific b/usr/share/zoneinfo/America/Los_Angeles similarity index 100% rename from usr/share/zoneinfo/US/Pacific rename to usr/share/zoneinfo/America/Los_Angeles diff --git a/usr/share/zoneinfo/America/Maceio b/usr/share/zoneinfo/America/Maceio new file mode 100644 index 000000000..dbb8d57d9 Binary files /dev/null and b/usr/share/zoneinfo/America/Maceio differ diff --git a/usr/share/zoneinfo/America/Managua b/usr/share/zoneinfo/America/Managua new file mode 100644 index 000000000..86ef76bf2 Binary files /dev/null and b/usr/share/zoneinfo/America/Managua differ diff --git a/usr/share/zoneinfo/America/Manaus b/usr/share/zoneinfo/America/Manaus new file mode 100644 index 000000000..59c952ebc Binary files /dev/null and b/usr/share/zoneinfo/America/Manaus differ diff --git a/usr/share/zoneinfo/America/Martinique b/usr/share/zoneinfo/America/Martinique new file mode 100644 index 000000000..25c0232d9 Binary files /dev/null and b/usr/share/zoneinfo/America/Martinique differ diff --git a/usr/share/zoneinfo/America/Matamoros b/usr/share/zoneinfo/America/Matamoros new file mode 100644 index 000000000..993ac4755 Binary files /dev/null and b/usr/share/zoneinfo/America/Matamoros differ diff --git a/usr/share/zoneinfo/America/Mazatlan b/usr/share/zoneinfo/America/Mazatlan new file mode 100644 index 000000000..97d4d36c1 Binary files /dev/null and b/usr/share/zoneinfo/America/Mazatlan differ diff --git a/usr/share/zoneinfo/America/Menominee b/usr/share/zoneinfo/America/Menominee new file mode 100644 index 000000000..28d2c56e1 Binary files /dev/null and b/usr/share/zoneinfo/America/Menominee differ diff --git a/usr/share/zoneinfo/America/Merida b/usr/share/zoneinfo/America/Merida new file mode 100644 index 000000000..e5de1131d Binary files /dev/null and b/usr/share/zoneinfo/America/Merida differ diff --git a/usr/share/zoneinfo/America/Metlakatla b/usr/share/zoneinfo/America/Metlakatla new file mode 100644 index 000000000..71b0eab08 Binary files /dev/null and b/usr/share/zoneinfo/America/Metlakatla differ diff --git a/usr/share/zoneinfo/America/Mexico_City b/usr/share/zoneinfo/America/Mexico_City new file mode 100644 index 000000000..80a415c70 Binary files /dev/null and b/usr/share/zoneinfo/America/Mexico_City differ diff --git a/usr/share/zoneinfo/America/Miquelon b/usr/share/zoneinfo/America/Miquelon new file mode 100644 index 000000000..ba95cb0b3 Binary files /dev/null and b/usr/share/zoneinfo/America/Miquelon differ diff --git a/usr/share/zoneinfo/America/Moncton b/usr/share/zoneinfo/America/Moncton new file mode 100644 index 000000000..020e33d97 Binary files /dev/null and b/usr/share/zoneinfo/America/Moncton differ diff --git a/usr/share/zoneinfo/America/Monterrey b/usr/share/zoneinfo/America/Monterrey new file mode 100644 index 000000000..a5822e2c6 Binary files /dev/null and b/usr/share/zoneinfo/America/Monterrey differ diff --git a/usr/share/zoneinfo/America/Montevideo b/usr/share/zoneinfo/America/Montevideo new file mode 100644 index 000000000..4b2fb3e56 Binary files /dev/null and b/usr/share/zoneinfo/America/Montevideo differ diff --git a/usr/share/zoneinfo/US/Eastern b/usr/share/zoneinfo/America/New_York similarity index 100% rename from usr/share/zoneinfo/US/Eastern rename to usr/share/zoneinfo/America/New_York diff --git a/usr/share/zoneinfo/America/Nome b/usr/share/zoneinfo/America/Nome new file mode 100644 index 000000000..23ead1c00 Binary files /dev/null and b/usr/share/zoneinfo/America/Nome differ diff --git a/usr/share/zoneinfo/America/Noronha b/usr/share/zoneinfo/America/Noronha new file mode 100644 index 000000000..9e74745ca Binary files /dev/null and b/usr/share/zoneinfo/America/Noronha differ diff --git a/usr/share/zoneinfo/America/North_Dakota/Beulah b/usr/share/zoneinfo/America/North_Dakota/Beulah new file mode 100644 index 000000000..becf43833 Binary files /dev/null and b/usr/share/zoneinfo/America/North_Dakota/Beulah differ diff --git a/usr/share/zoneinfo/America/North_Dakota/Center b/usr/share/zoneinfo/America/North_Dakota/Center new file mode 100644 index 000000000..d03bda045 Binary files /dev/null and b/usr/share/zoneinfo/America/North_Dakota/Center differ diff --git a/usr/share/zoneinfo/America/North_Dakota/New_Salem b/usr/share/zoneinfo/America/North_Dakota/New_Salem new file mode 100644 index 000000000..ecefc15d8 Binary files /dev/null and b/usr/share/zoneinfo/America/North_Dakota/New_Salem differ diff --git a/usr/share/zoneinfo/America/Nuuk b/usr/share/zoneinfo/America/Nuuk new file mode 100644 index 000000000..310774ea4 Binary files /dev/null and b/usr/share/zoneinfo/America/Nuuk differ diff --git a/usr/share/zoneinfo/America/Ojinaga b/usr/share/zoneinfo/America/Ojinaga new file mode 100644 index 000000000..f7e40c081 Binary files /dev/null and b/usr/share/zoneinfo/America/Ojinaga differ diff --git a/usr/share/zoneinfo/America/Panama b/usr/share/zoneinfo/America/Panama new file mode 100644 index 000000000..9154643f4 Binary files /dev/null and b/usr/share/zoneinfo/America/Panama differ diff --git a/usr/share/zoneinfo/America/Paramaribo b/usr/share/zoneinfo/America/Paramaribo new file mode 100644 index 000000000..24f925a2d Binary files /dev/null and b/usr/share/zoneinfo/America/Paramaribo differ diff --git a/usr/share/zoneinfo/US/Arizona b/usr/share/zoneinfo/America/Phoenix similarity index 100% rename from usr/share/zoneinfo/US/Arizona rename to usr/share/zoneinfo/America/Phoenix diff --git a/usr/share/zoneinfo/America/Port-au-Prince b/usr/share/zoneinfo/America/Port-au-Prince new file mode 100644 index 000000000..3e75731ba Binary files /dev/null and b/usr/share/zoneinfo/America/Port-au-Prince differ diff --git a/usr/share/zoneinfo/America/Porto_Velho b/usr/share/zoneinfo/America/Porto_Velho new file mode 100644 index 000000000..7f8047d93 Binary files /dev/null and b/usr/share/zoneinfo/America/Porto_Velho differ diff --git a/usr/share/zoneinfo/America/Puerto_Rico b/usr/share/zoneinfo/America/Puerto_Rico new file mode 100644 index 000000000..47b4dc341 Binary files /dev/null and b/usr/share/zoneinfo/America/Puerto_Rico differ diff --git a/usr/share/zoneinfo/America/Punta_Arenas b/usr/share/zoneinfo/America/Punta_Arenas new file mode 100644 index 000000000..aa839ea7d Binary files /dev/null and b/usr/share/zoneinfo/America/Punta_Arenas differ diff --git a/usr/share/zoneinfo/America/Rankin_Inlet b/usr/share/zoneinfo/America/Rankin_Inlet new file mode 100644 index 000000000..6d1d90ded Binary files /dev/null and b/usr/share/zoneinfo/America/Rankin_Inlet differ diff --git a/usr/share/zoneinfo/America/Recife b/usr/share/zoneinfo/America/Recife new file mode 100644 index 000000000..305abcb8a Binary files /dev/null and b/usr/share/zoneinfo/America/Recife differ diff --git a/usr/share/zoneinfo/America/Regina b/usr/share/zoneinfo/America/Regina new file mode 100644 index 000000000..a3f8217a5 Binary files /dev/null and b/usr/share/zoneinfo/America/Regina differ diff --git a/usr/share/zoneinfo/America/Resolute b/usr/share/zoneinfo/America/Resolute new file mode 100644 index 000000000..97eb8a9c1 Binary files /dev/null and b/usr/share/zoneinfo/America/Resolute differ diff --git a/usr/share/zoneinfo/America/Rio_Branco b/usr/share/zoneinfo/America/Rio_Branco new file mode 100644 index 000000000..fb5185ca6 Binary files /dev/null and b/usr/share/zoneinfo/America/Rio_Branco differ diff --git a/usr/share/zoneinfo/America/Santarem b/usr/share/zoneinfo/America/Santarem new file mode 100644 index 000000000..f81d14420 Binary files /dev/null and b/usr/share/zoneinfo/America/Santarem differ diff --git a/usr/share/zoneinfo/America/Santiago b/usr/share/zoneinfo/America/Santiago new file mode 100644 index 000000000..d3fc9b834 Binary files /dev/null and b/usr/share/zoneinfo/America/Santiago differ diff --git a/usr/share/zoneinfo/America/Santo_Domingo b/usr/share/zoneinfo/America/Santo_Domingo new file mode 100644 index 000000000..3e0785086 Binary files /dev/null and b/usr/share/zoneinfo/America/Santo_Domingo differ diff --git a/usr/share/zoneinfo/America/Sao_Paulo b/usr/share/zoneinfo/America/Sao_Paulo new file mode 100644 index 000000000..a16da2c4d Binary files /dev/null and b/usr/share/zoneinfo/America/Sao_Paulo differ diff --git a/usr/share/zoneinfo/America/Scoresbysund b/usr/share/zoneinfo/America/Scoresbysund new file mode 100644 index 000000000..fc1b11cbe Binary files /dev/null and b/usr/share/zoneinfo/America/Scoresbysund differ diff --git a/usr/share/zoneinfo/America/Sitka b/usr/share/zoneinfo/America/Sitka new file mode 100644 index 000000000..36681ed78 Binary files /dev/null and b/usr/share/zoneinfo/America/Sitka differ diff --git a/usr/share/zoneinfo/America/St_Johns b/usr/share/zoneinfo/America/St_Johns new file mode 100644 index 000000000..94d790baa Binary files /dev/null and b/usr/share/zoneinfo/America/St_Johns differ diff --git a/usr/share/zoneinfo/America/Swift_Current b/usr/share/zoneinfo/America/Swift_Current new file mode 100644 index 000000000..bdbb49448 Binary files /dev/null and b/usr/share/zoneinfo/America/Swift_Current differ diff --git a/usr/share/zoneinfo/America/Tegucigalpa b/usr/share/zoneinfo/America/Tegucigalpa new file mode 100644 index 000000000..38036a328 Binary files /dev/null and b/usr/share/zoneinfo/America/Tegucigalpa differ diff --git a/usr/share/zoneinfo/America/Thule b/usr/share/zoneinfo/America/Thule new file mode 100644 index 000000000..f38dc56bf Binary files /dev/null and b/usr/share/zoneinfo/America/Thule differ diff --git a/usr/share/zoneinfo/America/Tijuana b/usr/share/zoneinfo/America/Tijuana new file mode 100644 index 000000000..42087af4c Binary files /dev/null and b/usr/share/zoneinfo/America/Tijuana differ diff --git a/usr/share/zoneinfo/America/Toronto b/usr/share/zoneinfo/America/Toronto new file mode 100644 index 000000000..668e70d76 Binary files /dev/null and b/usr/share/zoneinfo/America/Toronto differ diff --git a/usr/share/zoneinfo/America/Vancouver b/usr/share/zoneinfo/America/Vancouver new file mode 100644 index 000000000..c99849111 Binary files /dev/null and b/usr/share/zoneinfo/America/Vancouver differ diff --git a/usr/share/zoneinfo/America/Whitehorse b/usr/share/zoneinfo/America/Whitehorse new file mode 100644 index 000000000..40baa9aba Binary files /dev/null and b/usr/share/zoneinfo/America/Whitehorse differ diff --git a/usr/share/zoneinfo/America/Winnipeg b/usr/share/zoneinfo/America/Winnipeg new file mode 100644 index 000000000..7e646d18e Binary files /dev/null and b/usr/share/zoneinfo/America/Winnipeg differ diff --git a/usr/share/zoneinfo/America/Yakutat b/usr/share/zoneinfo/America/Yakutat new file mode 100644 index 000000000..773feba89 Binary files /dev/null and b/usr/share/zoneinfo/America/Yakutat differ diff --git a/usr/share/zoneinfo/Anchorage b/usr/share/zoneinfo/Anchorage deleted file mode 120000 index cafb24b4f..000000000 --- a/usr/share/zoneinfo/Anchorage +++ /dev/null @@ -1 +0,0 @@ -US/Alaska \ No newline at end of file diff --git a/usr/share/zoneinfo/Antarctica/Casey b/usr/share/zoneinfo/Antarctica/Casey new file mode 100644 index 000000000..84f1c61e5 Binary files /dev/null and b/usr/share/zoneinfo/Antarctica/Casey differ diff --git a/usr/share/zoneinfo/Antarctica/Davis b/usr/share/zoneinfo/Antarctica/Davis new file mode 100644 index 000000000..3ec32224f Binary files /dev/null and b/usr/share/zoneinfo/Antarctica/Davis differ diff --git a/usr/share/zoneinfo/Antarctica/Macquarie b/usr/share/zoneinfo/Antarctica/Macquarie new file mode 100644 index 000000000..99a8e60ed Binary files /dev/null and b/usr/share/zoneinfo/Antarctica/Macquarie differ diff --git a/usr/share/zoneinfo/Antarctica/Mawson b/usr/share/zoneinfo/Antarctica/Mawson new file mode 100644 index 000000000..05e4c6c58 Binary files /dev/null and b/usr/share/zoneinfo/Antarctica/Mawson differ diff --git a/usr/share/zoneinfo/Antarctica/Palmer b/usr/share/zoneinfo/Antarctica/Palmer new file mode 100644 index 000000000..32c194163 Binary files /dev/null and b/usr/share/zoneinfo/Antarctica/Palmer differ diff --git a/usr/share/zoneinfo/Antarctica/Rothera b/usr/share/zoneinfo/Antarctica/Rothera new file mode 100644 index 000000000..ea49c00b2 Binary files /dev/null and b/usr/share/zoneinfo/Antarctica/Rothera differ diff --git a/usr/share/zoneinfo/Antarctica/Troll b/usr/share/zoneinfo/Antarctica/Troll new file mode 100644 index 000000000..2359c44bd Binary files /dev/null and b/usr/share/zoneinfo/Antarctica/Troll differ diff --git a/usr/share/zoneinfo/Antarctica/Vostok b/usr/share/zoneinfo/Antarctica/Vostok new file mode 100644 index 000000000..4ce8f7478 Binary files /dev/null and b/usr/share/zoneinfo/Antarctica/Vostok differ diff --git a/usr/share/zoneinfo/Asia/Almaty b/usr/share/zoneinfo/Asia/Almaty new file mode 100644 index 000000000..02f047d70 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Almaty differ diff --git a/usr/share/zoneinfo/Asia/Amman b/usr/share/zoneinfo/Asia/Amman new file mode 100644 index 000000000..a3f9dff57 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Amman differ diff --git a/usr/share/zoneinfo/Asia/Anadyr b/usr/share/zoneinfo/Asia/Anadyr new file mode 100644 index 000000000..551884d32 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Anadyr differ diff --git a/usr/share/zoneinfo/Asia/Aqtau b/usr/share/zoneinfo/Asia/Aqtau new file mode 100644 index 000000000..3a40d1175 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Aqtau differ diff --git a/usr/share/zoneinfo/Asia/Aqtobe b/usr/share/zoneinfo/Asia/Aqtobe new file mode 100644 index 000000000..62c5840a8 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Aqtobe differ diff --git a/usr/share/zoneinfo/Asia/Ashgabat b/usr/share/zoneinfo/Asia/Ashgabat new file mode 100644 index 000000000..848216726 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Ashgabat differ diff --git a/usr/share/zoneinfo/Asia/Atyrau b/usr/share/zoneinfo/Asia/Atyrau new file mode 100644 index 000000000..cb2c82f65 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Atyrau differ diff --git a/usr/share/zoneinfo/Asia/Baghdad b/usr/share/zoneinfo/Asia/Baghdad new file mode 100644 index 000000000..a3ce97599 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Baghdad differ diff --git a/usr/share/zoneinfo/Asia/Baku b/usr/share/zoneinfo/Asia/Baku new file mode 100644 index 000000000..96203d7a4 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Baku differ diff --git a/usr/share/zoneinfo/Asia/Bangkok b/usr/share/zoneinfo/Asia/Bangkok new file mode 100644 index 000000000..ed687d298 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Bangkok differ diff --git a/usr/share/zoneinfo/Asia/Barnaul b/usr/share/zoneinfo/Asia/Barnaul new file mode 100644 index 000000000..ff976dd3b Binary files /dev/null and b/usr/share/zoneinfo/Asia/Barnaul differ diff --git a/usr/share/zoneinfo/Asia/Beirut b/usr/share/zoneinfo/Asia/Beirut new file mode 100644 index 000000000..55dce5722 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Beirut differ diff --git a/usr/share/zoneinfo/Asia/Bishkek b/usr/share/zoneinfo/Asia/Bishkek new file mode 100644 index 000000000..fe7832cdf Binary files /dev/null and b/usr/share/zoneinfo/Asia/Bishkek differ diff --git a/usr/share/zoneinfo/Asia/Chita b/usr/share/zoneinfo/Asia/Chita new file mode 100644 index 000000000..9d49cd35c Binary files /dev/null and b/usr/share/zoneinfo/Asia/Chita differ diff --git a/usr/share/zoneinfo/Asia/Choibalsan b/usr/share/zoneinfo/Asia/Choibalsan new file mode 100644 index 000000000..0a948c2ea Binary files /dev/null and b/usr/share/zoneinfo/Asia/Choibalsan differ diff --git a/usr/share/zoneinfo/Asia/Colombo b/usr/share/zoneinfo/Asia/Colombo new file mode 100644 index 000000000..3eeb1b72b Binary files /dev/null and b/usr/share/zoneinfo/Asia/Colombo differ diff --git a/usr/share/zoneinfo/Asia/Damascus b/usr/share/zoneinfo/Asia/Damascus new file mode 100644 index 000000000..bd1624de5 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Damascus differ diff --git a/usr/share/zoneinfo/Asia/Dhaka b/usr/share/zoneinfo/Asia/Dhaka new file mode 100644 index 000000000..28136808b Binary files /dev/null and b/usr/share/zoneinfo/Asia/Dhaka differ diff --git a/usr/share/zoneinfo/Asia/Dili b/usr/share/zoneinfo/Asia/Dili new file mode 100644 index 000000000..bb7be9f3a Binary files /dev/null and b/usr/share/zoneinfo/Asia/Dili differ diff --git a/usr/share/zoneinfo/Asia/Dubai b/usr/share/zoneinfo/Asia/Dubai new file mode 100644 index 000000000..58d75bc26 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Dubai differ diff --git a/usr/share/zoneinfo/Asia/Dushanbe b/usr/share/zoneinfo/Asia/Dushanbe new file mode 100644 index 000000000..d83fb076a Binary files /dev/null and b/usr/share/zoneinfo/Asia/Dushanbe differ diff --git a/usr/share/zoneinfo/Asia/Famagusta b/usr/share/zoneinfo/Asia/Famagusta new file mode 100644 index 000000000..cc4417956 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Famagusta differ diff --git a/usr/share/zoneinfo/Asia/Gaza b/usr/share/zoneinfo/Asia/Gaza new file mode 100644 index 000000000..0d7966271 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Gaza differ diff --git a/usr/share/zoneinfo/Asia/Hebron b/usr/share/zoneinfo/Asia/Hebron new file mode 100644 index 000000000..53a3c1431 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Hebron differ diff --git a/usr/share/zoneinfo/Asia/Ho_Chi_Minh b/usr/share/zoneinfo/Asia/Ho_Chi_Minh new file mode 100644 index 000000000..86e21b0f5 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Ho_Chi_Minh differ diff --git a/usr/share/zoneinfo/Asia/Hong_Kong b/usr/share/zoneinfo/Asia/Hong_Kong new file mode 100644 index 000000000..c80e36480 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Hong_Kong differ diff --git a/usr/share/zoneinfo/Asia/Hovd b/usr/share/zoneinfo/Asia/Hovd new file mode 100644 index 000000000..6e08a2612 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Hovd differ diff --git a/usr/share/zoneinfo/Asia/Irkutsk b/usr/share/zoneinfo/Asia/Irkutsk new file mode 100644 index 000000000..550e2a087 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Irkutsk differ diff --git a/usr/share/zoneinfo/Asia/Jakarta b/usr/share/zoneinfo/Asia/Jakarta new file mode 100644 index 000000000..c9752d2f2 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Jakarta differ diff --git a/usr/share/zoneinfo/Asia/Jayapura b/usr/share/zoneinfo/Asia/Jayapura new file mode 100644 index 000000000..7c22f539d Binary files /dev/null and b/usr/share/zoneinfo/Asia/Jayapura differ diff --git a/usr/share/zoneinfo/Israel b/usr/share/zoneinfo/Asia/Jerusalem similarity index 100% rename from usr/share/zoneinfo/Israel rename to usr/share/zoneinfo/Asia/Jerusalem diff --git a/usr/share/zoneinfo/Asia/Kabul b/usr/share/zoneinfo/Asia/Kabul new file mode 100644 index 000000000..660ce4cf6 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Kabul differ diff --git a/usr/share/zoneinfo/Asia/Kamchatka b/usr/share/zoneinfo/Asia/Kamchatka new file mode 100644 index 000000000..c65155402 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Kamchatka differ diff --git a/usr/share/zoneinfo/Asia/Karachi b/usr/share/zoneinfo/Asia/Karachi new file mode 100644 index 000000000..e56d5afda Binary files /dev/null and b/usr/share/zoneinfo/Asia/Karachi differ diff --git a/usr/share/zoneinfo/Asia/Kathmandu b/usr/share/zoneinfo/Asia/Kathmandu new file mode 100644 index 000000000..3a0d330ff Binary files /dev/null and b/usr/share/zoneinfo/Asia/Kathmandu differ diff --git a/usr/share/zoneinfo/Asia/Khandyga b/usr/share/zoneinfo/Asia/Khandyga new file mode 100644 index 000000000..aeb733202 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Khandyga differ diff --git a/usr/share/zoneinfo/Asia/Kolkata b/usr/share/zoneinfo/Asia/Kolkata new file mode 100644 index 000000000..00bc80a65 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Kolkata differ diff --git a/usr/share/zoneinfo/Asia/Krasnoyarsk b/usr/share/zoneinfo/Asia/Krasnoyarsk new file mode 100644 index 000000000..e0d4fcb5c Binary files /dev/null and b/usr/share/zoneinfo/Asia/Krasnoyarsk differ diff --git a/usr/share/zoneinfo/Asia/Kuching b/usr/share/zoneinfo/Asia/Kuching new file mode 100644 index 000000000..59bc6e40b Binary files /dev/null and b/usr/share/zoneinfo/Asia/Kuching differ diff --git a/usr/share/zoneinfo/Asia/Macau b/usr/share/zoneinfo/Asia/Macau new file mode 100644 index 000000000..c22f75e42 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Macau differ diff --git a/usr/share/zoneinfo/Asia/Magadan b/usr/share/zoneinfo/Asia/Magadan new file mode 100644 index 000000000..16bac8444 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Magadan differ diff --git a/usr/share/zoneinfo/Asia/Makassar b/usr/share/zoneinfo/Asia/Makassar new file mode 100644 index 000000000..5990010b6 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Makassar differ diff --git a/usr/share/zoneinfo/Asia/Manila b/usr/share/zoneinfo/Asia/Manila new file mode 100644 index 000000000..3c3584e09 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Manila differ diff --git a/usr/share/zoneinfo/Asia/Nicosia b/usr/share/zoneinfo/Asia/Nicosia new file mode 100644 index 000000000..390347f44 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Nicosia differ diff --git a/usr/share/zoneinfo/Asia/Novokuznetsk b/usr/share/zoneinfo/Asia/Novokuznetsk new file mode 100644 index 000000000..9378d5053 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Novokuznetsk differ diff --git a/usr/share/zoneinfo/Asia/Novosibirsk b/usr/share/zoneinfo/Asia/Novosibirsk new file mode 100644 index 000000000..65a9fa2cd Binary files /dev/null and b/usr/share/zoneinfo/Asia/Novosibirsk differ diff --git a/usr/share/zoneinfo/Asia/Omsk b/usr/share/zoneinfo/Asia/Omsk new file mode 100644 index 000000000..dc0ed422f Binary files /dev/null and b/usr/share/zoneinfo/Asia/Omsk differ diff --git a/usr/share/zoneinfo/Asia/Oral b/usr/share/zoneinfo/Asia/Oral new file mode 100644 index 000000000..25a63ec8b Binary files /dev/null and b/usr/share/zoneinfo/Asia/Oral differ diff --git a/usr/share/zoneinfo/Asia/Pontianak b/usr/share/zoneinfo/Asia/Pontianak new file mode 100644 index 000000000..285bed2c6 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Pontianak differ diff --git a/usr/share/zoneinfo/Asia/Pyongyang b/usr/share/zoneinfo/Asia/Pyongyang new file mode 100644 index 000000000..57240cf89 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Pyongyang differ diff --git a/usr/share/zoneinfo/Asia/Qatar b/usr/share/zoneinfo/Asia/Qatar new file mode 100644 index 000000000..7409d7498 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Qatar differ diff --git a/usr/share/zoneinfo/Asia/Qostanay b/usr/share/zoneinfo/Asia/Qostanay new file mode 100644 index 000000000..109fe4156 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Qostanay differ diff --git a/usr/share/zoneinfo/Asia/Qyzylorda b/usr/share/zoneinfo/Asia/Qyzylorda new file mode 100644 index 000000000..fe4d6c6d6 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Qyzylorda differ diff --git a/usr/share/zoneinfo/Asia/Riyadh b/usr/share/zoneinfo/Asia/Riyadh new file mode 100644 index 000000000..01c47ccb8 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Riyadh differ diff --git a/usr/share/zoneinfo/Asia/Sakhalin b/usr/share/zoneinfo/Asia/Sakhalin new file mode 100644 index 000000000..69f0faad1 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Sakhalin differ diff --git a/usr/share/zoneinfo/Asia/Samarkand b/usr/share/zoneinfo/Asia/Samarkand new file mode 100644 index 000000000..c43e27c5d Binary files /dev/null and b/usr/share/zoneinfo/Asia/Samarkand differ diff --git a/usr/share/zoneinfo/Asia/Seoul b/usr/share/zoneinfo/Asia/Seoul new file mode 100644 index 000000000..1755147fa Binary files /dev/null and b/usr/share/zoneinfo/Asia/Seoul differ diff --git a/usr/share/zoneinfo/Asia/Shanghai b/usr/share/zoneinfo/Asia/Shanghai new file mode 100644 index 000000000..d6b66984a Binary files /dev/null and b/usr/share/zoneinfo/Asia/Shanghai differ diff --git a/usr/share/zoneinfo/Singapore b/usr/share/zoneinfo/Asia/Singapore similarity index 100% rename from usr/share/zoneinfo/Singapore rename to usr/share/zoneinfo/Asia/Singapore diff --git a/usr/share/zoneinfo/Asia/Srednekolymsk b/usr/share/zoneinfo/Asia/Srednekolymsk new file mode 100644 index 000000000..7fdee5cbe Binary files /dev/null and b/usr/share/zoneinfo/Asia/Srednekolymsk differ diff --git a/usr/share/zoneinfo/Asia/Taipei b/usr/share/zoneinfo/Asia/Taipei new file mode 100644 index 000000000..35d89d036 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Taipei differ diff --git a/usr/share/zoneinfo/Asia/Tashkent b/usr/share/zoneinfo/Asia/Tashkent new file mode 100644 index 000000000..65ee428ce Binary files /dev/null and b/usr/share/zoneinfo/Asia/Tashkent differ diff --git a/usr/share/zoneinfo/Asia/Tbilisi b/usr/share/zoneinfo/Asia/Tbilisi new file mode 100644 index 000000000..166e4341d Binary files /dev/null and b/usr/share/zoneinfo/Asia/Tbilisi differ diff --git a/usr/share/zoneinfo/Asia/Tehran b/usr/share/zoneinfo/Asia/Tehran new file mode 100644 index 000000000..824acb042 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Tehran differ diff --git a/usr/share/zoneinfo/Asia/Thimphu b/usr/share/zoneinfo/Asia/Thimphu new file mode 100644 index 000000000..0edc72cfe Binary files /dev/null and b/usr/share/zoneinfo/Asia/Thimphu differ diff --git a/usr/share/zoneinfo/Asia/Tokyo b/usr/share/zoneinfo/Asia/Tokyo new file mode 100644 index 000000000..1aa066ce3 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Tokyo differ diff --git a/usr/share/zoneinfo/Asia/Tomsk b/usr/share/zoneinfo/Asia/Tomsk new file mode 100644 index 000000000..c3c307d7b Binary files /dev/null and b/usr/share/zoneinfo/Asia/Tomsk differ diff --git a/usr/share/zoneinfo/Asia/Ulaanbaatar b/usr/share/zoneinfo/Asia/Ulaanbaatar new file mode 100644 index 000000000..6f5d3a15a Binary files /dev/null and b/usr/share/zoneinfo/Asia/Ulaanbaatar differ diff --git a/usr/share/zoneinfo/Asia/Urumqi b/usr/share/zoneinfo/Asia/Urumqi new file mode 100644 index 000000000..69ff7f6fb Binary files /dev/null and b/usr/share/zoneinfo/Asia/Urumqi differ diff --git a/usr/share/zoneinfo/Asia/Ust-Nera b/usr/share/zoneinfo/Asia/Ust-Nera new file mode 100644 index 000000000..c39331e3a Binary files /dev/null and b/usr/share/zoneinfo/Asia/Ust-Nera differ diff --git a/usr/share/zoneinfo/Asia/Vladivostok b/usr/share/zoneinfo/Asia/Vladivostok new file mode 100644 index 000000000..72a3d4e87 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Vladivostok differ diff --git a/usr/share/zoneinfo/Asia/Yakutsk b/usr/share/zoneinfo/Asia/Yakutsk new file mode 100644 index 000000000..336f932e8 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Yakutsk differ diff --git a/usr/share/zoneinfo/Asia/Yangon b/usr/share/zoneinfo/Asia/Yangon new file mode 100644 index 000000000..14b2ad09e Binary files /dev/null and b/usr/share/zoneinfo/Asia/Yangon differ diff --git a/usr/share/zoneinfo/Asia/Yekaterinburg b/usr/share/zoneinfo/Asia/Yekaterinburg new file mode 100644 index 000000000..a3bf7f29b Binary files /dev/null and b/usr/share/zoneinfo/Asia/Yekaterinburg differ diff --git a/usr/share/zoneinfo/Asia/Yerevan b/usr/share/zoneinfo/Asia/Yerevan new file mode 100644 index 000000000..6dd927cb9 Binary files /dev/null and b/usr/share/zoneinfo/Asia/Yerevan differ diff --git a/usr/share/zoneinfo/Atlantic/Azores b/usr/share/zoneinfo/Atlantic/Azores new file mode 100644 index 000000000..e6e2616e9 Binary files /dev/null and b/usr/share/zoneinfo/Atlantic/Azores differ diff --git a/usr/share/zoneinfo/Atlantic/Bermuda b/usr/share/zoneinfo/Atlantic/Bermuda new file mode 100644 index 000000000..abc75ea7e Binary files /dev/null and b/usr/share/zoneinfo/Atlantic/Bermuda differ diff --git a/usr/share/zoneinfo/Atlantic/Canary b/usr/share/zoneinfo/Atlantic/Canary new file mode 100644 index 000000000..5ab3243a5 Binary files /dev/null and b/usr/share/zoneinfo/Atlantic/Canary differ diff --git a/usr/share/zoneinfo/Atlantic/Cape_Verde b/usr/share/zoneinfo/Atlantic/Cape_Verde new file mode 100644 index 000000000..8f7de1c0a Binary files /dev/null and b/usr/share/zoneinfo/Atlantic/Cape_Verde differ diff --git a/usr/share/zoneinfo/Atlantic/Faroe b/usr/share/zoneinfo/Atlantic/Faroe new file mode 100644 index 000000000..9558bf718 Binary files /dev/null and b/usr/share/zoneinfo/Atlantic/Faroe differ diff --git a/usr/share/zoneinfo/Atlantic/Madeira b/usr/share/zoneinfo/Atlantic/Madeira new file mode 100644 index 000000000..cf965c3f9 Binary files /dev/null and b/usr/share/zoneinfo/Atlantic/Madeira differ diff --git a/usr/share/zoneinfo/Atlantic/South_Georgia b/usr/share/zoneinfo/Atlantic/South_Georgia new file mode 100644 index 000000000..7fa5f4683 Binary files /dev/null and b/usr/share/zoneinfo/Atlantic/South_Georgia differ diff --git a/usr/share/zoneinfo/Atlantic/Stanley b/usr/share/zoneinfo/Atlantic/Stanley new file mode 100644 index 000000000..1a4c8ea86 Binary files /dev/null and b/usr/share/zoneinfo/Atlantic/Stanley differ diff --git a/usr/share/zoneinfo/Australia/Adelaide b/usr/share/zoneinfo/Australia/Adelaide new file mode 100644 index 000000000..3bfbbc563 Binary files /dev/null and b/usr/share/zoneinfo/Australia/Adelaide differ diff --git a/usr/share/zoneinfo/Australia/Brisbane b/usr/share/zoneinfo/Australia/Brisbane new file mode 100644 index 000000000..dc9a980a6 Binary files /dev/null and b/usr/share/zoneinfo/Australia/Brisbane differ diff --git a/usr/share/zoneinfo/Australia/Broken_Hill b/usr/share/zoneinfo/Australia/Broken_Hill new file mode 100644 index 000000000..947b50995 Binary files /dev/null and b/usr/share/zoneinfo/Australia/Broken_Hill differ diff --git a/usr/share/zoneinfo/Australia/Darwin b/usr/share/zoneinfo/Australia/Darwin new file mode 100644 index 000000000..a6a67300d Binary files /dev/null and b/usr/share/zoneinfo/Australia/Darwin differ diff --git a/usr/share/zoneinfo/Australia/Eucla b/usr/share/zoneinfo/Australia/Eucla new file mode 100644 index 000000000..9080f5cdb Binary files /dev/null and b/usr/share/zoneinfo/Australia/Eucla differ diff --git a/usr/share/zoneinfo/Australia/Hobart b/usr/share/zoneinfo/Australia/Hobart new file mode 100644 index 000000000..dc2ef554d Binary files /dev/null and b/usr/share/zoneinfo/Australia/Hobart differ diff --git a/usr/share/zoneinfo/Australia/Lindeman b/usr/share/zoneinfo/Australia/Lindeman new file mode 100644 index 000000000..131d77b54 Binary files /dev/null and b/usr/share/zoneinfo/Australia/Lindeman differ diff --git a/usr/share/zoneinfo/Australia/Lord_Howe b/usr/share/zoneinfo/Australia/Lord_Howe new file mode 100644 index 000000000..4d4ec8cee Binary files /dev/null and b/usr/share/zoneinfo/Australia/Lord_Howe differ diff --git a/usr/share/zoneinfo/Australia/Melbourne b/usr/share/zoneinfo/Australia/Melbourne new file mode 100644 index 000000000..d3f195ac2 Binary files /dev/null and b/usr/share/zoneinfo/Australia/Melbourne differ diff --git a/usr/share/zoneinfo/Australia/Perth b/usr/share/zoneinfo/Australia/Perth new file mode 100644 index 000000000..4f771828c Binary files /dev/null and b/usr/share/zoneinfo/Australia/Perth differ diff --git a/usr/share/zoneinfo/Australia/Sydney b/usr/share/zoneinfo/Australia/Sydney new file mode 100644 index 000000000..1975a3a4b Binary files /dev/null and b/usr/share/zoneinfo/Australia/Sydney differ diff --git a/usr/share/zoneinfo/Beijing b/usr/share/zoneinfo/Beijing deleted file mode 100644 index 763271bcb..000000000 Binary files a/usr/share/zoneinfo/Beijing and /dev/null differ diff --git a/usr/share/zoneinfo/Berlin b/usr/share/zoneinfo/Berlin deleted file mode 100644 index b4f2a2af6..000000000 Binary files a/usr/share/zoneinfo/Berlin and /dev/null differ diff --git a/usr/share/zoneinfo/Boulder b/usr/share/zoneinfo/Boulder deleted file mode 120000 index 8b727a113..000000000 --- a/usr/share/zoneinfo/Boulder +++ /dev/null @@ -1 +0,0 @@ -US/Mountain \ No newline at end of file diff --git a/usr/share/zoneinfo/CET b/usr/share/zoneinfo/CET new file mode 100644 index 000000000..546748d6e Binary files /dev/null and b/usr/share/zoneinfo/CET differ diff --git a/usr/share/zoneinfo/CST6CDT b/usr/share/zoneinfo/CST6CDT new file mode 100644 index 000000000..d93155805 Binary files /dev/null and b/usr/share/zoneinfo/CST6CDT differ diff --git a/usr/share/zoneinfo/Chicago b/usr/share/zoneinfo/Chicago deleted file mode 120000 index 0c6fef91f..000000000 --- a/usr/share/zoneinfo/Chicago +++ /dev/null @@ -1 +0,0 @@ -US/Central \ No newline at end of file diff --git a/usr/share/zoneinfo/EET b/usr/share/zoneinfo/EET new file mode 100644 index 000000000..378919ea1 Binary files /dev/null and b/usr/share/zoneinfo/EET differ diff --git a/usr/share/zoneinfo/EST b/usr/share/zoneinfo/EST new file mode 100644 index 000000000..3ae969114 Binary files /dev/null and b/usr/share/zoneinfo/EST differ diff --git a/usr/share/zoneinfo/EST5EDT b/usr/share/zoneinfo/EST5EDT new file mode 100644 index 000000000..50c95e0cb Binary files /dev/null and b/usr/share/zoneinfo/EST5EDT differ diff --git a/usr/share/zoneinfo/UTC b/usr/share/zoneinfo/Etc/GMT similarity index 100% rename from usr/share/zoneinfo/UTC rename to usr/share/zoneinfo/Etc/GMT diff --git a/usr/share/zoneinfo/Etc/GMT+1 b/usr/share/zoneinfo/Etc/GMT+1 new file mode 100644 index 000000000..98d5dcf91 Binary files /dev/null and b/usr/share/zoneinfo/Etc/GMT+1 differ diff --git a/usr/share/zoneinfo/Etc/GMT+10 b/usr/share/zoneinfo/Etc/GMT+10 new file mode 100644 index 000000000..ecb287e66 Binary files /dev/null and b/usr/share/zoneinfo/Etc/GMT+10 differ diff --git a/usr/share/zoneinfo/Etc/GMT+11 b/usr/share/zoneinfo/Etc/GMT+11 new file mode 100644 index 000000000..e94141297 Binary files /dev/null and b/usr/share/zoneinfo/Etc/GMT+11 differ diff --git a/usr/share/zoneinfo/Etc/GMT+12 b/usr/share/zoneinfo/Etc/GMT+12 new file mode 100644 index 000000000..9c95bd073 Binary files /dev/null and b/usr/share/zoneinfo/Etc/GMT+12 differ diff --git a/usr/share/zoneinfo/Etc/GMT+2 b/usr/share/zoneinfo/Etc/GMT+2 new file mode 100644 index 000000000..6d5ce3db7 Binary files /dev/null and b/usr/share/zoneinfo/Etc/GMT+2 differ diff --git a/usr/share/zoneinfo/Etc/GMT+3 b/usr/share/zoneinfo/Etc/GMT+3 new file mode 100644 index 000000000..5ef7be71f Binary files /dev/null and b/usr/share/zoneinfo/Etc/GMT+3 differ diff --git a/usr/share/zoneinfo/Etc/GMT+4 b/usr/share/zoneinfo/Etc/GMT+4 new file mode 100644 index 000000000..75f16216f Binary files /dev/null and b/usr/share/zoneinfo/Etc/GMT+4 differ diff --git a/usr/share/zoneinfo/Etc/GMT+5 b/usr/share/zoneinfo/Etc/GMT+5 new file mode 100644 index 000000000..589990ae8 Binary files /dev/null and b/usr/share/zoneinfo/Etc/GMT+5 differ diff --git a/usr/share/zoneinfo/Etc/GMT+6 b/usr/share/zoneinfo/Etc/GMT+6 new file mode 100644 index 000000000..fcb60ca24 Binary files /dev/null and b/usr/share/zoneinfo/Etc/GMT+6 differ diff --git a/usr/share/zoneinfo/Etc/GMT+7 b/usr/share/zoneinfo/Etc/GMT+7 new file mode 100644 index 000000000..c0427a40e Binary files /dev/null and b/usr/share/zoneinfo/Etc/GMT+7 differ diff --git a/usr/share/zoneinfo/Etc/GMT+8 b/usr/share/zoneinfo/Etc/GMT+8 new file mode 100644 index 000000000..9bdc2283c Binary files /dev/null and b/usr/share/zoneinfo/Etc/GMT+8 differ diff --git a/usr/share/zoneinfo/Etc/GMT+9 b/usr/share/zoneinfo/Etc/GMT+9 new file mode 100644 index 000000000..ca7a81f65 Binary files /dev/null and b/usr/share/zoneinfo/Etc/GMT+9 differ diff --git a/usr/share/zoneinfo/Etc/GMT-1 b/usr/share/zoneinfo/Etc/GMT-1 new file mode 100644 index 000000000..cb45601c9 Binary files /dev/null and b/usr/share/zoneinfo/Etc/GMT-1 differ diff --git a/usr/share/zoneinfo/Etc/GMT-10 b/usr/share/zoneinfo/Etc/GMT-10 new file mode 100644 index 000000000..11d988e10 Binary files /dev/null and b/usr/share/zoneinfo/Etc/GMT-10 differ diff --git a/usr/share/zoneinfo/Etc/GMT-11 b/usr/share/zoneinfo/Etc/GMT-11 new file mode 100644 index 000000000..f4c5d5cc2 Binary files /dev/null and b/usr/share/zoneinfo/Etc/GMT-11 differ diff --git a/usr/share/zoneinfo/Etc/GMT-12 b/usr/share/zoneinfo/Etc/GMT-12 new file mode 100644 index 000000000..cd397b02c Binary files /dev/null and b/usr/share/zoneinfo/Etc/GMT-12 differ diff --git a/usr/share/zoneinfo/Etc/GMT-13 b/usr/share/zoneinfo/Etc/GMT-13 new file mode 100644 index 000000000..8fad7c6b0 Binary files /dev/null and b/usr/share/zoneinfo/Etc/GMT-13 differ diff --git a/usr/share/zoneinfo/Etc/GMT-14 b/usr/share/zoneinfo/Etc/GMT-14 new file mode 100644 index 000000000..a595e60ee Binary files /dev/null and b/usr/share/zoneinfo/Etc/GMT-14 differ diff --git a/usr/share/zoneinfo/Etc/GMT-2 b/usr/share/zoneinfo/Etc/GMT-2 new file mode 100644 index 000000000..97b44a9ba Binary files /dev/null and b/usr/share/zoneinfo/Etc/GMT-2 differ diff --git a/usr/share/zoneinfo/Etc/GMT-3 b/usr/share/zoneinfo/Etc/GMT-3 new file mode 100644 index 000000000..4eb17ff00 Binary files /dev/null and b/usr/share/zoneinfo/Etc/GMT-3 differ diff --git a/usr/share/zoneinfo/Etc/GMT-4 b/usr/share/zoneinfo/Etc/GMT-4 new file mode 100644 index 000000000..13aef80cb Binary files /dev/null and b/usr/share/zoneinfo/Etc/GMT-4 differ diff --git a/usr/share/zoneinfo/Etc/GMT-5 b/usr/share/zoneinfo/Etc/GMT-5 new file mode 100644 index 000000000..83a281695 Binary files /dev/null and b/usr/share/zoneinfo/Etc/GMT-5 differ diff --git a/usr/share/zoneinfo/Etc/GMT-6 b/usr/share/zoneinfo/Etc/GMT-6 new file mode 100644 index 000000000..79a983e54 Binary files /dev/null and b/usr/share/zoneinfo/Etc/GMT-6 differ diff --git a/usr/share/zoneinfo/Etc/GMT-7 b/usr/share/zoneinfo/Etc/GMT-7 new file mode 100644 index 000000000..e136690e1 Binary files /dev/null and b/usr/share/zoneinfo/Etc/GMT-7 differ diff --git a/usr/share/zoneinfo/Etc/GMT-8 b/usr/share/zoneinfo/Etc/GMT-8 new file mode 100644 index 000000000..bc70fe416 Binary files /dev/null and b/usr/share/zoneinfo/Etc/GMT-8 differ diff --git a/usr/share/zoneinfo/Etc/GMT-9 b/usr/share/zoneinfo/Etc/GMT-9 new file mode 100644 index 000000000..d18cedd52 Binary files /dev/null and b/usr/share/zoneinfo/Etc/GMT-9 differ diff --git a/usr/share/zoneinfo/Etc/UTC b/usr/share/zoneinfo/Etc/UTC new file mode 100644 index 000000000..00841a622 Binary files /dev/null and b/usr/share/zoneinfo/Etc/UTC differ diff --git a/usr/share/zoneinfo/Europe/Andorra b/usr/share/zoneinfo/Europe/Andorra new file mode 100644 index 000000000..38685d421 Binary files /dev/null and b/usr/share/zoneinfo/Europe/Andorra differ diff --git a/usr/share/zoneinfo/Europe/Astrakhan b/usr/share/zoneinfo/Europe/Astrakhan new file mode 100644 index 000000000..aff8d82d2 Binary files /dev/null and b/usr/share/zoneinfo/Europe/Astrakhan differ diff --git a/usr/share/zoneinfo/Europe/Athens b/usr/share/zoneinfo/Europe/Athens new file mode 100644 index 000000000..231bf9c3b Binary files /dev/null and b/usr/share/zoneinfo/Europe/Athens differ diff --git a/usr/share/zoneinfo/Europe/Belgrade b/usr/share/zoneinfo/Europe/Belgrade new file mode 100644 index 000000000..a1bf9281e Binary files /dev/null and b/usr/share/zoneinfo/Europe/Belgrade differ diff --git a/usr/share/zoneinfo/Europe/Berlin b/usr/share/zoneinfo/Europe/Berlin new file mode 100644 index 000000000..465546bd3 Binary files /dev/null and b/usr/share/zoneinfo/Europe/Berlin differ diff --git a/usr/share/zoneinfo/Europe/Brussels b/usr/share/zoneinfo/Europe/Brussels new file mode 100644 index 000000000..31973271d Binary files /dev/null and b/usr/share/zoneinfo/Europe/Brussels differ diff --git a/usr/share/zoneinfo/Europe/Bucharest b/usr/share/zoneinfo/Europe/Bucharest new file mode 100644 index 000000000..c4a391e73 Binary files /dev/null and b/usr/share/zoneinfo/Europe/Bucharest differ diff --git a/usr/share/zoneinfo/Europe/Budapest b/usr/share/zoneinfo/Europe/Budapest new file mode 100644 index 000000000..940be4670 Binary files /dev/null and b/usr/share/zoneinfo/Europe/Budapest differ diff --git a/usr/share/zoneinfo/Europe/Chisinau b/usr/share/zoneinfo/Europe/Chisinau new file mode 100644 index 000000000..9152e6859 Binary files /dev/null and b/usr/share/zoneinfo/Europe/Chisinau differ diff --git a/usr/share/zoneinfo/Europe/Dublin b/usr/share/zoneinfo/Europe/Dublin new file mode 100644 index 000000000..17d2b1582 Binary files /dev/null and b/usr/share/zoneinfo/Europe/Dublin differ diff --git a/usr/share/zoneinfo/Europe/Gibraltar b/usr/share/zoneinfo/Europe/Gibraltar new file mode 100644 index 000000000..017bb2e34 Binary files /dev/null and b/usr/share/zoneinfo/Europe/Gibraltar differ diff --git a/usr/share/zoneinfo/Europe/Helsinki b/usr/share/zoneinfo/Europe/Helsinki new file mode 100644 index 000000000..ff5e56530 Binary files /dev/null and b/usr/share/zoneinfo/Europe/Helsinki differ diff --git a/usr/share/zoneinfo/Europe/Istanbul b/usr/share/zoneinfo/Europe/Istanbul new file mode 100644 index 000000000..c89186687 Binary files /dev/null and b/usr/share/zoneinfo/Europe/Istanbul differ diff --git a/usr/share/zoneinfo/Europe/Kaliningrad b/usr/share/zoneinfo/Europe/Kaliningrad new file mode 100644 index 000000000..0ec475647 Binary files /dev/null and b/usr/share/zoneinfo/Europe/Kaliningrad differ diff --git a/usr/share/zoneinfo/Europe/Kirov b/usr/share/zoneinfo/Europe/Kirov new file mode 100644 index 000000000..bfac56111 Binary files /dev/null and b/usr/share/zoneinfo/Europe/Kirov differ diff --git a/usr/share/zoneinfo/Europe/Kyiv b/usr/share/zoneinfo/Europe/Kyiv new file mode 100644 index 000000000..753a6c86f Binary files /dev/null and b/usr/share/zoneinfo/Europe/Kyiv differ diff --git a/usr/share/zoneinfo/Europe/Lisbon b/usr/share/zoneinfo/Europe/Lisbon new file mode 100644 index 000000000..f0c70b690 Binary files /dev/null and b/usr/share/zoneinfo/Europe/Lisbon differ diff --git a/usr/share/zoneinfo/Europe/London b/usr/share/zoneinfo/Europe/London new file mode 100644 index 000000000..b9e95d926 Binary files /dev/null and b/usr/share/zoneinfo/Europe/London differ diff --git a/usr/share/zoneinfo/Europe/Madrid b/usr/share/zoneinfo/Europe/Madrid new file mode 100644 index 000000000..60bdf4d07 Binary files /dev/null and b/usr/share/zoneinfo/Europe/Madrid differ diff --git a/usr/share/zoneinfo/Europe/Malta b/usr/share/zoneinfo/Europe/Malta new file mode 100644 index 000000000..27539c224 Binary files /dev/null and b/usr/share/zoneinfo/Europe/Malta differ diff --git a/usr/share/zoneinfo/Europe/Minsk b/usr/share/zoneinfo/Europe/Minsk new file mode 100644 index 000000000..30d3a672b Binary files /dev/null and b/usr/share/zoneinfo/Europe/Minsk differ diff --git a/usr/share/zoneinfo/Europe/Moscow b/usr/share/zoneinfo/Europe/Moscow new file mode 100644 index 000000000..5e6b6de64 Binary files /dev/null and b/usr/share/zoneinfo/Europe/Moscow differ diff --git a/usr/share/zoneinfo/Europe/Paris b/usr/share/zoneinfo/Europe/Paris new file mode 100644 index 000000000..00a27264c Binary files /dev/null and b/usr/share/zoneinfo/Europe/Paris differ diff --git a/usr/share/zoneinfo/Europe/Prague b/usr/share/zoneinfo/Europe/Prague new file mode 100644 index 000000000..fb7c145ac Binary files /dev/null and b/usr/share/zoneinfo/Europe/Prague differ diff --git a/usr/share/zoneinfo/Europe/Riga b/usr/share/zoneinfo/Europe/Riga new file mode 100644 index 000000000..d99170b64 Binary files /dev/null and b/usr/share/zoneinfo/Europe/Riga differ diff --git a/usr/share/zoneinfo/Europe/Rome b/usr/share/zoneinfo/Europe/Rome new file mode 100644 index 000000000..639ca3be4 Binary files /dev/null and b/usr/share/zoneinfo/Europe/Rome differ diff --git a/usr/share/zoneinfo/Europe/Samara b/usr/share/zoneinfo/Europe/Samara new file mode 100644 index 000000000..8d0c26e5c Binary files /dev/null and b/usr/share/zoneinfo/Europe/Samara differ diff --git a/usr/share/zoneinfo/Europe/Saratov b/usr/share/zoneinfo/Europe/Saratov new file mode 100644 index 000000000..2684d8f8b Binary files /dev/null and b/usr/share/zoneinfo/Europe/Saratov differ diff --git a/usr/share/zoneinfo/Europe/Simferopol b/usr/share/zoneinfo/Europe/Simferopol new file mode 100644 index 000000000..298b8326c Binary files /dev/null and b/usr/share/zoneinfo/Europe/Simferopol differ diff --git a/usr/share/zoneinfo/Europe/Sofia b/usr/share/zoneinfo/Europe/Sofia new file mode 100644 index 000000000..89450685c Binary files /dev/null and b/usr/share/zoneinfo/Europe/Sofia differ diff --git a/usr/share/zoneinfo/Europe/Tallinn b/usr/share/zoneinfo/Europe/Tallinn new file mode 100644 index 000000000..fbebdc625 Binary files /dev/null and b/usr/share/zoneinfo/Europe/Tallinn differ diff --git a/usr/share/zoneinfo/Europe/Tirane b/usr/share/zoneinfo/Europe/Tirane new file mode 100644 index 000000000..743a7337f Binary files /dev/null and b/usr/share/zoneinfo/Europe/Tirane differ diff --git a/usr/share/zoneinfo/Europe/Ulyanovsk b/usr/share/zoneinfo/Europe/Ulyanovsk new file mode 100644 index 000000000..bb842cb1f Binary files /dev/null and b/usr/share/zoneinfo/Europe/Ulyanovsk differ diff --git a/usr/share/zoneinfo/Europe/Vienna b/usr/share/zoneinfo/Europe/Vienna new file mode 100644 index 000000000..75339e98d Binary files /dev/null and b/usr/share/zoneinfo/Europe/Vienna differ diff --git a/usr/share/zoneinfo/Europe/Vilnius b/usr/share/zoneinfo/Europe/Vilnius new file mode 100644 index 000000000..43c3d7f10 Binary files /dev/null and b/usr/share/zoneinfo/Europe/Vilnius differ diff --git a/usr/share/zoneinfo/Europe/Volgograd b/usr/share/zoneinfo/Europe/Volgograd new file mode 100644 index 000000000..0715d58bc Binary files /dev/null and b/usr/share/zoneinfo/Europe/Volgograd differ diff --git a/usr/share/zoneinfo/Europe/Warsaw b/usr/share/zoneinfo/Europe/Warsaw new file mode 100644 index 000000000..efe1a40f2 Binary files /dev/null and b/usr/share/zoneinfo/Europe/Warsaw differ diff --git a/usr/share/zoneinfo/Europe/Zurich b/usr/share/zoneinfo/Europe/Zurich new file mode 100644 index 000000000..388df2969 Binary files /dev/null and b/usr/share/zoneinfo/Europe/Zurich differ diff --git a/usr/share/zoneinfo/GMT b/usr/share/zoneinfo/GMT deleted file mode 120000 index 1ed082089..000000000 --- a/usr/share/zoneinfo/GMT +++ /dev/null @@ -1 +0,0 @@ -UTC \ No newline at end of file diff --git a/usr/share/zoneinfo/GMT b/usr/share/zoneinfo/GMT new file mode 100644 index 000000000..157573b1d Binary files /dev/null and b/usr/share/zoneinfo/GMT differ diff --git a/usr/share/zoneinfo/GST b/usr/share/zoneinfo/GST deleted file mode 120000 index e2ebd1750..000000000 --- a/usr/share/zoneinfo/GST +++ /dev/null @@ -1 +0,0 @@ -US/Pacific \ No newline at end of file diff --git a/usr/share/zoneinfo/HST b/usr/share/zoneinfo/HST new file mode 100644 index 000000000..160a53e04 Binary files /dev/null and b/usr/share/zoneinfo/HST differ diff --git a/usr/share/zoneinfo/Honolulu b/usr/share/zoneinfo/Honolulu deleted file mode 120000 index 16c5c6023..000000000 --- a/usr/share/zoneinfo/Honolulu +++ /dev/null @@ -1 +0,0 @@ -US/Hawaii \ No newline at end of file diff --git a/usr/share/zoneinfo/India b/usr/share/zoneinfo/India deleted file mode 100644 index 0014046d2..000000000 Binary files a/usr/share/zoneinfo/India and /dev/null differ diff --git a/usr/share/zoneinfo/Indian/Chagos b/usr/share/zoneinfo/Indian/Chagos new file mode 100644 index 000000000..8b8ce226b Binary files /dev/null and b/usr/share/zoneinfo/Indian/Chagos differ diff --git a/usr/share/zoneinfo/Indian/Maldives b/usr/share/zoneinfo/Indian/Maldives new file mode 100644 index 000000000..58a82e4eb Binary files /dev/null and b/usr/share/zoneinfo/Indian/Maldives differ diff --git a/usr/share/zoneinfo/Indian/Mauritius b/usr/share/zoneinfo/Indian/Mauritius new file mode 100644 index 000000000..7c1113488 Binary files /dev/null and b/usr/share/zoneinfo/Indian/Mauritius differ diff --git a/usr/share/zoneinfo/Japan b/usr/share/zoneinfo/Japan deleted file mode 100644 index 5ea81c532..000000000 Binary files a/usr/share/zoneinfo/Japan and /dev/null differ diff --git a/usr/share/zoneinfo/London b/usr/share/zoneinfo/London deleted file mode 100644 index 4527515ca..000000000 Binary files a/usr/share/zoneinfo/London and /dev/null differ diff --git a/usr/share/zoneinfo/MET b/usr/share/zoneinfo/MET new file mode 100644 index 000000000..6f0558c3b Binary files /dev/null and b/usr/share/zoneinfo/MET differ diff --git a/usr/share/zoneinfo/MST b/usr/share/zoneinfo/MST new file mode 100644 index 000000000..a0953d1e7 Binary files /dev/null and b/usr/share/zoneinfo/MST differ diff --git a/usr/share/zoneinfo/MST7MDT b/usr/share/zoneinfo/MST7MDT new file mode 100644 index 000000000..137867c8b Binary files /dev/null and b/usr/share/zoneinfo/MST7MDT differ diff --git a/usr/share/zoneinfo/Melbourne b/usr/share/zoneinfo/Melbourne deleted file mode 100644 index ec8dfe038..000000000 Binary files a/usr/share/zoneinfo/Melbourne and /dev/null differ diff --git a/usr/share/zoneinfo/New_York b/usr/share/zoneinfo/New_York deleted file mode 120000 index b8d5363be..000000000 --- a/usr/share/zoneinfo/New_York +++ /dev/null @@ -1 +0,0 @@ -US/Eastern \ No newline at end of file diff --git a/usr/share/zoneinfo/PST8PDT b/usr/share/zoneinfo/PST8PDT new file mode 100644 index 000000000..fde4833f6 Binary files /dev/null and b/usr/share/zoneinfo/PST8PDT differ diff --git a/usr/share/zoneinfo/Pacific/Apia b/usr/share/zoneinfo/Pacific/Apia new file mode 100644 index 000000000..a6b835aab Binary files /dev/null and b/usr/share/zoneinfo/Pacific/Apia differ diff --git a/usr/share/zoneinfo/Pacific/Auckland b/usr/share/zoneinfo/Pacific/Auckland new file mode 100644 index 000000000..afb392931 Binary files /dev/null and b/usr/share/zoneinfo/Pacific/Auckland differ diff --git a/usr/share/zoneinfo/Pacific/Bougainville b/usr/share/zoneinfo/Pacific/Bougainville new file mode 100644 index 000000000..7c667093c Binary files /dev/null and b/usr/share/zoneinfo/Pacific/Bougainville differ diff --git a/usr/share/zoneinfo/Pacific/Chatham b/usr/share/zoneinfo/Pacific/Chatham new file mode 100644 index 000000000..f06065ebd Binary files /dev/null and b/usr/share/zoneinfo/Pacific/Chatham differ diff --git a/usr/share/zoneinfo/Pacific/Easter b/usr/share/zoneinfo/Pacific/Easter new file mode 100644 index 000000000..54dff005b Binary files /dev/null and b/usr/share/zoneinfo/Pacific/Easter differ diff --git a/usr/share/zoneinfo/Pacific/Efate b/usr/share/zoneinfo/Pacific/Efate new file mode 100644 index 000000000..bf7471dd3 Binary files /dev/null and b/usr/share/zoneinfo/Pacific/Efate differ diff --git a/usr/share/zoneinfo/Pacific/Fakaofo b/usr/share/zoneinfo/Pacific/Fakaofo new file mode 100644 index 000000000..b7b30213e Binary files /dev/null and b/usr/share/zoneinfo/Pacific/Fakaofo differ diff --git a/usr/share/zoneinfo/Pacific/Fiji b/usr/share/zoneinfo/Pacific/Fiji new file mode 100644 index 000000000..610b850b1 Binary files /dev/null and b/usr/share/zoneinfo/Pacific/Fiji differ diff --git a/usr/share/zoneinfo/Pacific/Galapagos b/usr/share/zoneinfo/Pacific/Galapagos new file mode 100644 index 000000000..a9403eca4 Binary files /dev/null and b/usr/share/zoneinfo/Pacific/Galapagos differ diff --git a/usr/share/zoneinfo/Pacific/Gambier b/usr/share/zoneinfo/Pacific/Gambier new file mode 100644 index 000000000..ddfc34ffc Binary files /dev/null and b/usr/share/zoneinfo/Pacific/Gambier differ diff --git a/usr/share/zoneinfo/Pacific/Guadalcanal b/usr/share/zoneinfo/Pacific/Guadalcanal new file mode 100644 index 000000000..720c67901 Binary files /dev/null and b/usr/share/zoneinfo/Pacific/Guadalcanal differ diff --git a/usr/share/zoneinfo/Pacific/Guam b/usr/share/zoneinfo/Pacific/Guam new file mode 100644 index 000000000..bf9a2d955 Binary files /dev/null and b/usr/share/zoneinfo/Pacific/Guam differ diff --git a/usr/share/zoneinfo/US/Hawaii b/usr/share/zoneinfo/Pacific/Honolulu similarity index 100% rename from usr/share/zoneinfo/US/Hawaii rename to usr/share/zoneinfo/Pacific/Honolulu diff --git a/usr/share/zoneinfo/Pacific/Kanton b/usr/share/zoneinfo/Pacific/Kanton new file mode 100644 index 000000000..2b6a06088 Binary files /dev/null and b/usr/share/zoneinfo/Pacific/Kanton differ diff --git a/usr/share/zoneinfo/Pacific/Kiritimati b/usr/share/zoneinfo/Pacific/Kiritimati new file mode 100644 index 000000000..2f676d3bf Binary files /dev/null and b/usr/share/zoneinfo/Pacific/Kiritimati differ diff --git a/usr/share/zoneinfo/Pacific/Kosrae b/usr/share/zoneinfo/Pacific/Kosrae new file mode 100644 index 000000000..f5d58242c Binary files /dev/null and b/usr/share/zoneinfo/Pacific/Kosrae differ diff --git a/usr/share/zoneinfo/Pacific/Kwajalein b/usr/share/zoneinfo/Pacific/Kwajalein new file mode 100644 index 000000000..9416d522d Binary files /dev/null and b/usr/share/zoneinfo/Pacific/Kwajalein differ diff --git a/usr/share/zoneinfo/Pacific/Marquesas b/usr/share/zoneinfo/Pacific/Marquesas new file mode 100644 index 000000000..6ea24b72c Binary files /dev/null and b/usr/share/zoneinfo/Pacific/Marquesas differ diff --git a/usr/share/zoneinfo/Pacific/Nauru b/usr/share/zoneinfo/Pacific/Nauru new file mode 100644 index 000000000..ae13aac77 Binary files /dev/null and b/usr/share/zoneinfo/Pacific/Nauru differ diff --git a/usr/share/zoneinfo/Pacific/Niue b/usr/share/zoneinfo/Pacific/Niue new file mode 100644 index 000000000..be874e247 Binary files /dev/null and b/usr/share/zoneinfo/Pacific/Niue differ diff --git a/usr/share/zoneinfo/Pacific/Norfolk b/usr/share/zoneinfo/Pacific/Norfolk new file mode 100644 index 000000000..0c0bdbda2 Binary files /dev/null and b/usr/share/zoneinfo/Pacific/Norfolk differ diff --git a/usr/share/zoneinfo/Pacific/Noumea b/usr/share/zoneinfo/Pacific/Noumea new file mode 100644 index 000000000..824f81416 Binary files /dev/null and b/usr/share/zoneinfo/Pacific/Noumea differ diff --git a/usr/share/zoneinfo/US/Samoa b/usr/share/zoneinfo/Pacific/Pago_Pago similarity index 100% rename from usr/share/zoneinfo/US/Samoa rename to usr/share/zoneinfo/Pacific/Pago_Pago diff --git a/usr/share/zoneinfo/Pacific/Palau b/usr/share/zoneinfo/Pacific/Palau new file mode 100644 index 000000000..bc8eb7a55 Binary files /dev/null and b/usr/share/zoneinfo/Pacific/Palau differ diff --git a/usr/share/zoneinfo/Pacific/Pitcairn b/usr/share/zoneinfo/Pacific/Pitcairn new file mode 100644 index 000000000..8a4ba4d30 Binary files /dev/null and b/usr/share/zoneinfo/Pacific/Pitcairn differ diff --git a/usr/share/zoneinfo/Pacific/Port_Moresby b/usr/share/zoneinfo/Pacific/Port_Moresby new file mode 100644 index 000000000..5d8fc3a1b Binary files /dev/null and b/usr/share/zoneinfo/Pacific/Port_Moresby differ diff --git a/usr/share/zoneinfo/Pacific/Rarotonga b/usr/share/zoneinfo/Pacific/Rarotonga new file mode 100644 index 000000000..7220bda0a Binary files /dev/null and b/usr/share/zoneinfo/Pacific/Rarotonga differ diff --git a/usr/share/zoneinfo/Pacific/Tahiti b/usr/share/zoneinfo/Pacific/Tahiti new file mode 100644 index 000000000..50a064fa0 Binary files /dev/null and b/usr/share/zoneinfo/Pacific/Tahiti differ diff --git a/usr/share/zoneinfo/Pacific/Tarawa b/usr/share/zoneinfo/Pacific/Tarawa new file mode 100644 index 000000000..6bc216823 Binary files /dev/null and b/usr/share/zoneinfo/Pacific/Tarawa differ diff --git a/usr/share/zoneinfo/Pacific/Tongatapu b/usr/share/zoneinfo/Pacific/Tongatapu new file mode 100644 index 000000000..f28c84018 Binary files /dev/null and b/usr/share/zoneinfo/Pacific/Tongatapu differ diff --git a/usr/share/zoneinfo/Sydney b/usr/share/zoneinfo/Sydney deleted file mode 100644 index f4343b326..000000000 Binary files a/usr/share/zoneinfo/Sydney and /dev/null differ diff --git a/usr/share/zoneinfo/WET b/usr/share/zoneinfo/WET new file mode 100644 index 000000000..423c6c203 Binary files /dev/null and b/usr/share/zoneinfo/WET differ