| 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 |
int32_t relatedYearDifference() const override { |
| 40 |
return chineseRelatedYearDiff; |
| 41 |
} |
| 42 |
|
| 43 |
public: |
| 44 |
UClassID getDynamicClassID() const override; |
| 45 |
static UClassID U_EXPORT2 getStaticClassID(); |
| 46 |
|
| 47 |
protected: |
| 48 |
DECLARE_OVERRIDE_SYSTEM_DEFAULT_CENTURY |
| 49 |
|
| 50 |
struct SystemDefaultCenturyLocale { |
| 51 |
static inline const char* identifier = "@calendar=chinese"; |
| 52 |
}; |
| 53 |
static inline SystemDefaultCentury<ICU4XChineseCalendar, |
| 54 |
SystemDefaultCenturyLocale> |
| 55 |
defaultCentury_{}; |
| 56 |
}; |
| 57 |
|
| 58 |
} // namespace mozilla::intl::calendar |
| 59 |
|
| 60 |
#endif |