From 7afdfe63354967ea5123cb2b1746c3ae552d0977 Mon Sep 17 00:00:00 2001 From: Stefan Saraev Date: Mon, 18 Aug 2014 17:46:54 +0300 Subject: [PATCH] setup timezone on TZ country setting change, store the value in format TIMEZONE=Xx/Yyy to /storage/.cache/timezone to be used with tz-data.service --- xbmc/platform/posix/PosixTimezone.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) --- a/xbmc/platform/posix/PosixTimezone.cpp +++ b/xbmc/platform/posix/PosixTimezone.cpp @@ -26,6 +26,8 @@ #include +#include + CPosixTimezone::CPosixTimezone() { char* line = NULL; @@ -143,6 +145,16 @@ void CPosixTimezone::OnSettingChanged(co const std::string &settingId = setting->GetId(); if (settingId == CSettings::SETTING_LOCALE_TIMEZONE) { + std::ofstream out("/storage/.cache/timezone"); + if (out) + { + const std::string tz = std::string("TIMEZONE=") + (std::static_pointer_cast(setting)->GetValue().c_str()); + out << tz << std::endl; + out.flush(); + out.close(); + system("systemctl restart tz-data.service"); + } + SetTimezone(std::static_pointer_cast(setting)->GetValue()); CDateTime::ResetTimezoneBias();