From ac5906ee4bc7b59f48457b01a318139ab15f6c8d Mon Sep 17 00:00:00 2001
From: Stefan Saraev <stefan@saraev.ca>
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/linux/LinuxTimezone.cpp | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/xbmc/platform/linux/LinuxTimezone.cpp b/xbmc/platform/linux/LinuxTimezone.cpp
index fae9276..2c24542 100644
--- a/xbmc/platform/linux/LinuxTimezone.cpp
+++ b/xbmc/platform/linux/LinuxTimezone.cpp
@@ -36,6 +36,8 @@
 
 #include <algorithm>
 
+#include <fstream>
+
 CLinuxTimezone::CLinuxTimezone()
 {
    char* line = NULL;
@@ -153,6 +155,16 @@ void CLinuxTimezone::OnSettingChanged(std::shared_ptr<const CSetting> setting)
   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<const CSettingString>(setting)->GetValue().c_str());
+      out << tz << std::endl;
+      out.flush();
+      out.close();
+      system("systemctl restart tz-data.service");
+    }
+
     SetTimezone(std::static_pointer_cast<const CSettingString>(setting)->GetValue());
 
     CDateTime::ResetTimezoneBias();
-- 
2.14.1

