19596a2c1Sopenharmony_ci/* 29596a2c1Sopenharmony_ci * Copyright (c) 2024 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#include "i18n_hilog.h" 169596a2c1Sopenharmony_ci#include "unicode/gregocal.h" 179596a2c1Sopenharmony_ci#include "lunar_calendar.h" 189596a2c1Sopenharmony_ci 199596a2c1Sopenharmony_cinamespace OHOS { 209596a2c1Sopenharmony_cinamespace Global { 219596a2c1Sopenharmony_cinamespace I18n { 229596a2c1Sopenharmony_cistd::unordered_map<int32_t, int32_t> LunarCalendar::daysOfMonth { 239596a2c1Sopenharmony_ci { 1, 31 }, 249596a2c1Sopenharmony_ci { 2, 28 }, 259596a2c1Sopenharmony_ci { 3, 31 }, 269596a2c1Sopenharmony_ci { 4, 30 }, 279596a2c1Sopenharmony_ci { 5, 31 }, 289596a2c1Sopenharmony_ci { 6, 30 }, 299596a2c1Sopenharmony_ci { 7, 31 }, 309596a2c1Sopenharmony_ci { 8, 31 }, 319596a2c1Sopenharmony_ci { 9, 30 }, 329596a2c1Sopenharmony_ci { 10, 31 }, 339596a2c1Sopenharmony_ci { 11, 30 }, 349596a2c1Sopenharmony_ci { 12, 31 } 359596a2c1Sopenharmony_ci}; 369596a2c1Sopenharmony_ci 379596a2c1Sopenharmony_cistd::unordered_map<int32_t, int32_t> LunarCalendar::accDaysOfMonth { 389596a2c1Sopenharmony_ci { 1, 0 }, 399596a2c1Sopenharmony_ci { 2, 31 }, 409596a2c1Sopenharmony_ci { 3, 59 }, 419596a2c1Sopenharmony_ci { 4, 90 }, 429596a2c1Sopenharmony_ci { 5, 120 }, 439596a2c1Sopenharmony_ci { 6, 151 }, 449596a2c1Sopenharmony_ci { 7, 181 }, 459596a2c1Sopenharmony_ci { 8, 212 }, 469596a2c1Sopenharmony_ci { 9, 243 }, 479596a2c1Sopenharmony_ci { 10, 273 }, 489596a2c1Sopenharmony_ci { 11, 304 }, 499596a2c1Sopenharmony_ci { 12, 334 } 509596a2c1Sopenharmony_ci}; 519596a2c1Sopenharmony_ci 529596a2c1Sopenharmony_cistd::vector<uint32_t> LunarCalendar::lunarDateInfo { 539596a2c1Sopenharmony_ci 0x4bd8, 0x4ae0, 0xa570, 0x54d5, 0xd260, 0xd950, 0x5554, 0x56af, 0x9ad0, 0x55d2, 549596a2c1Sopenharmony_ci 0x4ae0, 0xa5b6, 0xa4d0, 0xd250, 0xd295, 0xb54f, 0xd6a0, 0xada2, 0x95b0, 0x4977, 559596a2c1Sopenharmony_ci 0x497f, 0xa4b0, 0xb4b5, 0x6a50, 0x6d40, 0xab54, 0x2b6f, 0x9570, 0x52f2, 0x4970, 569596a2c1Sopenharmony_ci 0x6566, 0xd4a0, 0xea50, 0x6a95, 0x5adf, 0x2b60, 0x86e3, 0x92ef, 0xc8d7, 0xc95f, 579596a2c1Sopenharmony_ci 0xd4a0, 0xd8a6, 0xb55f, 0x56a0, 0xa5b4, 0x25df, 0x92d0, 0xd2b2, 0xa950, 0xb557, 589596a2c1Sopenharmony_ci 0x6ca0, 0xb550, 0x5355, 0x4daf, 0xa5b0, 0x4573, 0x52bf, 0xa9a8, 0xe950, 0x6aa0, 599596a2c1Sopenharmony_ci 0xaea6, 0xab50, 0x4b60, 0xaae4, 0xa570, 0x5260, 0xf263, 0xd950, 0x5b57, 0x56a0, 609596a2c1Sopenharmony_ci 0x96d0, 0x4dd5, 0x4ad0, 0xa4d0, 0xd4d4, 0xd250, 0xd558, 0xb540, 0xb6a0, 0x95a6, 619596a2c1Sopenharmony_ci 0x95bf, 0x49b0, 0xa974, 0xa4b0, 0xb27a, 0x6a50, 0x6d40, 0xaf46, 0xab60, 0x9570, 629596a2c1Sopenharmony_ci 0x4af5, 0x4970, 0x64b0, 0x74a3, 0xea50, 0x6b58, 0x5ac0, 0xab60, 0x96d5, 0x92e0, 639596a2c1Sopenharmony_ci 0xc960, 0xd954, 0xd4a0, 0xda50, 0x7552, 0x56a0, 0xabb7, 0x25d0, 0x92d0, 0xcab5, 649596a2c1Sopenharmony_ci 0xa950, 0xb4a0, 0xbaa4, 0xad50, 0x55d9, 0x4ba0, 0xa5b0, 0x5176, 0x52bf, 0xa930, 659596a2c1Sopenharmony_ci 0x7954, 0x6aa0, 0xad50, 0x5b52, 0x4b60, 0xa6e6, 0xa4e0, 0xd260, 0xea65, 0xd530, 669596a2c1Sopenharmony_ci 0x5aa0, 0x76a3, 0x96d0, 0x4afb, 0x4ad0, 0xa4d0, 0xd0b6, 0xd25f, 0xd520, 0xdd45, 679596a2c1Sopenharmony_ci 0xb5a0, 0x56d0, 0x55b2, 0x49b0, 0xa577, 0xa4b0, 0xaa50, 0xb255, 0x6d2f, 0xada0, 689596a2c1Sopenharmony_ci 0x4b63, 0x937f, 0x49f8, 0x4970, 0x64b0, 0x68a6, 0xea5f, 0x6b20, 0xa6c4, 0xaaef, 699596a2c1Sopenharmony_ci 0x92e0, 0xd2e3, 0xc960, 0xd557, 0xd4a0, 0xda50, 0x5d55, 0x56a0, 0xa6d0, 0x55d4, 709596a2c1Sopenharmony_ci 0x52d0, 0xa9b8, 0xa950, 0xb4a0, 0xb6a6, 0xad50, 0x55a0, 0xaba4, 0xa5b0, 0x52b0, 719596a2c1Sopenharmony_ci 0xb273, 0x6930, 0x7337, 0x6aa0, 0xad50, 0x4b55, 0x4b6f, 0xa570, 0x54e4, 0xd260, 729596a2c1Sopenharmony_ci 0xe968, 0xd520, 0xdaa0, 0x6aa6, 0x56df, 0x4ae0, 0xa9d4, 0xa4d0, 0xd150, 0xf252, 739596a2c1Sopenharmony_ci 0xd520, 749596a2c1Sopenharmony_ci}; 759596a2c1Sopenharmony_ci 769596a2c1Sopenharmony_ciLunarCalendar::LunarCalendar() 779596a2c1Sopenharmony_ci{ 789596a2c1Sopenharmony_ci UErrorCode status = U_ZERO_ERROR; 799596a2c1Sopenharmony_ci calendar_ = new icu::GregorianCalendar(status); 809596a2c1Sopenharmony_ci if (U_FAILURE(status)) { 819596a2c1Sopenharmony_ci HILOG_ERROR_I18N("LunarCalendar: create GregorianCalendar failed"); 829596a2c1Sopenharmony_ci if (calendar_ != nullptr) { 839596a2c1Sopenharmony_ci delete calendar_; 849596a2c1Sopenharmony_ci } 859596a2c1Sopenharmony_ci calendar_ = nullptr; 869596a2c1Sopenharmony_ci } 879596a2c1Sopenharmony_ci} 889596a2c1Sopenharmony_ci 899596a2c1Sopenharmony_ciLunarCalendar::~LunarCalendar() 909596a2c1Sopenharmony_ci{ 919596a2c1Sopenharmony_ci if (calendar_ != nullptr) { 929596a2c1Sopenharmony_ci delete calendar_; 939596a2c1Sopenharmony_ci } 949596a2c1Sopenharmony_ci calendar_ = nullptr; 959596a2c1Sopenharmony_ci} 969596a2c1Sopenharmony_ci 979596a2c1Sopenharmony_cibool LunarCalendar::SetGregorianDate(int32_t year, int32_t month, int32_t day) 989596a2c1Sopenharmony_ci{ 999596a2c1Sopenharmony_ci ConvertDate(year, month, day); 1009596a2c1Sopenharmony_ci isGregorianLeapYear = false; 1019596a2c1Sopenharmony_ci isValidDate = VerifyDate(year, month, day); 1029596a2c1Sopenharmony_ci if (!isValidDate) { 1039596a2c1Sopenharmony_ci return false; 1049596a2c1Sopenharmony_ci } 1059596a2c1Sopenharmony_ci solorYear = year; 1069596a2c1Sopenharmony_ci solorMonth = month; 1079596a2c1Sopenharmony_ci solorDay = day; 1089596a2c1Sopenharmony_ci CalcDaysFromBaseDate(); 1099596a2c1Sopenharmony_ci SolorDateToLunarDate(); 1109596a2c1Sopenharmony_ci return true; 1119596a2c1Sopenharmony_ci} 1129596a2c1Sopenharmony_ci 1139596a2c1Sopenharmony_civoid LunarCalendar::ConvertDate(int32_t& year, int32_t& month, int32_t& day) 1149596a2c1Sopenharmony_ci{ 1159596a2c1Sopenharmony_ci if (calendar_ == nullptr) { 1169596a2c1Sopenharmony_ci return; 1179596a2c1Sopenharmony_ci } 1189596a2c1Sopenharmony_ci calendar_->set(year, month - 1, day); 1199596a2c1Sopenharmony_ci UErrorCode status = U_ZERO_ERROR; 1209596a2c1Sopenharmony_ci int32_t tempYear = calendar_->get(UCAL_YEAR, status); 1219596a2c1Sopenharmony_ci if (U_FAILURE(status)) { 1229596a2c1Sopenharmony_ci HILOG_ERROR_I18N("ConvertDate: get year failed"); 1239596a2c1Sopenharmony_ci return; 1249596a2c1Sopenharmony_ci } 1259596a2c1Sopenharmony_ci int32_t tempMonth = calendar_->get(UCAL_MONTH, status) + 1; 1269596a2c1Sopenharmony_ci if (U_FAILURE(status)) { 1279596a2c1Sopenharmony_ci HILOG_ERROR_I18N("ConvertDate: get month failed"); 1289596a2c1Sopenharmony_ci return; 1299596a2c1Sopenharmony_ci } 1309596a2c1Sopenharmony_ci int32_t tempDay = calendar_->get(UCAL_DATE, status); 1319596a2c1Sopenharmony_ci if (U_FAILURE(status)) { 1329596a2c1Sopenharmony_ci HILOG_ERROR_I18N("ConvertDate: get day failed"); 1339596a2c1Sopenharmony_ci return; 1349596a2c1Sopenharmony_ci } 1359596a2c1Sopenharmony_ci year = tempYear; 1369596a2c1Sopenharmony_ci month = tempMonth; 1379596a2c1Sopenharmony_ci day = tempDay; 1389596a2c1Sopenharmony_ci} 1399596a2c1Sopenharmony_ci 1409596a2c1Sopenharmony_civoid LunarCalendar::CalcDaysFromBaseDate() 1419596a2c1Sopenharmony_ci{ 1429596a2c1Sopenharmony_ci daysCounts = DAYS_OF_YEAR * (solorYear - START_YEAR); 1439596a2c1Sopenharmony_ci daysCounts += accDaysOfMonth[solorMonth]; 1449596a2c1Sopenharmony_ci if (isGregorianLeapYear && solorMonth > MONTH_FEB) { 1459596a2c1Sopenharmony_ci daysCounts++; 1469596a2c1Sopenharmony_ci } 1479596a2c1Sopenharmony_ci daysCounts--; 1489596a2c1Sopenharmony_ci daysCounts += solorDay; 1499596a2c1Sopenharmony_ci daysCounts += (solorYear - START_YEAR) / FREQ_LEAP_YEAR; 1509596a2c1Sopenharmony_ci if (isGregorianLeapYear) { 1519596a2c1Sopenharmony_ci daysCounts--; 1529596a2c1Sopenharmony_ci } 1539596a2c1Sopenharmony_ci if (solorYear >= VALID_END_YEAR) { 1549596a2c1Sopenharmony_ci daysCounts--; 1559596a2c1Sopenharmony_ci } 1569596a2c1Sopenharmony_ci} 1579596a2c1Sopenharmony_ci 1589596a2c1Sopenharmony_civoid LunarCalendar::SolorDateToLunarDate() 1599596a2c1Sopenharmony_ci{ 1609596a2c1Sopenharmony_ci int32_t daysInPerLunarYear = 0; 1619596a2c1Sopenharmony_ci int32_t daysInPerLunarMonth = 0; 1629596a2c1Sopenharmony_ci int32_t leapMonth = 0xf; 1639596a2c1Sopenharmony_ci int tempDaysCounts = daysCounts; 1649596a2c1Sopenharmony_ci tempDaysCounts -= DAYS_FROM_SOLAR_TO_LUNAR; 1659596a2c1Sopenharmony_ci int32_t i = 0; 1669596a2c1Sopenharmony_ci for (i = START_YEAR; (tempDaysCounts > 0) && (i < END_YEAR); i++) { 1679596a2c1Sopenharmony_ci daysInPerLunarYear = GetDaysPerLunarYear(i); 1689596a2c1Sopenharmony_ci tempDaysCounts -= daysInPerLunarYear; 1699596a2c1Sopenharmony_ci } 1709596a2c1Sopenharmony_ci if (tempDaysCounts < 0) { 1719596a2c1Sopenharmony_ci tempDaysCounts += daysInPerLunarYear; 1729596a2c1Sopenharmony_ci --i; 1739596a2c1Sopenharmony_ci } 1749596a2c1Sopenharmony_ci lunarYear = i; 1759596a2c1Sopenharmony_ci 1769596a2c1Sopenharmony_ci leapMonth = lunarDateInfo[lunarYear - START_YEAR] & 0xf; 1779596a2c1Sopenharmony_ci leapMonth = (leapMonth == 0xf) ? 0 : leapMonth; 1789596a2c1Sopenharmony_ci isLeapMonth = false; 1799596a2c1Sopenharmony_ci for (i = 1; i <= VALID_END_MONTH && tempDaysCounts > 0; i++) { 1809596a2c1Sopenharmony_ci if (leapMonth > 0 && (leapMonth + 1) == i && !isLeapMonth) { 1819596a2c1Sopenharmony_ci --i; 1829596a2c1Sopenharmony_ci isLeapMonth = true; 1839596a2c1Sopenharmony_ci daysInPerLunarMonth = ((lunarDateInfo[lunarYear - START_YEAR + 1] & 0xf) == 0xf) ? DAYS_IN_BIG_MONTH : 1849596a2c1Sopenharmony_ci DAYS_IN_SMALL_MONTH; 1859596a2c1Sopenharmony_ci } else { 1869596a2c1Sopenharmony_ci daysInPerLunarMonth = ((lunarDateInfo[lunarYear - START_YEAR] & 1879596a2c1Sopenharmony_ci (0x8000 >> (i - 1))) == (0x8000 >> (i - 1))) ? DAYS_IN_BIG_MONTH : DAYS_IN_SMALL_MONTH; 1889596a2c1Sopenharmony_ci } 1899596a2c1Sopenharmony_ci if (isLeapMonth && (leapMonth + 1) == i) { 1909596a2c1Sopenharmony_ci isLeapMonth = false; 1919596a2c1Sopenharmony_ci } 1929596a2c1Sopenharmony_ci tempDaysCounts -= daysInPerLunarMonth; 1939596a2c1Sopenharmony_ci } 1949596a2c1Sopenharmony_ci AdjustLeapMonth(i, tempDaysCounts, leapMonth); 1959596a2c1Sopenharmony_ci if (tempDaysCounts < 0) { 1969596a2c1Sopenharmony_ci tempDaysCounts += daysInPerLunarMonth; 1979596a2c1Sopenharmony_ci --i; 1989596a2c1Sopenharmony_ci } 1999596a2c1Sopenharmony_ci lunarMonth = i; 2009596a2c1Sopenharmony_ci lunarDay = tempDaysCounts + 1; 2019596a2c1Sopenharmony_ci} 2029596a2c1Sopenharmony_ci 2039596a2c1Sopenharmony_civoid LunarCalendar::AdjustLeapMonth(int32_t& i, int32_t tempDaysCounts, int32_t leapMonth) 2049596a2c1Sopenharmony_ci{ 2059596a2c1Sopenharmony_ci if (tempDaysCounts == 0 && leapMonth > 0 && i == leapMonth + 1) { 2069596a2c1Sopenharmony_ci if (isLeapMonth) { 2079596a2c1Sopenharmony_ci isLeapMonth = false; 2089596a2c1Sopenharmony_ci } else { 2099596a2c1Sopenharmony_ci isLeapMonth = true; 2109596a2c1Sopenharmony_ci --i; 2119596a2c1Sopenharmony_ci } 2129596a2c1Sopenharmony_ci } 2139596a2c1Sopenharmony_ci} 2149596a2c1Sopenharmony_ci 2159596a2c1Sopenharmony_ciint32_t LunarCalendar::GetDaysPerLunarYear(int32_t lunarYear) 2169596a2c1Sopenharmony_ci{ 2179596a2c1Sopenharmony_ci int32_t daysPerLunarYear = 0; 2189596a2c1Sopenharmony_ci if ((lunarYear < START_YEAR) || (lunarYear > END_YEAR)) { 2199596a2c1Sopenharmony_ci return 0; 2209596a2c1Sopenharmony_ci } 2219596a2c1Sopenharmony_ci daysPerLunarYear += BASE_DAYS_PER_LUNAR_YEAR; 2229596a2c1Sopenharmony_ci for (uint32_t i = 0x8000; i > 0x8; i = i >> 1) { 2239596a2c1Sopenharmony_ci daysPerLunarYear += ((lunarDateInfo[lunarYear - START_YEAR] & i) == i) ? 1 : 0; 2249596a2c1Sopenharmony_ci } 2259596a2c1Sopenharmony_ci if (((lunarDateInfo[lunarYear - START_YEAR] & 0xf) != 0) && 2269596a2c1Sopenharmony_ci ((lunarDateInfo[lunarYear - START_YEAR] & 0xf) != 0xf)) { 2279596a2c1Sopenharmony_ci daysPerLunarYear += ((lunarDateInfo[lunarYear - START_YEAR + 1] & 0xf) == 0xf) ? DAYS_IN_BIG_MONTH : 2289596a2c1Sopenharmony_ci DAYS_IN_SMALL_MONTH; 2299596a2c1Sopenharmony_ci } 2309596a2c1Sopenharmony_ci return daysPerLunarYear; 2319596a2c1Sopenharmony_ci} 2329596a2c1Sopenharmony_ci 2339596a2c1Sopenharmony_cibool LunarCalendar::VerifyDate(int32_t year, int32_t month, int32_t day) 2349596a2c1Sopenharmony_ci{ 2359596a2c1Sopenharmony_ci if ((year < VALID_START_YEAR) || (year > VALID_END_YEAR)) { 2369596a2c1Sopenharmony_ci HILOG_ERROR_I18N("VerifyDate: %{public}d is an invalid year", year); 2379596a2c1Sopenharmony_ci return false; 2389596a2c1Sopenharmony_ci } 2399596a2c1Sopenharmony_ci 2409596a2c1Sopenharmony_ci if ((month < VALID_START_MONTH) || (month > VALID_END_MONTH)) { 2419596a2c1Sopenharmony_ci HILOG_ERROR_I18N("VerifyDate: %{public}d is an invalid month", month); 2429596a2c1Sopenharmony_ci return false; 2439596a2c1Sopenharmony_ci } 2449596a2c1Sopenharmony_ci 2459596a2c1Sopenharmony_ci int32_t validEndDay = daysOfMonth[month]; 2469596a2c1Sopenharmony_ci isGregorianLeapYear = IsGregorianLeapYear(year); 2479596a2c1Sopenharmony_ci if (month == MONTH_FEB) { 2489596a2c1Sopenharmony_ci validEndDay = isGregorianLeapYear ? validEndDay + 1 : validEndDay; 2499596a2c1Sopenharmony_ci } 2509596a2c1Sopenharmony_ci 2519596a2c1Sopenharmony_ci if ((month < VALID_START_DAY) || (month > validEndDay)) { 2529596a2c1Sopenharmony_ci HILOG_ERROR_I18N("VerifyDate: %{public}d is an invalid day", day); 2539596a2c1Sopenharmony_ci return false; 2549596a2c1Sopenharmony_ci } 2559596a2c1Sopenharmony_ci return true; 2569596a2c1Sopenharmony_ci} 2579596a2c1Sopenharmony_ci 2589596a2c1Sopenharmony_cibool LunarCalendar::IsGregorianLeapYear(int32_t year) 2599596a2c1Sopenharmony_ci{ 2609596a2c1Sopenharmony_ci if (year % YEAR_ERA == 0) { 2619596a2c1Sopenharmony_ci if (year % (YEAR_ERA * FREQ_LEAP_YEAR) == 0) { 2629596a2c1Sopenharmony_ci return true; 2639596a2c1Sopenharmony_ci } 2649596a2c1Sopenharmony_ci return false; 2659596a2c1Sopenharmony_ci } 2669596a2c1Sopenharmony_ci if (year % FREQ_LEAP_YEAR == 0) { 2679596a2c1Sopenharmony_ci return true; 2689596a2c1Sopenharmony_ci } 2699596a2c1Sopenharmony_ci return false; 2709596a2c1Sopenharmony_ci} 2719596a2c1Sopenharmony_ci 2729596a2c1Sopenharmony_ciint32_t LunarCalendar::GetLunarYear() 2739596a2c1Sopenharmony_ci{ 2749596a2c1Sopenharmony_ci if (!isValidDate) { 2759596a2c1Sopenharmony_ci HILOG_ERROR_I18N("GetLunarYear: invalid date"); 2769596a2c1Sopenharmony_ci return -1; 2779596a2c1Sopenharmony_ci } 2789596a2c1Sopenharmony_ci return lunarYear; 2799596a2c1Sopenharmony_ci} 2809596a2c1Sopenharmony_ci 2819596a2c1Sopenharmony_ciint32_t LunarCalendar::GetLunarMonth() 2829596a2c1Sopenharmony_ci{ 2839596a2c1Sopenharmony_ci if (!isValidDate) { 2849596a2c1Sopenharmony_ci HILOG_ERROR_I18N("GetLunarYear: invalid date"); 2859596a2c1Sopenharmony_ci return -1; 2869596a2c1Sopenharmony_ci } 2879596a2c1Sopenharmony_ci return lunarMonth; 2889596a2c1Sopenharmony_ci} 2899596a2c1Sopenharmony_ci 2909596a2c1Sopenharmony_ciint32_t LunarCalendar::GetLunarDay() 2919596a2c1Sopenharmony_ci{ 2929596a2c1Sopenharmony_ci if (!isValidDate) { 2939596a2c1Sopenharmony_ci HILOG_ERROR_I18N("GetLunarYear: invalid date"); 2949596a2c1Sopenharmony_ci return -1; 2959596a2c1Sopenharmony_ci } 2969596a2c1Sopenharmony_ci return lunarDay; 2979596a2c1Sopenharmony_ci} 2989596a2c1Sopenharmony_ci 2999596a2c1Sopenharmony_cibool LunarCalendar::IsLeapMonth() 3009596a2c1Sopenharmony_ci{ 3019596a2c1Sopenharmony_ci if (!isValidDate) { 3029596a2c1Sopenharmony_ci HILOG_ERROR_I18N("GetLunarYear: invalid date"); 3039596a2c1Sopenharmony_ci return false; 3049596a2c1Sopenharmony_ci } 3059596a2c1Sopenharmony_ci return isLeapMonth; 3069596a2c1Sopenharmony_ci} 3079596a2c1Sopenharmony_ci} // namespace I18n 3089596a2c1Sopenharmony_ci} // namespace Global 3099596a2c1Sopenharmony_ci} // namespace OHOS