19596a2c1Sopenharmony_ci/* 29596a2c1Sopenharmony_ci * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 39596a2c1Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 49596a2c1Sopenharmony_ci * you may not use this file except in compliance with the License. 59596a2c1Sopenharmony_ci * You may obtain a copy of the License at 69596a2c1Sopenharmony_ci * 79596a2c1Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 89596a2c1Sopenharmony_ci * 99596a2c1Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 109596a2c1Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 119596a2c1Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 129596a2c1Sopenharmony_ci * See the License for the specific language governing permissions and 139596a2c1Sopenharmony_ci * limitations under the License. 149596a2c1Sopenharmony_ci */ 159596a2c1Sopenharmony_ci#ifndef I18N_TIMEZONE_ADDON_H 169596a2c1Sopenharmony_ci#define I18N_TIMEZONE_ADDON_H 179596a2c1Sopenharmony_ci 189596a2c1Sopenharmony_ci#include "i18n_timezone.h" 199596a2c1Sopenharmony_ci#include "napi/native_api.h" 209596a2c1Sopenharmony_ci#include "napi/native_node_api.h" 219596a2c1Sopenharmony_ci 229596a2c1Sopenharmony_cinamespace OHOS { 239596a2c1Sopenharmony_cinamespace Global { 249596a2c1Sopenharmony_cinamespace I18n { 259596a2c1Sopenharmony_ciclass I18nTimeZoneAddon { 269596a2c1Sopenharmony_cipublic: 279596a2c1Sopenharmony_ci I18nTimeZoneAddon(); 289596a2c1Sopenharmony_ci ~I18nTimeZoneAddon(); 299596a2c1Sopenharmony_ci static void Destructor(napi_env env, void *nativeObject, void *hint); 309596a2c1Sopenharmony_ci static napi_value GetI18nTimeZone(napi_env env, napi_callback_info info); 319596a2c1Sopenharmony_ci static napi_value InitI18nTimeZone(napi_env env, napi_value exports); 329596a2c1Sopenharmony_ci 339596a2c1Sopenharmony_ciprivate: 349596a2c1Sopenharmony_ci static napi_value InitTimeZone(napi_env env, napi_value exports); 359596a2c1Sopenharmony_ci static napi_value I18nTimeZoneConstructor(napi_env env, napi_callback_info info); 369596a2c1Sopenharmony_ci static napi_value GetAvailableTimezoneIDs(napi_env env, napi_callback_info info); 379596a2c1Sopenharmony_ci static napi_value GetAvailableZoneCityIDs(napi_env env, napi_callback_info info); 389596a2c1Sopenharmony_ci static napi_value GetCityDisplayName(napi_env env, napi_callback_info info); 399596a2c1Sopenharmony_ci static napi_value GetTimezoneFromCity(napi_env env, napi_callback_info info); 409596a2c1Sopenharmony_ci static napi_value GetTimezonesByLocation(napi_env env, napi_callback_info info); 419596a2c1Sopenharmony_ci static bool CheckLongitudeTypeAndScope(napi_env env, napi_value argv, double &x); 429596a2c1Sopenharmony_ci static bool CheckLatitudeTypeAndScope(napi_env env, napi_value argv, double &y); 439596a2c1Sopenharmony_ci 449596a2c1Sopenharmony_ci static napi_value GetID(napi_env env, napi_callback_info info); 459596a2c1Sopenharmony_ci static napi_value GetTimeZoneDisplayName(napi_env env, napi_callback_info info); 469596a2c1Sopenharmony_ci static napi_value GetRawOffset(napi_env env, napi_callback_info info); 479596a2c1Sopenharmony_ci static napi_value GetOffset(napi_env env, napi_callback_info info); 489596a2c1Sopenharmony_ci 499596a2c1Sopenharmony_ci static napi_value StaticGetTimeZone(napi_env, napi_value *argv, bool isZoneID); 509596a2c1Sopenharmony_ci static int32_t GetParameter(napi_env env, napi_value *argv, std::string &localeStr, bool &isDST); 519596a2c1Sopenharmony_ci static bool GetStringFromJS(napi_env env, napi_value argv, std::string &jsString); 529596a2c1Sopenharmony_ci static int32_t GetFirstParameter(napi_env env, napi_value value, std::string &localeStr, bool &isDST); 539596a2c1Sopenharmony_ci 549596a2c1Sopenharmony_ci std::unique_ptr<I18nTimeZone> timezone_ = nullptr; 559596a2c1Sopenharmony_ci}; 569596a2c1Sopenharmony_ci} // namespace I18n 579596a2c1Sopenharmony_ci} // namespace Global 589596a2c1Sopenharmony_ci} // namespace OHOS 599596a2c1Sopenharmony_ci#endif