1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 *******************************************************************************
5 * Copyright (C) 2003 - 2013, International Business Machines Corporation and *
6 * others. All Rights Reserved. *
7 *******************************************************************************
13 #include "unicode/utypes.h"
15 #if !UCONFIG_NO_FORMATTING
17 #include "unicode/calendar.h"
23 * Implement the Ethiopic calendar system.
26 class EthiopicCalendar
: public CECalendar
{
30 * Calendar type - use Amete Alem era for all the time or not
39 * Useful constants for EthiopicCalendar.
44 * Constant for መስከረም, the 1st month of the Ethiopic year.
49 * Constant for ጥቅምት, the 2nd month of the Ethiopic year.
54 * Constant for ኅዳር, the 3rd month of the Ethiopic year.
59 * Constant for ታኅሣሥ, the 4th month of the Ethiopic year.
64 * Constant for ጥር, the 5th month of the Ethiopic year.
69 * Constant for የካቲት, the 6th month of the Ethiopic year.
74 * Constant for መጋቢት, the 7th month of the Ethiopic year.
79 * Constant for ሚያዝያ, the 8th month of the Ethiopic year.
84 * Constant for ግንቦት, the 9th month of the Ethiopic year.
89 * Constant for ሰኔ, the 10th month of the Ethiopic year.
94 * Constant for ሐምሌ, the 11th month of the Ethiopic year.
99 * Constant for ነሐሴ, the 12th month of the Ethiopic year.
104 * Constant for ጳጉሜን, the 13th month of the Ethiopic year.
110 AMETE_ALEM
, // Before the epoch
111 AMETE_MIHRET
// After the epoch
115 * Constructs a EthiopicCalendar based on the current time in the default time zone
116 * with the given locale.
118 * @param aLocale The given locale.
119 * @param success Indicates the status of EthiopicCalendar object construction.
120 * Returns U_ZERO_ERROR if constructed successfully.
121 * @param type Whether this Ethiopic calendar use Amete Mihrret (default) or
122 * only use Amete Alem for all the time.
125 EthiopicCalendar(const Locale
& aLocale
, UErrorCode
& success
, EEraType type
= AMETE_MIHRET_ERA
);
131 EthiopicCalendar(const EthiopicCalendar
& other
);
137 virtual ~EthiopicCalendar();
140 * Create and return a polymorphic copy of this calendar.
141 * @return return a polymorphic copy of this calendar.
144 virtual Calendar
* clone() const;
147 * return the calendar type, "ethiopic"
148 * @return calendar type
151 virtual const char * getType() const;
154 * Set Alem or Mihret era.
155 * @param onOff Set Amete Alem era if true, otherwise set Amete Mihret era.
158 void setAmeteAlemEra (UBool onOff
);
161 * Return true if this calendar is set to the Amete Alem era.
162 * @return true if set to the Amete Alem era.
165 UBool
isAmeteAlemEra() const;
168 //-------------------------------------------------------------------------
169 // Calendar framework
170 //-------------------------------------------------------------------------
173 * Return the extended year defined by the current fields.
176 virtual int32_t handleGetExtendedYear();
179 * Compute fields from the JD
182 virtual void handleComputeFields(int32_t julianDay
, UErrorCode
&status
);
185 * Calculate the limit for a specified type of limit and field
188 virtual int32_t handleGetLimit(UCalendarDateFields field
, ELimitType limitType
) const;
191 * Returns the date of the start of the default century
192 * @return start of century - in milliseconds since epoch, 1970
195 virtual UDate
defaultCenturyStart() const;
198 * Returns the year in which the default century begins
201 virtual int32_t defaultCenturyStartYear() const;
204 * Return the date offset from Julian
207 virtual int32_t getJDEpochOffset() const;
211 * When eraType is AMETE_ALEM_ERA, then this calendar use only AMETE_ALEM
212 * for the era. Otherwise (default), this calendar uses both AMETE_ALEM
215 * EXTENDED_YEAR AMETE_ALEM_ERA AMETE_MIHRET_ERA
216 * 0 Amete Alem 5500 Amete Alem 5500
217 * 1 Amete Mihret 1 Amete Alem 5501
223 * Override Calendar Returns a unique class ID POLYMORPHICALLY. Pure virtual
224 * override. This method is to implement a simple version of RTTI, since not all C++
225 * compilers support genuine RTTI. Polymorphic operator==() and clone() methods call
228 * @return The class ID for this object. All objects of a given class have the
229 * same class ID. Objects of other classes have different class IDs.
232 virtual UClassID
getDynamicClassID(void) const;
235 * Return the class ID for this class. This is useful only for comparing to a return
236 * value from getDynamicClassID(). For example:
238 * Base* polymorphic_pointer = createPolymorphicObject();
239 * if (polymorphic_pointer->getDynamicClassID() ==
240 * Derived::getStaticClassID()) ...
242 * @return The class ID for all objects of this class.
245 U_I18N_API
static UClassID U_EXPORT2
getStaticClassID(void);
248 // We do not want to introduce this API in ICU4C.
249 // It was accidentally introduced in ICU4J as a public API.
252 //-------------------------------------------------------------------------
253 // Calendar system Conversion methods...
254 //-------------------------------------------------------------------------
257 * Convert an Ethiopic year, month, and day to a Julian day.
259 * @param year the extended year
260 * @param month the month
265 int32_t ethiopicToJD(int32_t year
, int32_t month
, int32_t day
);
270 #endif /* #if !UCONFIG_NO_FORMATTING */
271 #endif /* ETHPCCAL_H */