2 *******************************************************************************
3 * Copyright (C) 2003 - 2008, International Business Machines Corporation and *
4 * others. All Rights Reserved. *
5 *******************************************************************************
11 #include "unicode/utypes.h"
13 #if !UCONFIG_NO_FORMATTING
15 #include "unicode/calendar.h"
21 * Implement the Ethiopic calendar system.
24 class EthiopicCalendar
: public CECalendar
{
28 * Calendar type - use Amete Alem era for all the time or not
37 * Useful constants for EthiopicCalendar.
42 * Constant for መስከረም, the 1st month of the Ethiopic year.
47 * Constant for ጥቅምት, the 2nd month of the Ethiopic year.
52 * Constant for ኅዳር, the 3rd month of the Ethiopic year.
57 * Constant for ታኅሣሥ, the 4th month of the Ethiopic year.
62 * Constant for ጥር, the 5th month of the Ethiopic year.
67 * Constant for የካቲት, the 6th month of the Ethiopic year.
72 * Constant for መጋቢት, the 7th month of the Ethiopic year.
77 * Constant for ሚያዝያ, the 8th month of the Ethiopic year.
82 * Constant for ግንቦት, the 9th month of the Ethiopic year.
87 * Constant for ሰኔ, the 10th month of the Ethiopic year.
92 * Constant for ሐምሌ, the 11th month of the Ethiopic year.
97 * Constant for ነሐሴ, the 12th month of the Ethiopic year.
102 * Constant for ጳጉሜን, the 13th month of the Ethiopic year.
108 AMETE_ALEM
, // Before the epoch
109 AMETE_MIHRET
// After the epoch
113 * Constructs a EthiopicCalendar based on the current time in the default time zone
114 * with the given locale.
116 * @param aLocale The given locale.
117 * @param success Indicates the status of EthiopicCalendar object construction.
118 * Returns U_ZERO_ERROR if constructed successfully.
119 * @param type Whether this Ethiopic calendar use Amete Mihrret (default) or
120 * only use Amete Alem for all the time.
123 EthiopicCalendar(const Locale
& aLocale
, UErrorCode
& success
, EEraType type
= AMETE_MIHRET_ERA
);
129 EthiopicCalendar(const EthiopicCalendar
& other
);
135 virtual ~EthiopicCalendar();
138 * Create and return a polymorphic copy of this calendar.
139 * @return return a polymorphic copy of this calendar.
142 virtual Calendar
* clone() const;
145 * return the calendar type, "ethiopic"
146 * @return calendar type
149 virtual const char * getType() const;
152 * Set Alem or Mihret era.
153 * @param onOff Set Amete Alem era if true, otherwise set Amete Mihret era.
156 void setAmeteAlemEra (UBool onOff
);
159 * Return true if this calendar is set to the Amete Alem era.
160 * @return true if set to the Amete Alem era.
163 UBool
isAmeteAlemEra() const;
166 //-------------------------------------------------------------------------
167 // Calendar framework
168 //-------------------------------------------------------------------------
171 * Return the extended year defined by the current fields.
174 virtual int32_t handleGetExtendedYear();
177 * Compute fields from the JD
180 virtual void handleComputeFields(int32_t julianDay
, UErrorCode
&status
);
183 * Calculate the limit for a specified type of limit and field
186 virtual int32_t handleGetLimit(UCalendarDateFields field
, ELimitType limitType
) const;
189 * Returns the date of the start of the default century
190 * @return start of century - in milliseconds since epoch, 1970
193 virtual UDate
defaultCenturyStart() const;
196 * Returns the year in which the default century begins
199 virtual int32_t defaultCenturyStartYear() const;
202 * Return the date offset from Julian
205 virtual int32_t getJDEpochOffset() const;
209 * The system maintains a static default century start date. This is initialized
210 * the first time it is used. Before then, it is set to SYSTEM_DEFAULT_CENTURY to
211 * indicate an uninitialized state. Once the system default century date and year
212 * are set, they do not change.
214 static UDate fgSystemDefaultCenturyStart
;
217 * See documentation for systemDefaultCenturyStart.
219 static int32_t fgSystemDefaultCenturyStartYear
;
222 * Default value that indicates the defaultCenturyStartYear is unitialized
224 static const int32_t fgSystemDefaultCenturyYear
;
227 * start of default century, as a date
229 static const UDate fgSystemDefaultCentury
;
232 * Initializes the 100-year window that dates with 2-digit years
233 * are considered to fall within so that its start date is 80 years
234 * before the current time.
236 static void initializeSystemDefaultCentury(void);
239 * When eraType is AMETE_ALEM_ERA, then this calendar use only AMETE_ALEM
240 * for the era. Otherwise (default), this calendar uses both AMETE_ALEM
243 * EXTENDED_YEAR AMETE_ALEM_ERA AMETE_MIHRET_ERA
244 * 0 Amete Alem 5500 Amete Alem 5500
245 * 1 Amete Mihret 1 Amete Alem 5501
251 * Override Calendar Returns a unique class ID POLYMORPHICALLY. Pure virtual
252 * override. This method is to implement a simple version of RTTI, since not all C++
253 * compilers support genuine RTTI. Polymorphic operator==() and clone() methods call
256 * @return The class ID for this object. All objects of a given class have the
257 * same class ID. Objects of other classes have different class IDs.
260 virtual UClassID
getDynamicClassID(void) const;
263 * Return the class ID for this class. This is useful only for comparing to a return
264 * value from getDynamicClassID(). For example:
266 * Base* polymorphic_pointer = createPolymorphicObject();
267 * if (polymorphic_pointer->getDynamicClassID() ==
268 * Derived::getStaticClassID()) ...
270 * @return The class ID for all objects of this class.
273 U_I18N_API
static UClassID U_EXPORT2
getStaticClassID(void);
276 // We do not want to introduce this API in ICU4C.
277 // It was accidentally introduced in ICU4J as a public API.
280 //-------------------------------------------------------------------------
281 // Calendar system Conversion methods...
282 //-------------------------------------------------------------------------
285 * Convert an Ethiopic year, month, and day to a Julian day.
287 * @param year the extended year
288 * @param month the month
293 int32_t ethiopicToJD(int32_t year
, int32_t month
, int32_t day
);
298 #endif /* #if !UCONFIG_NO_FORMATTING */
299 #endif /* ETHPCCAL_H */