From 7afdfe63354967ea5123cb2b1746c3ae552d0977 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/posix/PosixTimezone.cpp | 12 ++++++++++++
 1 file changed, 12 insertions(+)

--- a/xbmc/platform/posix/PosixTimezone.cpp
+++ b/xbmc/platform/posix/PosixTimezone.cpp
@@ -24,6 +24,8 @@
 
 #include "PlatformDefs.h"
 
+#include <fstream>
+
 CPosixTimezone::CPosixTimezone()
 {
    char* line = NULL;
@@ -141,6 +143,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<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();
