ethpccal.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. // © 2016 and later: Unicode, Inc. and others.
  2. // License & terms of use: http://www.unicode.org/copyright.html
  3. /*
  4. *******************************************************************************
  5. * Copyright (C) 2003 - 2013, International Business Machines Corporation and *
  6. * others. All Rights Reserved. *
  7. *******************************************************************************
  8. */
  9. #ifndef ETHPCCAL_H
  10. #define ETHPCCAL_H
  11. #include "unicode/utypes.h"
  12. #if !UCONFIG_NO_FORMATTING
  13. #include "unicode/calendar.h"
  14. #include "cecal.h"
  15. U_NAMESPACE_BEGIN
  16. /**
  17. * Implement the Ethiopic calendar system.
  18. * @internal
  19. */
  20. class EthiopicCalendar : public CECalendar {
  21. public:
  22. /**
  23. * Calendar type - use Amete Alem era for all the time or not
  24. * @internal
  25. */
  26. enum EEraType {
  27. AMETE_MIHRET_ERA,
  28. AMETE_ALEM_ERA
  29. };
  30. /**
  31. * Useful constants for EthiopicCalendar.
  32. * @internal
  33. */
  34. enum EMonths {
  35. /**
  36. * Constant for መስከረም, the 1st month of the Ethiopic year.
  37. */
  38. MESKEREM,
  39. /**
  40. * Constant for ጥቅምት, the 2nd month of the Ethiopic year.
  41. */
  42. TEKEMT,
  43. /**
  44. * Constant for ኅዳር, the 3rd month of the Ethiopic year.
  45. */
  46. HEDAR,
  47. /**
  48. * Constant for ታኅሣሥ, the 4th month of the Ethiopic year.
  49. */
  50. TAHSAS,
  51. /**
  52. * Constant for ጥር, the 5th month of the Ethiopic year.
  53. */
  54. TER,
  55. /**
  56. * Constant for የካቲት, the 6th month of the Ethiopic year.
  57. */
  58. YEKATIT,
  59. /**
  60. * Constant for መጋቢት, the 7th month of the Ethiopic year.
  61. */
  62. MEGABIT,
  63. /**
  64. * Constant for ሚያዝያ, the 8th month of the Ethiopic year.
  65. */
  66. MIAZIA,
  67. /**
  68. * Constant for ግንቦት, the 9th month of the Ethiopic year.
  69. */
  70. GENBOT,
  71. /**
  72. * Constant for ሰኔ, the 10th month of the Ethiopic year.
  73. */
  74. SENE,
  75. /**
  76. * Constant for ሐምሌ, the 11th month of the Ethiopic year.
  77. */
  78. HAMLE,
  79. /**
  80. * Constant for ነሐሴ, the 12th month of the Ethiopic year.
  81. */
  82. NEHASSA,
  83. /**
  84. * Constant for ጳጉሜን, the 13th month of the Ethiopic year.
  85. */
  86. PAGUMEN
  87. };
  88. enum EEras {
  89. AMETE_ALEM, // Before the epoch
  90. AMETE_MIHRET // After the epoch
  91. };
  92. /**
  93. * Constructs a EthiopicCalendar based on the current time in the default time zone
  94. * with the given locale.
  95. *
  96. * @param aLocale The given locale.
  97. * @param success Indicates the status of EthiopicCalendar object construction.
  98. * Returns U_ZERO_ERROR if constructed successfully.
  99. * @param type Whether this Ethiopic calendar use Amete Mihrret (default) or
  100. * only use Amete Alem for all the time.
  101. * @internal
  102. */
  103. EthiopicCalendar(const Locale& aLocale, UErrorCode& success, EEraType type = AMETE_MIHRET_ERA);
  104. /**
  105. * Copy Constructor
  106. * @internal
  107. */
  108. EthiopicCalendar(const EthiopicCalendar& other);
  109. /**
  110. * Destructor.
  111. * @internal
  112. */
  113. virtual ~EthiopicCalendar();
  114. /**
  115. * Create and return a polymorphic copy of this calendar.
  116. * @return return a polymorphic copy of this calendar.
  117. * @internal
  118. */
  119. virtual EthiopicCalendar* clone() const;
  120. /**
  121. * return the calendar type, "ethiopic"
  122. * @return calendar type
  123. * @internal
  124. */
  125. virtual const char * getType() const;
  126. /**
  127. * Set Alem or Mihret era.
  128. * @param onOff Set Amete Alem era if true, otherwise set Amete Mihret era.
  129. * @internal
  130. */
  131. void setAmeteAlemEra (UBool onOff);
  132. /**
  133. * Return true if this calendar is set to the Amete Alem era.
  134. * @return true if set to the Amete Alem era.
  135. * @internal
  136. */
  137. UBool isAmeteAlemEra() const;
  138. protected:
  139. //-------------------------------------------------------------------------
  140. // Calendar framework
  141. //-------------------------------------------------------------------------
  142. /**
  143. * Return the extended year defined by the current fields.
  144. * @internal
  145. */
  146. virtual int32_t handleGetExtendedYear();
  147. /**
  148. * Compute fields from the JD
  149. * @internal
  150. */
  151. virtual void handleComputeFields(int32_t julianDay, UErrorCode &status);
  152. /**
  153. * Calculate the limit for a specified type of limit and field
  154. * @internal
  155. */
  156. virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const;
  157. /**
  158. * Returns the date of the start of the default century
  159. * @return start of century - in milliseconds since epoch, 1970
  160. * @internal
  161. */
  162. virtual UDate defaultCenturyStart() const;
  163. /**
  164. * Returns the year in which the default century begins
  165. * @internal
  166. */
  167. virtual int32_t defaultCenturyStartYear() const;
  168. /**
  169. * Return the date offset from Julian
  170. * @internal
  171. */
  172. virtual int32_t getJDEpochOffset() const;
  173. private:
  174. /**
  175. * When eraType is AMETE_ALEM_ERA, then this calendar use only AMETE_ALEM
  176. * for the era. Otherwise (default), this calendar uses both AMETE_ALEM
  177. * and AMETE_MIHRET.
  178. *
  179. * EXTENDED_YEAR AMETE_ALEM_ERA AMETE_MIHRET_ERA
  180. * 0 Amete Alem 5500 Amete Alem 5500
  181. * 1 Amete Mihret 1 Amete Alem 5501
  182. */
  183. EEraType eraType;
  184. public:
  185. /**
  186. * Override Calendar Returns a unique class ID POLYMORPHICALLY. Pure virtual
  187. * override. This method is to implement a simple version of RTTI, since not all C++
  188. * compilers support genuine RTTI. Polymorphic operator==() and clone() methods call
  189. * this method.
  190. *
  191. * @return The class ID for this object. All objects of a given class have the
  192. * same class ID. Objects of other classes have different class IDs.
  193. * @internal
  194. */
  195. virtual UClassID getDynamicClassID(void) const;
  196. /**
  197. * Return the class ID for this class. This is useful only for comparing to a return
  198. * value from getDynamicClassID(). For example:
  199. *
  200. * Base* polymorphic_pointer = createPolymorphicObject();
  201. * if (polymorphic_pointer->getDynamicClassID() ==
  202. * Derived::getStaticClassID()) ...
  203. *
  204. * @return The class ID for all objects of this class.
  205. * @internal
  206. */
  207. U_I18N_API static UClassID U_EXPORT2 getStaticClassID(void);
  208. #if 0
  209. // We do not want to introduce this API in ICU4C.
  210. // It was accidentally introduced in ICU4J as a public API.
  211. public:
  212. //-------------------------------------------------------------------------
  213. // Calendar system Conversion methods...
  214. //-------------------------------------------------------------------------
  215. /**
  216. * Convert an Ethiopic year, month, and day to a Julian day.
  217. *
  218. * @param year the extended year
  219. * @param month the month
  220. * @param day the day
  221. * @return Julian day
  222. * @internal
  223. */
  224. int32_t ethiopicToJD(int32_t year, int32_t month, int32_t day);
  225. #endif
  226. };
  227. U_NAMESPACE_END
  228. #endif /* #if !UCONFIG_NO_FORMATTING */
  229. #endif /* ETHPCCAL_H */
  230. //eof