19596a2c1Sopenharmony_ci/* 29596a2c1Sopenharmony_ci * Copyright (c) 2023 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 OHOS_GLOBAL_I18N_HOLIDAY_MANAGER_H 169596a2c1Sopenharmony_ci#define OHOS_GLOBAL_I18N_HOLIDAY_MANAGER_H 179596a2c1Sopenharmony_ci 189596a2c1Sopenharmony_ci#include <vector> 199596a2c1Sopenharmony_ci#include "holiday_manager.h" 209596a2c1Sopenharmony_ci#include "napi/native_api.h" 219596a2c1Sopenharmony_ci#include "napi/native_node_api.h" 229596a2c1Sopenharmony_ci 239596a2c1Sopenharmony_cinamespace OHOS { 249596a2c1Sopenharmony_cinamespace Global { 259596a2c1Sopenharmony_cinamespace I18n { 269596a2c1Sopenharmony_ciclass HolidayManagerAddon { 279596a2c1Sopenharmony_cipublic: 289596a2c1Sopenharmony_ci HolidayManagerAddon(); 299596a2c1Sopenharmony_ci ~HolidayManagerAddon(); 309596a2c1Sopenharmony_ci static void Destructor(napi_env env, void *nativeObject, void *hint); 319596a2c1Sopenharmony_ci static napi_value InitHolidayManager(napi_env env, napi_value exports); 329596a2c1Sopenharmony_ci 339596a2c1Sopenharmony_ciprivate: 349596a2c1Sopenharmony_ci static napi_value HolidayManagerConstructor(napi_env env, napi_callback_info info); 359596a2c1Sopenharmony_ci bool InitHolidayManagerContext(napi_env env, napi_callback_info info, const char* path); 369596a2c1Sopenharmony_ci 379596a2c1Sopenharmony_ci // process js function call 389596a2c1Sopenharmony_ci static napi_value IsHoliday(napi_env env, napi_callback_info info); 399596a2c1Sopenharmony_ci static napi_value GetHolidayInfoItemArray(napi_env env, napi_callback_info info); 409596a2c1Sopenharmony_ci static int32_t ValidateParamNumber(napi_env &env, napi_value &argv); 419596a2c1Sopenharmony_ci static std::vector<int> ValidateParamDate(napi_env &env, napi_value &argv); 429596a2c1Sopenharmony_ci static napi_value CreateHolidayItem(napi_env env, const HolidayInfoItem &holidayItem); 439596a2c1Sopenharmony_ci static napi_value HolidayLocalNameItem(napi_env env, const std::vector<HolidayLocalName> localNames); 449596a2c1Sopenharmony_ci static napi_value GetHolidayInfoItemResult(napi_env env, std::vector<HolidayInfoItem> itemList); 459596a2c1Sopenharmony_ci static int GetDateValue(napi_env env, napi_value value, const std::string method); 469596a2c1Sopenharmony_ci 479596a2c1Sopenharmony_ci static const int32_t MONTH_INCREASE_ONE = 1; // 1 is real month greater than display 489596a2c1Sopenharmony_ci 499596a2c1Sopenharmony_ci napi_env env_; 509596a2c1Sopenharmony_ci std::unique_ptr<HolidayManager> holidayManager_ = nullptr; 519596a2c1Sopenharmony_ci}; 529596a2c1Sopenharmony_ci} // namespace I18n 539596a2c1Sopenharmony_ci} // namespace Global 549596a2c1Sopenharmony_ci} // namespace OHOS 559596a2c1Sopenharmony_ci#endif