1 /* 2 * Copyright (C) 2005-2018 Team Kodi 3 * This file is part of Kodi - https://kodi.tv 4 * 5 * SPDX-License-Identifier: GPL-2.0-or-later 6 * See LICENSES/README.md for more information. 7 */ 8 9 #pragma once 10 11 #include "settings/lib/ISettingCallback.h" 12 #include "settings/lib/ISettingsHandler.h" 13 14 #include <map> 15 #include <string> 16 #include <vector> 17 18 class CSetting; 19 struct StringSettingOption; 20 21 class CPosixTimezone : public ISettingCallback, public ISettingsHandler 22 { 23 public: 24 CPosixTimezone(); 25 26 void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; 27 28 void OnSettingsLoaded() override; 29 30 std::string GetOSConfiguredTimezone(); 31 32 std::vector<std::string> GetCounties(); 33 std::vector<std::string> GetTimezonesByCountry(const std::string& country); 34 std::string GetCountryByTimezone(const std::string& timezone); 35 36 void SetTimezone(const std::string& timezone); 37 int m_IsDST = 0; 38 39 static void SettingOptionsTimezoneCountriesFiller(const std::shared_ptr<const CSetting>& setting, 40 std::vector<StringSettingOption>& list, 41 std::string& current, 42 void* data); 43 static void SettingOptionsTimezonesFiller(const std::shared_ptr<const CSetting>& setting, 44 std::vector<StringSettingOption>& list, 45 std::string& current, 46 void* data); 47 48 private: 49 std::vector<std::string> m_counties; 50 std::map<std::string, std::string> m_countryByCode; 51 std::map<std::string, std::string> m_countryByName; 52 53 std::map<std::string, std::vector<std::string> > m_timezonesByCountryCode; 54 std::map<std::string, std::string> m_countriesByTimezoneName; 55 }; 56 57 extern CPosixTimezone g_timezone; 58 59