Lakka-LibreELEC/packages/mediacenter/kodi/patches/kodi-100.08-setup-timezone.patch
2023-03-10 17:59:27 +01:00

41 lines
1.2 KiB
Diff

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
@@ -25,6 +25,8 @@
#include <algorithm>
+#include <fstream>
+
CPosixTimezone::CPosixTimezone()
{
char* line = NULL;
@@ -142,6 +144,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();