ethpccal.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  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. * Useful constants for EthiopicCalendar.
  24. * @internal
  25. */
  26. enum EMonths {
  27. /**
  28. * Constant for መስከረም, the 1st month of the Ethiopic year.
  29. */
  30. MESKEREM,
  31. /**
  32. * Constant for ጥቅምት, the 2nd month of the Ethiopic year.
  33. */
  34. TEKEMT,
  35. /**
  36. * Constant for ኅዳር, the 3rd month of the Ethiopic year.
  37. */
  38. HEDAR,
  39. /**
  40. * Constant for ታኅሣሥ, the 4th month of the Ethiopic year.
  41. */
  42. TAHSAS,
  43. /**
  44. * Constant for ጥር, the 5th month of the Ethiopic year.
  45. */
  46. TER,
  47. /**
  48. * Constant for የካቲት, the 6th month of the Ethiopic year.
  49. */
  50. YEKATIT,
  51. /**
  52. * Constant for መጋቢት, the 7th month of the Ethiopic year.
  53. */
  54. MEGABIT,
  55. /**
  56. * Constant for ሚያዝያ, the 8th month of the Ethiopic year.
  57. */
  58. MIAZIA,
  59. /**
  60. * Constant for ግንቦት, the 9th month of the Ethiopic year.
  61. */
  62. GENBOT,
  63. /**
  64. * Constant for ሰኔ, the 10th month of the Ethiopic year.
  65. */
  66. SENE,
  67. /**
  68. * Constant for ሐምሌ, the 11th month of the Ethiopic year.
  69. */
  70. HAMLE,
  71. /**
  72. * Constant for ነሐሴ, the 12th month of the Ethiopic year.
  73. */
  74. NEHASSA,
  75. /**
  76. * Constant for ጳጉሜን, the 13th month of the Ethiopic year.
  77. */
  78. PAGUMEN
  79. };
  80. enum EEras {
  81. AMETE_ALEM, // Before the epoch
  82. AMETE_MIHRET // After the epoch
  83. };
  84. /**
  85. * Constructs a EthiopicCalendar based on the current time in the default time zone
  86. * with the given locale.
  87. *
  88. * @param aLocale The given locale.
  89. * @param success Indicates the status of EthiopicCalendar object construction.
  90. * Returns U_ZERO_ERROR if constructed successfully.
  91. * @param type Whether this Ethiopic calendar use Amete Mihrret (default) or
  92. * only use Amete Alem for all the time.
  93. * @internal
  94. */
  95. EthiopicCalendar(const Locale& aLocale, UErrorCode& success);
  96. /**
  97. * Copy Constructor
  98. * @internal
  99. */
  100. EthiopicCalendar(const EthiopicCalendar& other) = default;
  101. /**
  102. * Destructor.
  103. * @internal
  104. */
  105. virtual ~EthiopicCalendar();
  106. /**
  107. * Create and return a polymorphic copy of this calendar.
  108. * @return return a polymorphic copy of this calendar.
  109. * @internal
  110. */
  111. virtual EthiopicCalendar* clone() const override;
  112. /**
  113. * Return the calendar type, "ethiopic"
  114. * @return calendar type
  115. * @internal
  116. */
  117. virtual const char * getType() const override;
  118. /**
  119. * @return The related Gregorian year; will be obtained by modifying the value
  120. * obtained by get from UCAL_EXTENDED_YEAR field
  121. * @internal
  122. */
  123. virtual int32_t getRelatedYear(UErrorCode &status) const override;
  124. /**
  125. * @param year The related Gregorian year to set; will be modified as necessary then
  126. * set in UCAL_EXTENDED_YEAR field
  127. * @internal
  128. */
  129. virtual void setRelatedYear(int32_t year) override;
  130. protected:
  131. //-------------------------------------------------------------------------
  132. // Calendar framework
  133. //-------------------------------------------------------------------------
  134. /**
  135. * Return the extended year defined by the current fields.
  136. * This calendar uses both AMETE_ALEM and AMETE_MIHRET.
  137. *
  138. * EXTENDED_YEAR ERA YEAR
  139. * 0 AMETE_ALEM 5500
  140. * 1 AMETE_MIHRET 1
  141. * @internal
  142. */
  143. virtual int32_t handleGetExtendedYear() override;
  144. /**
  145. * Compute fields from the JD
  146. * @internal
  147. */
  148. virtual void handleComputeFields(int32_t julianDay, UErrorCode &status) override;
  149. /**
  150. * Returns the date of the start of the default century
  151. * @return start of century - in milliseconds since epoch, 1970
  152. * @internal
  153. */
  154. virtual UDate defaultCenturyStart() const override;
  155. /**
  156. * Returns the year in which the default century begins
  157. * @internal
  158. */
  159. virtual int32_t defaultCenturyStartYear() const override;
  160. /**
  161. * Return the date offset from Julian
  162. * @internal
  163. */
  164. virtual int32_t getJDEpochOffset() const override;
  165. public:
  166. /**
  167. * Override Calendar Returns a unique class ID POLYMORPHICALLY. Pure virtual
  168. * override. This method is to implement a simple version of RTTI, since not all C++
  169. * compilers support genuine RTTI. Polymorphic operator==() and clone() methods call
  170. * this method.
  171. *
  172. * @return The class ID for this object. All objects of a given class have the
  173. * same class ID. Objects of other classes have different class IDs.
  174. * @internal
  175. */
  176. virtual UClassID getDynamicClassID() const override;
  177. /**
  178. * Return the class ID for this class. This is useful only for comparing to a return
  179. * value from getDynamicClassID(). For example:
  180. *
  181. * Base* polymorphic_pointer = createPolymorphicObject();
  182. * if (polymorphic_pointer->getDynamicClassID() ==
  183. * Derived::getStaticClassID()) ...
  184. *
  185. * @return The class ID for all objects of this class.
  186. * @internal
  187. */
  188. U_I18N_API static UClassID U_EXPORT2 getStaticClassID();
  189. #if 0
  190. // We do not want to introduce this API in ICU4C.
  191. // It was accidentally introduced in ICU4J as a public API.
  192. public:
  193. //-------------------------------------------------------------------------
  194. // Calendar system Conversion methods...
  195. //-------------------------------------------------------------------------
  196. /**
  197. * Convert an Ethiopic year, month, and day to a Julian day.
  198. *
  199. * @param year the extended year
  200. * @param month the month
  201. * @param day the day
  202. * @return Julian day
  203. * @internal
  204. */
  205. int32_t ethiopicToJD(int32_t year, int32_t month, int32_t day);
  206. #endif
  207. };
  208. /**
  209. * Implement the Ethiopic Amete Alem calendar system.
  210. * @internal
  211. */
  212. class EthiopicAmeteAlemCalendar : public EthiopicCalendar {
  213. public:
  214. /**
  215. * Constructs a EthiopicAmeteAlemCalendar based on the current time in the default time zone
  216. * with the given locale.
  217. *
  218. * @param aLocale The given locale.
  219. * @param success Indicates the status of EthiopicCalendar object construction.
  220. * Returns U_ZERO_ERROR if constructed successfully.
  221. * @internal
  222. */
  223. EthiopicAmeteAlemCalendar(const Locale& aLocale, UErrorCode& success);
  224. /**
  225. * Copy Constructor
  226. * @internal
  227. */
  228. EthiopicAmeteAlemCalendar(const EthiopicAmeteAlemCalendar& other) = default;
  229. /**
  230. * Destructor.
  231. * @internal
  232. */
  233. virtual ~EthiopicAmeteAlemCalendar();
  234. /**
  235. * Create and return a polymorphic copy of this calendar.
  236. * @return return a polymorphic copy of this calendar.
  237. * @internal
  238. */
  239. virtual EthiopicAmeteAlemCalendar* clone() const override;
  240. /**
  241. * Return the calendar type, "ethiopic-amete-alem"
  242. * @return calendar type
  243. * @internal
  244. */
  245. virtual const char * getType() const override;
  246. /**
  247. * Override Calendar Returns a unique class ID POLYMORPHICALLY. Pure virtual
  248. * override. This method is to implement a simple version of RTTI, since not all C++
  249. * compilers support genuine RTTI. Polymorphic operator==() and clone() methods call
  250. * this method.
  251. *
  252. * @return The class ID for this object. All objects of a given class have the
  253. * same class ID. Objects of other classes have different class IDs.
  254. * @internal
  255. */
  256. virtual UClassID getDynamicClassID() const override;
  257. /**
  258. * Return the class ID for this class. This is useful only for comparing to a return
  259. * value from getDynamicClassID(). For example:
  260. *
  261. * Base* polymorphic_pointer = createPolymorphicObject();
  262. * if (polymorphic_pointer->getDynamicClassID() ==
  263. * Derived::getStaticClassID()) ...
  264. *
  265. * @return The class ID for all objects of this class.
  266. * @internal
  267. */
  268. U_I18N_API static UClassID U_EXPORT2 getStaticClassID();
  269. /**
  270. * @return The related Gregorian year; will be obtained by modifying the value
  271. * obtained by get from UCAL_EXTENDED_YEAR field
  272. * @internal
  273. */
  274. virtual int32_t getRelatedYear(UErrorCode &status) const override;
  275. /**
  276. * @param year The related Gregorian year to set; will be modified as necessary then
  277. * set in UCAL_EXTENDED_YEAR field
  278. * @internal
  279. */
  280. virtual void setRelatedYear(int32_t year) override;
  281. protected:
  282. //-------------------------------------------------------------------------
  283. // Calendar framework
  284. //-------------------------------------------------------------------------
  285. /**
  286. * Return the extended year defined by the current fields.
  287. * This calendar use only AMETE_ALEM for the era.
  288. *
  289. * EXTENDED_YEAR ERA YEAR
  290. * 0 AMETE_ALEM 5500
  291. * 1 AMETE_ALEM 5501
  292. * @internal
  293. */
  294. virtual int32_t handleGetExtendedYear() override;
  295. /**
  296. * Compute fields from the JD
  297. * @internal
  298. */
  299. virtual void handleComputeFields(int32_t julianDay, UErrorCode &status) override;
  300. /**
  301. * Calculate the limit for a specified type of limit and field
  302. * @internal
  303. */
  304. virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const override;
  305. /**
  306. * Returns the year in which the default century begins
  307. * @internal
  308. */
  309. virtual int32_t defaultCenturyStartYear() const override;
  310. };
  311. U_NAMESPACE_END
  312. #endif /* #if !UCONFIG_NO_FORMATTING */
  313. #endif /* ETHPCCAL_H */
  314. //eof