ICU4XChineseCalendar.h (1730B)
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_ICU4XChineseCalendar_h_ 5 #define intl_components_calendar_ICU4XChineseCalendar_h_ 6 7 #include "mozilla/intl/calendar/ICU4XChineseBasedCalendar.h" 8 9 #include <stdint.h> 10 #include <string_view> 11 12 #include "unicode/uobject.h" 13 14 namespace mozilla::intl::calendar { 15 16 /** 17 * Chinese calendar implementation. 18 * 19 * Overrides the same methods as icu::ChineseCalendar to ensure compatible 20 * behavior even when using ICU4X as the underlying calendar implementation. 21 */ 22 class ICU4XChineseCalendar : public ICU4XChineseBasedCalendar { 23 public: 24 ICU4XChineseCalendar() = delete; 25 ICU4XChineseCalendar(const icu::Locale& locale, UErrorCode& success); 26 ICU4XChineseCalendar(const icu::TimeZone& timeZone, const icu::Locale& locale, 27 UErrorCode& success); 28 ICU4XChineseCalendar(const ICU4XChineseCalendar& other); 29 30 virtual ~ICU4XChineseCalendar(); 31 32 ICU4XChineseCalendar* clone() const override; 33 34 const char* getType() const override; 35 36 protected: 37 std::string_view eraName(int32_t extendedYear) const override; 38 39 public: 40 UClassID getDynamicClassID() const override; 41 static UClassID U_EXPORT2 getStaticClassID(); 42 43 protected: 44 DECLARE_OVERRIDE_SYSTEM_DEFAULT_CENTURY 45 46 struct SystemDefaultCenturyLocale { 47 static inline const char* identifier = "@calendar=chinese"; 48 }; 49 static inline SystemDefaultCentury<ICU4XChineseCalendar, 50 SystemDefaultCenturyLocale> 51 defaultCentury_{}; 52 }; 53 54 } // namespace mozilla::intl::calendar 55 56 #endif