Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/tz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,13 @@ discover_tz_dir()
{
struct stat sb;
using namespace std;

#if !TARGET_OS_IPHONE
auto tz_dir_env = getenv("TZDIR");
if (tz_dir_env != nullptr)
return tz_dir_env;
#endif

# ifndef __APPLE__
CONSTDATA auto tz_dir_default = "/usr/share/zoneinfo";
CONSTDATA auto tz_dir_buildroot = "/usr/share/zoneinfo/uclibc";
Expand Down Expand Up @@ -3731,6 +3738,14 @@ sniff_realpath(const char* timezone)
const time_zone*
tzdb::current_zone() const
{
// If used in a docker instance with no timezone info set in the regular place,
// provide an environment variable to set the current timezone
{
static auto tz_local_env = getenv("TZ");
if (tz_local_env != nullptr)
return locate_zone(tz_local_env);
}

// On some OS's a file called /etc/localtime may
// exist and it may be either a real file
// containing time zone details or a symlink to such a file.
Expand Down