From 735b360c4215720adf3b64b76c274ce1094538f9 Mon Sep 17 00:00:00 2001 From: Thomas Mader Date: Mon, 25 Dec 2017 20:57:29 +0100 Subject: [PATCH] Fix Issue 15391 - Add possibility to specify custom path to TZDatabaseDir --- posix.mak | 8 ++++++++ std/datetime/timezone.d | 11 ++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/posix.mak b/posix.mak index 96032f81995..e0128c1e21b 100644 --- a/posix.mak +++ b/posix.mak @@ -22,6 +22,9 @@ # # make std/somemodule.test => only builds and unittests std.somemodule # +# make TZ_DATABASE_DIR=path to the TZDatabase directory => This is useful to +# overwrite the hardcoded path to the TZDatabase directory needed +# for std/datetime/timezone.d ################################################################################ # Configurable stuff, usually from the command line @@ -139,6 +142,11 @@ endif ifdef ENABLE_COVERAGE DFLAGS += -cov endif +ifneq (,$(TZ_DATABASE_DIR)) +$(file > /tmp/TZDatabaseDirFile, ${TZ_DATABASE_DIR}) +DFLAGS += -version=TZDatabaseDir -J/tmp/ +endif + UDFLAGS=-unittest -version=StdUnittest # Set DOTOBJ and DOTEXE diff --git a/std/datetime/timezone.d b/std/datetime/timezone.d index 1a6e3d37d35..1642219e5cb 100644 --- a/std/datetime/timezone.d +++ b/std/datetime/timezone.d @@ -1967,7 +1967,16 @@ public: } - version(Android) + version(TZDatabaseDir) + { + import std.string : strip; + /++ + The default directory where the TZ Database files are. It's empty + for Windows, since Windows doesn't have them. + +/ + enum defaultTZDatabaseDir = strip(import("TZDatabaseDirFile")); + } + else version(Android) { // Android concatenates all time zone data into a single file and stores it here. enum defaultTZDatabaseDir = "/system/usr/share/zoneinfo/";