From 5f01382e248d77e1c207620e400096ce33837159 Mon Sep 17 00:00:00 2001 From: atkawa7 Date: Fri, 8 Sep 2017 16:14:14 -0700 Subject: [PATCH] Enable current_zone() on FreeBSD --- tz.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tz.cpp b/tz.cpp index c68edb2..e625bc4 100644 --- a/tz.cpp +++ b/tz.cpp @@ -3612,6 +3612,20 @@ TZ_DB::current_zone() const // Fall through to try other means. } { + // On some versions of some bsd distro's (e.g. FreeBSD), + // the current timezone might be in the first line of + // the /var/db/zoneinfo file. + std::ifstream timezone_file("/var/db/zoneinfo"); + if (timezone_file.is_open()) + { + std::string result; + std::getline(timezone_file, result); + if (!result.empty()) + return locate_zone(result); + } + // Fall through to try other means. + } + { // On some versions of some linux distro's (e.g. Red Hat), // the current timezone might be in the first line of // the /etc/sysconfig/clock file as: