summaryrefslogtreecommitdiffstats
path: root/xbmc/platform/posix/PosixTimezone.h
blob: 076e87fa51e98221736d6aa3de820768a96b8150 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
 *  Copyright (C) 2005-2018 Team Kodi
 *  This file is part of Kodi - https://kodi.tv
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 *  See LICENSES/README.md for more information.
 */

#pragma once

#include "settings/lib/ISettingCallback.h"
#include "settings/lib/ISettingsHandler.h"

#include <map>
#include <string>
#include <vector>

class CSetting;
struct StringSettingOption;

class CPosixTimezone : public ISettingCallback, public ISettingsHandler
{
public:
   CPosixTimezone();

  void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override;

   void OnSettingsLoaded() override;

   std::string GetOSConfiguredTimezone();

   std::vector<std::string> GetCounties();
   std::vector<std::string> GetTimezonesByCountry(const std::string& country);
   std::string GetCountryByTimezone(const std::string& timezone);

  void SetTimezone(const std::string& timezone);
   int m_IsDST = 0;

  static void SettingOptionsTimezoneCountriesFiller(const std::shared_ptr<const CSetting>& setting,
                                                    std::vector<StringSettingOption>& list,
                                                    std::string& current,
                                                    void* data);
  static void SettingOptionsTimezonesFiller(const std::shared_ptr<const CSetting>& setting,
                                            std::vector<StringSettingOption>& list,
                                            std::string& current,
                                            void* data);

private:
   std::vector<std::string> m_counties;
   std::map<std::string, std::string> m_countryByCode;
   std::map<std::string, std::string> m_countryByName;

   std::map<std::string, std::vector<std::string> > m_timezonesByCountryCode;
   std::map<std::string, std::string> m_countriesByTimezoneName;
};

extern CPosixTimezone g_timezone;