ICU4XChineseBasedCalendar.h (1948B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 #ifndef intl_components_calendar_ICU4XChineseBasedCalendar_h_ 5 #define intl_components_calendar_ICU4XChineseBasedCalendar_h_ 6 7 #include "mozilla/intl/calendar/ICU4XCalendar.h" 8 9 #include <stdint.h> 10 11 namespace mozilla::intl::calendar { 12 13 /** 14 * Abstract base class for Chinese-based calendars. 15 * 16 * Overrides the same methods as icu::ChineseCalendar to ensure compatible 17 * behavior even when using ICU4X as the underlying calendar implementation. 18 */ 19 class ICU4XChineseBasedCalendar : public ICU4XCalendar { 20 protected: 21 ICU4XChineseBasedCalendar(icu4x::capi::CalendarKind kind, 22 const icu::Locale& locale, UErrorCode& success); 23 ICU4XChineseBasedCalendar(icu4x::capi::CalendarKind kind, 24 const icu::TimeZone& timeZone, 25 const icu::Locale& locale, UErrorCode& success); 26 ICU4XChineseBasedCalendar(const ICU4XChineseBasedCalendar& other); 27 28 public: 29 ICU4XChineseBasedCalendar() = delete; 30 virtual ~ICU4XChineseBasedCalendar(); 31 32 protected: 33 bool hasLeapMonths() const override; 34 bool hasMonthCode(MonthCode monthCode) const override; 35 bool requiresFallbackForExtendedYear(int32_t year) const override; 36 bool requiresFallbackForGregorianYear(int32_t year) const override; 37 38 public: 39 bool inTemporalLeapYear(UErrorCode& status) const override; 40 41 protected: 42 void handleComputeFields(int32_t julianDay, UErrorCode& status) override; 43 int32_t handleGetLimit(UCalendarDateFields field, 44 ELimitType limitType) const override; 45 const icu::UFieldResolutionTable* getFieldResolutionTable() const override; 46 47 private: 48 static const icu::UFieldResolutionTable CHINESE_DATE_PRECEDENCE[]; 49 }; 50 51 } // namespace mozilla::intl::calendar 52 53 #endif