Skip to content

Commit

Permalink
Fix Issue 15391 - Add possibility to specify custom path to TZDatabas…
Browse files Browse the repository at this point in the history
…eDir
  • Loading branch information
ThomasMader committed Dec 27, 2017
1 parent 867ed5b commit 735b360
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
8 changes: 8 additions & 0 deletions posix.mak
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion std/datetime/timezone.d
Original file line number Diff line number Diff line change
Expand Up @@ -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/";
Expand Down

0 comments on commit 735b360

Please sign in to comment.