1 /* 2 * Copyright (C) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef SERVICES_INCLUDE_TIME_ZONE_INFO_H 16 #define SERVICES_INCLUDE_TIME_ZONE_INFO_H 17 18 #include <singleton.h> 19 #include <map> 20 #include <mutex> 21 #include <sys/time.h> 22 #include <vector> 23 #include <fstream> 24 25 #include "refbase.h" 26 #include "time.h" 27 #include "time_common.h" 28 #include "parameter.h" 29 30 namespace OHOS { 31 namespace MiscServices { 32 struct zoneInfoEntry { 33 std::string ID; 34 std::string alias; 35 int utcOffsetHours; 36 }; 37 38 class TimeZoneInfo : public std::enable_shared_from_this<TimeZoneInfo> { 39 DECLARE_DELAYED_SINGLETON(TimeZoneInfo) 40 public: 41 bool GetTimezone(std::string &timezoneId); 42 bool SetTimezone(std::string timezoneId); 43 bool SetTimezoneToKernel(std::string timezoneId); 44 void Init(); 45 private: 46 std::string curTimezoneId_; 47 std::map<std::string, struct zoneInfoEntry> timezoneInfoMap_; 48 }; 49 } // MiscServices 50 } // OHOS 51 52 #endif // SERVICES_INCLUDE_TIME_ZONE_INFO_H