diff --git a/configure b/configure index 8682b88f7e0..f2507f7b167 100755 --- a/configure +++ b/configure @@ -34539,7 +34539,7 @@ _ACEOF if test ${use_internal_tzcode} = yes; then -$as_echo "#define USE_INTERNAL_MKTME 1" >>confdefs.h +$as_echo "#define USE_INTERNAL_MKTIME 1" >>confdefs.h fi if test "x${use_internal_tzcode}" = xyes; then diff --git a/configure.ac b/configure.ac index cf99dee1a9d..9fc3ac6bcae 100644 --- a/configure.ac +++ b/configure.ac @@ -2274,7 +2274,7 @@ fi AC_DEFINE_UNQUOTED(VALGRIND_LEVEL, ${valgrind_level}, [Define as 1 or 2 to specify levels of Valgrind instrumentation]) if test ${use_internal_tzcode} = yes; then - AC_DEFINE(USE_INTERNAL_MKTME, 1, [Define to use internal time-zone code]) + AC_DEFINE(USE_INTERNAL_MKITME, 1, [Define to use internal time-zone code]) fi AM_CONDITIONAL(BUILD_TZONE, [test "x${use_internal_tzcode}" = xyes]) diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 49c5bd9637b..9162585a01a 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -169,8 +169,15 @@ are not installed: but recommended packages remain needed for thorough checking of an \R build. - \item (Windows only.) The version of \samp{tzcode} included in - \file{src/extra/tzone} has been updated. + \item The version of \samp{tzcode} included in + \file{src/extra/tzone} has been updated. (Formerly used only on + Windows.) + + \item There is experimental support to use the shipped Olson + time-zone database and (64-bit) time-zone conversion code: use + \command{configure} option \option{--with-internal-tzcode}. (It + might be necessary to set environment variable \env{TZ} on OSes + where this is not already set.) } } diff --git a/share/Makefile.in b/share/Makefile.in index 1a2617bdbe1..7c48885471c 100644 --- a/share/Makefile.in +++ b/share/Makefile.in @@ -45,7 +45,7 @@ installdirs: @$(MKINSTALLDIRS) "$(DESTDIR)$(rsharedir)/texmf/tex/latex" install-message: @$(ECHO) "installing share ..." -install-sources: installdirs +install-sources: installdirs @BUILD_TZONE_TRUE@ install-zoneinfo @for f in $(srcdir)/R/*.R; do \ $(INSTALL_DATA) $${f} "$(DESTDIR)$(rsharedir)/R"; \ done @@ -78,6 +78,9 @@ install-sources: installdirs done install-strip: install +install-zoneinfo: + @@R_UNZIPCMD@ -qo $(top_srcdir)/src/extra/tzone/zoneinfo.zip -d "$(DESTDIR)$(rsharedir)" + uninstall: @$(ECHO) "uninstalling share ..." @rm -rf "$(DESTDIR)$(rsharedir)" diff --git a/src/extra/Makefile.in b/src/extra/Makefile.in index e84cf902ca9..35d5e951836 100644 --- a/src/extra/Makefile.in +++ b/src/extra/Makefile.in @@ -23,8 +23,10 @@ LIBZ =@BUILD_ZLIB_TRUE@ make.zlib LIBXDR =@BUILD_XDR_TRUE@ make.xdr LIBINTL =@BUILD_LIBINTL_TRUE@ make.intl LIBTRE = make.tre +LIBTZONE = @BUILD_TZONE_TRUE@make.tzone LIBXZ =@BUILD_XZ_TRUE@ make.xz -EXTRAS = $(RBLAS) $(LIBBZ2) $(LIBPCRE) $(LIBZ) $(LIBXDR) $(LIBINTL) $(LIBTRE) $(LIBXZ) +EXTRAS = $(RBLAS) $(LIBBZ2) $(LIBPCRE) $(LIBZ) $(LIBXDR) $(LIBINTL) \ + $(LIBTRE) $(LIBTZONE) $(LIBXZ) all: Makefile R @@ -58,6 +60,9 @@ make.xz: Makefile make.intl: Makefile @(cd intl; $(MAKE)) +make.tzone: Makefile + @(cd tzone; $(MAKE)) + mostlyclean: clean clean: diff --git a/src/extra/tzone/localtime.c b/src/extra/tzone/localtime.c index 5228c799deb..6a341d78455 100644 --- a/src/extra/tzone/localtime.c +++ b/src/extra/tzone/localtime.c @@ -53,6 +53,7 @@ use of 64-bit time_t irrespective of platform. #define localtime R_localtime #define mktime R_mktime #define tzset R_tzset +#define tzsetwall R_tzsetwall #include typedef int64_t R_time_t; #define time_t R_time_t diff --git a/src/gnuwin32/fixed/h/config.h b/src/gnuwin32/fixed/h/config.h index 2f1973dc71c..47aa83607c8 100644 --- a/src/gnuwin32/fixed/h/config.h +++ b/src/gnuwin32/fixed/h/config.h @@ -835,6 +835,9 @@ /* Define if you have the 'wint_t' type. (For intl) */ #define HAVE_WINT_T 1 +/* Define if your mktime works correctly outside 1902-2037. */ +#define HAVE_WORKING_64BIT_MKTIME 1 + /* Define to 1 if you have cairo. */ /* #undef HAVE_WORKING_CAIRO */ @@ -1031,6 +1034,9 @@ /* Define to use Apple's ICU. */ /* #undef USE_ICU_APPLE */ +/* Define to use internal time-zone code */ +#define USE_INTERNAL_MKTME 1 + /* Define if the POSIX multithreading library can be used. (For intl) */ /* #undef USE_POSIX_THREADS */ diff --git a/src/main/Makefile.in b/src/main/Makefile.in index b5f2ab80ebe..09ccf1ca9f3 100644 --- a/src/main/Makefile.in +++ b/src/main/Makefile.in @@ -88,11 +88,13 @@ R_TRE = ../extra/tre/libtre.a R_XDR = @BUILD_XDR_TRUE@ ../extra/xdr/libxdr.a R_XZ = @BUILD_XZ_TRUE@ ../extra/xz/liblzma.a R_LIBINTL = @BUILD_LIBINTL_TRUE@ ../extra/intl/libintl.a +R_TZONE = @BUILD_TZONE_TRUE@ ../extra/tzone/localtime.o MAIN_LIBS = ../unix/libunix.a ../appl/libappl.a ../nmath/libnmath.a MAIN_OBJS = `ls ../unix/*.o ../appl/*.o ../nmath/*.o` EXTRA_STATIC_LIBS = \ - $(R_ZLIBS) $(R_BZLIBS) $(R_PCRE) $(R_TRE) $(R_XDR) $(R_XZ) $(R_LIBINTL) + $(R_ZLIBS) $(R_BZLIBS) $(R_PCRE) $(R_TRE) $(R_XDR) $(R_XZ) $(R_LIBINTL) \ + $(R_TZONE) STATIC_LIBS = $(MAIN_LIBS) $(EXTRA_STATIC_LIBS) EXTRA_LIBS = $(BLAS_LIBS) $(FLIBS) $(R_XTRA_LIBS) @LIBINTL@ $(READLINE_LIBS) $(LIBS) diff --git a/src/main/datetime.c b/src/main/datetime.c index f73be4ec984..f6a1a7e26de 100644 --- a/src/main/datetime.c +++ b/src/main/datetime.c @@ -97,12 +97,12 @@ #include #ifdef Win32 -# define USE_INTERNAL_MKTME 1 +# define USE_INTERNAL_MKTIME 1 #endif # include -#ifdef USE_INTERNAL_MKTME +#ifdef USE_INTERNAL_MKTIME # include typedef int64_t R_time_t; diff --git a/src/main/util.c b/src/main/util.c index dbb66b92844..48dae37f14e 100644 --- a/src/main/util.c +++ b/src/main/util.c @@ -942,7 +942,23 @@ SEXP attribute_hidden do_normalizepath(SEXP call, SEXP op, SEXP args, SEXP rho) UNPROTECT(1); return ans; } + +#ifdef USE_INTERNAL_MKTIME +const char *getTZinfo(void) +{ + const char *p = getenv("TZ"); + if(p) return p; +#ifdef HAVE_REALPATH + static char abspath[PATH_MAX+1] = ""; + if(!abspath[0] && realpath("/etc/localtime", abspath)) + return abspath + 20; // strip /usr/share/zoneinfo/ #endif + warning("system timezone name is unknown: set environment variable TZ"); + return "unknown"; +} +#endif + +#endif // not Win32 /* encodeString(x, w, quote, justify) */