michael@0: /* michael@0: ******************************************************************************* michael@0: * Copyright (C) 2003 - 2013, International Business Machines Corporation and * michael@0: * others. All Rights Reserved. * michael@0: ******************************************************************************* michael@0: */ michael@0: michael@0: #ifndef ETHPCCAL_H michael@0: #define ETHPCCAL_H michael@0: michael@0: #include "unicode/utypes.h" michael@0: michael@0: #if !UCONFIG_NO_FORMATTING michael@0: michael@0: #include "unicode/calendar.h" michael@0: #include "cecal.h" michael@0: michael@0: U_NAMESPACE_BEGIN michael@0: michael@0: /** michael@0: * Implement the Ethiopic calendar system. michael@0: * @internal michael@0: */ michael@0: class EthiopicCalendar : public CECalendar { michael@0: michael@0: public: michael@0: /** michael@0: * Calendar type - use Amete Alem era for all the time or not michael@0: * @internal michael@0: */ michael@0: enum EEraType { michael@0: AMETE_MIHRET_ERA, michael@0: AMETE_ALEM_ERA michael@0: }; michael@0: michael@0: /** michael@0: * Useful constants for EthiopicCalendar. michael@0: * @internal michael@0: */ michael@0: enum EMonths { michael@0: /** michael@0: * Constant for መስከረም, the 1st month of the Ethiopic year. michael@0: */ michael@0: MESKEREM, michael@0: michael@0: /** michael@0: * Constant for ጥቅምት, the 2nd month of the Ethiopic year. michael@0: */ michael@0: TEKEMT, michael@0: michael@0: /** michael@0: * Constant for ኅዳር, the 3rd month of the Ethiopic year. michael@0: */ michael@0: HEDAR, michael@0: michael@0: /** michael@0: * Constant for ታኅሣሥ, the 4th month of the Ethiopic year. michael@0: */ michael@0: TAHSAS, michael@0: michael@0: /** michael@0: * Constant for ጥር, the 5th month of the Ethiopic year. michael@0: */ michael@0: TER, michael@0: michael@0: /** michael@0: * Constant for የካቲት, the 6th month of the Ethiopic year. michael@0: */ michael@0: YEKATIT, michael@0: michael@0: /** michael@0: * Constant for መጋቢት, the 7th month of the Ethiopic year. michael@0: */ michael@0: MEGABIT, michael@0: michael@0: /** michael@0: * Constant for ሚያዝያ, the 8th month of the Ethiopic year. michael@0: */ michael@0: MIAZIA, michael@0: michael@0: /** michael@0: * Constant for ግንቦት, the 9th month of the Ethiopic year. michael@0: */ michael@0: GENBOT, michael@0: michael@0: /** michael@0: * Constant for ሰኔ, the 10th month of the Ethiopic year. michael@0: */ michael@0: SENE, michael@0: michael@0: /** michael@0: * Constant for ሐምሌ, the 11th month of the Ethiopic year. michael@0: */ michael@0: HAMLE, michael@0: michael@0: /** michael@0: * Constant for ነሐሴ, the 12th month of the Ethiopic year. michael@0: */ michael@0: NEHASSA, michael@0: michael@0: /** michael@0: * Constant for ጳጉሜን, the 13th month of the Ethiopic year. michael@0: */ michael@0: PAGUMEN michael@0: }; michael@0: michael@0: enum EEras { michael@0: AMETE_ALEM, // Before the epoch michael@0: AMETE_MIHRET // After the epoch michael@0: }; michael@0: michael@0: /** michael@0: * Constructs a EthiopicCalendar based on the current time in the default time zone michael@0: * with the given locale. michael@0: * michael@0: * @param aLocale The given locale. michael@0: * @param success Indicates the status of EthiopicCalendar object construction. michael@0: * Returns U_ZERO_ERROR if constructed successfully. michael@0: * @param type Whether this Ethiopic calendar use Amete Mihrret (default) or michael@0: * only use Amete Alem for all the time. michael@0: * @internal michael@0: */ michael@0: EthiopicCalendar(const Locale& aLocale, UErrorCode& success, EEraType type = AMETE_MIHRET_ERA); michael@0: michael@0: /** michael@0: * Copy Constructor michael@0: * @internal michael@0: */ michael@0: EthiopicCalendar(const EthiopicCalendar& other); michael@0: michael@0: /** michael@0: * Destructor. michael@0: * @internal michael@0: */ michael@0: virtual ~EthiopicCalendar(); michael@0: michael@0: /** michael@0: * Create and return a polymorphic copy of this calendar. michael@0: * @return return a polymorphic copy of this calendar. michael@0: * @internal michael@0: */ michael@0: virtual Calendar* clone() const; michael@0: michael@0: /** michael@0: * return the calendar type, "ethiopic" michael@0: * @return calendar type michael@0: * @internal michael@0: */ michael@0: virtual const char * getType() const; michael@0: michael@0: /** michael@0: * Set Alem or Mihret era. michael@0: * @param onOff Set Amete Alem era if true, otherwise set Amete Mihret era. michael@0: * @internal michael@0: */ michael@0: void setAmeteAlemEra (UBool onOff); michael@0: michael@0: /** michael@0: * Return true if this calendar is set to the Amete Alem era. michael@0: * @return true if set to the Amete Alem era. michael@0: * @internal michael@0: */ michael@0: UBool isAmeteAlemEra() const; michael@0: michael@0: protected: michael@0: //------------------------------------------------------------------------- michael@0: // Calendar framework michael@0: //------------------------------------------------------------------------- michael@0: michael@0: /** michael@0: * Return the extended year defined by the current fields. michael@0: * @internal michael@0: */ michael@0: virtual int32_t handleGetExtendedYear(); michael@0: michael@0: /** michael@0: * Compute fields from the JD michael@0: * @internal michael@0: */ michael@0: virtual void handleComputeFields(int32_t julianDay, UErrorCode &status); michael@0: michael@0: /** michael@0: * Calculate the limit for a specified type of limit and field michael@0: * @internal michael@0: */ michael@0: virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const; michael@0: michael@0: /** michael@0: * Returns the date of the start of the default century michael@0: * @return start of century - in milliseconds since epoch, 1970 michael@0: * @internal michael@0: */ michael@0: virtual UDate defaultCenturyStart() const; michael@0: michael@0: /** michael@0: * Returns the year in which the default century begins michael@0: * @internal michael@0: */ michael@0: virtual int32_t defaultCenturyStartYear() const; michael@0: michael@0: /** michael@0: * Return the date offset from Julian michael@0: * @internal michael@0: */ michael@0: virtual int32_t getJDEpochOffset() const; michael@0: michael@0: private: michael@0: /** michael@0: * When eraType is AMETE_ALEM_ERA, then this calendar use only AMETE_ALEM michael@0: * for the era. Otherwise (default), this calendar uses both AMETE_ALEM michael@0: * and AMETE_MIHRET. michael@0: * michael@0: * EXTENDED_YEAR AMETE_ALEM_ERA AMETE_MIHRET_ERA michael@0: * 0 Amete Alem 5500 Amete Alem 5500 michael@0: * 1 Amete Mihret 1 Amete Alem 5501 michael@0: */ michael@0: EEraType eraType; michael@0: michael@0: public: michael@0: /** michael@0: * Override Calendar Returns a unique class ID POLYMORPHICALLY. Pure virtual michael@0: * override. This method is to implement a simple version of RTTI, since not all C++ michael@0: * compilers support genuine RTTI. Polymorphic operator==() and clone() methods call michael@0: * this method. michael@0: * michael@0: * @return The class ID for this object. All objects of a given class have the michael@0: * same class ID. Objects of other classes have different class IDs. michael@0: * @internal michael@0: */ michael@0: virtual UClassID getDynamicClassID(void) const; michael@0: michael@0: /** michael@0: * Return the class ID for this class. This is useful only for comparing to a return michael@0: * value from getDynamicClassID(). For example: michael@0: * michael@0: * Base* polymorphic_pointer = createPolymorphicObject(); michael@0: * if (polymorphic_pointer->getDynamicClassID() == michael@0: * Derived::getStaticClassID()) ... michael@0: * michael@0: * @return The class ID for all objects of this class. michael@0: * @internal michael@0: */ michael@0: U_I18N_API static UClassID U_EXPORT2 getStaticClassID(void); michael@0: michael@0: #if 0 michael@0: // We do not want to introduce this API in ICU4C. michael@0: // It was accidentally introduced in ICU4J as a public API. michael@0: michael@0: public: michael@0: //------------------------------------------------------------------------- michael@0: // Calendar system Conversion methods... michael@0: //------------------------------------------------------------------------- michael@0: michael@0: /** michael@0: * Convert an Ethiopic year, month, and day to a Julian day. michael@0: * michael@0: * @param year the extended year michael@0: * @param month the month michael@0: * @param day the day michael@0: * @return Julian day michael@0: * @internal michael@0: */ michael@0: int32_t ethiopicToJD(int32_t year, int32_t month, int32_t day); michael@0: #endif michael@0: }; michael@0: michael@0: U_NAMESPACE_END michael@0: #endif /* #if !UCONFIG_NO_FORMATTING */ michael@0: #endif /* ETHPCCAL_H */ michael@0: //eof