1 // © 2018 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
7 #include "unicode/utypes.h"
9 #if !UCONFIG_NO_FORMATTING
11 #include "unicode/localpointer.h"
12 #include "unicode/uobject.h"
17 // Export an explicit template instantiation of LocalMemory used as a data member of EraRules.
18 // When building DLLs for Windows this is required even though no direct access leaks out of the i18n library.
19 // See digitlst.h, pluralaffix.h, datefmt.h, and others for similar examples.
20 #if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN
22 // Ignore warning 4661 as LocalPointerBase does not use operator== or operator!=
24 #pragma warning(disable: 4661)
26 template class U_I18N_API LocalPointerBase
<int32_t>;
27 template class U_I18N_API LocalMemory
<int32_t>;
33 class U_I18N_API EraRules
: public UMemory
{
37 static EraRules
* createInstance(const char *calType
, UBool includeTentativeEra
, UErrorCode
& status
);
40 * Gets number of effective eras
41 * @return number of effective eras
43 inline int32_t getNumberOfEras() const {
48 * Gets start date of an era
49 * @param eraIdx Era index
50 * @param fields Receives date fields. The result includes values of year, month,
51 * day of month in this order. When an era has no start date, the result
52 * will be January 1st in year whose value is minimum integer.
53 * @param status Receives status.
55 void getStartDate(int32_t eraIdx
, int32_t (&fields
)[3], UErrorCode
& status
) const;
58 * Gets start year of an era
59 * @param eraIdx Era index
60 * @param status Receives status.
61 * @return The first year of an era. When a era has no start date, minimum int32
64 int32_t getStartYear(int32_t eraIdx
, UErrorCode
& status
) const;
67 * Returns era index for the specified year/month/day.
69 * @param month Month (1-base)
70 * @param day Day of month
71 * @param status Receives status
72 * @return era index (or 0, when the specified date is before the first era)
74 int32_t getEraIndex(int32_t year
, int32_t month
, int32_t day
, UErrorCode
& status
) const;
77 * Gets the current era index. This is calculated only once for an instance of
78 * EraRules. The current era calculation is based on the default time zone at
79 * the time of instantiation.
81 * @return era index of current era (or 0, when current date is before the first era)
83 inline int32_t getCurrentEraIndex() const {
88 EraRules(LocalMemory
<int32_t>& eraStartDates
, int32_t numEra
);
90 void initCurrentEra();
92 LocalMemory
<int32_t> startDates
;
98 #endif /* #if !UCONFIG_NO_FORMATTING */
99 #endif /* ERARULES_H_ */