coptccal.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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 COPTCCAL_H
  10. #define COPTCCAL_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 Coptic calendar system.
  18. * @internal
  19. */
  20. class CopticCalendar : public CECalendar {
  21. public:
  22. /**
  23. * Useful constants for CopticCalendar.
  24. * @internal
  25. */
  26. enum EMonths {
  27. /**
  28. * Constant for ωογτ/تﻮﺗ,
  29. * the 1st month of the Coptic year.
  30. */
  31. TOUT,
  32. /**
  33. * Constant for Παοπι/ﻪﺑﺎﺑ,
  34. * the 2nd month of the Coptic year.
  35. */
  36. BABA,
  37. /**
  38. * Constant for Αθορ/رﻮﺗﺎﻫ,
  39. * the 3rd month of the Coptic year.
  40. */
  41. HATOR,
  42. /**
  43. * Constant for Χοιακ/ﻚﻬﻴﻛ,
  44. * the 4th month of the Coptic year.
  45. */
  46. KIAHK,
  47. /**
  48. * Constant for Τωβι/طﻮﺒﻫ,
  49. * the 5th month of the Coptic year.
  50. */
  51. TOBA,
  52. /**
  53. * Constant for Μεϣιρ/ﺮﻴﺸﻣأ,
  54. * the 6th month of the Coptic year.
  55. */
  56. AMSHIR,
  57. /**
  58. * Constant for Παρεμϩατ/تﺎﻬﻣﺮﺑ,
  59. * the 7th month of the Coptic year.
  60. */
  61. BARAMHAT,
  62. /**
  63. * Constant for Φαρμοθι/هدﻮﻣﺮﺑ,
  64. * the 8th month of the Coptic year.
  65. */
  66. BARAMOUDA,
  67. /**
  68. * Constant for Παϣαν/ﺲﻨﺸﺑ,
  69. * the 9th month of the Coptic year.
  70. */
  71. BASHANS,
  72. /**
  73. * Constant for Παωνι/ﻪﻧؤﻮﺑ,
  74. * the 10th month of the Coptic year.
  75. */
  76. PAONA,
  77. /**
  78. * Constant for Επηπ/ﺐﻴﺑأ,
  79. * the 11th month of the Coptic year.
  80. */
  81. EPEP,
  82. /**
  83. * Constant for Μεϲωρη/ىﺮﺴﻣ,
  84. * the 12th month of the Coptic year.
  85. */
  86. MESRA,
  87. /**
  88. * Constant for Πικογϫι
  89. * μαβοτ/ﺮﻴﻐﺼﻟا
  90. * ﺮﻬﺸﻟا,
  91. * the 13th month of the Coptic year.
  92. */
  93. NASIE
  94. };
  95. enum EEras {
  96. BCE, // Before the epoch
  97. CE // After the epoch
  98. };
  99. /**
  100. * Constructs a CopticCalendar based on the current time in the default time zone
  101. * with the given locale.
  102. *
  103. * @param aLocale The given locale.
  104. * @param success Indicates the status of CopticCalendar object construction.
  105. * Returns U_ZERO_ERROR if constructed successfully.
  106. * @internal
  107. */
  108. CopticCalendar(const Locale& aLocale, UErrorCode& success);
  109. /**
  110. * Copy Constructor
  111. * @internal
  112. */
  113. CopticCalendar (const CopticCalendar& other);
  114. /**
  115. * Destructor.
  116. * @internal
  117. */
  118. virtual ~CopticCalendar();
  119. /**
  120. * Create and return a polymorphic copy of this calendar.
  121. * @return return a polymorphic copy of this calendar.
  122. * @internal
  123. */
  124. virtual CopticCalendar* clone() const override;
  125. /**
  126. * return the calendar type, "coptic"
  127. * @return calendar type
  128. * @internal
  129. */
  130. const char * getType() const override;
  131. /**
  132. * @return The related Gregorian year; will be obtained by modifying the value
  133. * obtained by get from UCAL_EXTENDED_YEAR field
  134. * @internal
  135. */
  136. virtual int32_t getRelatedYear(UErrorCode &status) const override;
  137. /**
  138. * @param year The related Gregorian year to set; will be modified as necessary then
  139. * set in UCAL_EXTENDED_YEAR field
  140. * @internal
  141. */
  142. virtual void setRelatedYear(int32_t year) override;
  143. protected:
  144. //-------------------------------------------------------------------------
  145. // Calendar framework
  146. //-------------------------------------------------------------------------
  147. /**
  148. * Return the extended year defined by the current fields.
  149. * @internal
  150. */
  151. virtual int32_t handleGetExtendedYear() override;
  152. /**
  153. * Compute fields from the JD
  154. * @internal
  155. */
  156. virtual void handleComputeFields(int32_t julianDay, UErrorCode &status) override;
  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 override;
  163. /**
  164. * Returns the year in which the default century begins
  165. * @internal
  166. */
  167. virtual int32_t defaultCenturyStartYear() const override;
  168. /**
  169. * Return the date offset from Julian
  170. * @internal
  171. */
  172. virtual int32_t getJDEpochOffset() const override;
  173. public:
  174. /**
  175. * Override Calendar Returns a unique class ID POLYMORPHICALLY. Pure virtual
  176. * override. This method is to implement a simple version of RTTI, since not all C++
  177. * compilers support genuine RTTI. Polymorphic operator==() and clone() methods call
  178. * this method.
  179. *
  180. * @return The class ID for this object. All objects of a given class have the
  181. * same class ID. Objects of other classes have different class IDs.
  182. * @internal
  183. */
  184. virtual UClassID getDynamicClassID() const override;
  185. /**
  186. * Return the class ID for this class. This is useful only for comparing to a return
  187. * value from getDynamicClassID(). For example:
  188. *
  189. * Base* polymorphic_pointer = createPolymorphicObject();
  190. * if (polymorphic_pointer->getDynamicClassID() ==
  191. * Derived::getStaticClassID()) ...
  192. *
  193. * @return The class ID for all objects of this class.
  194. * @internal
  195. */
  196. U_I18N_API static UClassID U_EXPORT2 getStaticClassID();
  197. #if 0
  198. // We do not want to introduce this API in ICU4C.
  199. // It was accidentally introduced in ICU4J as a public API.
  200. public:
  201. //-------------------------------------------------------------------------
  202. // Calendar system Conversion methods...
  203. //-------------------------------------------------------------------------
  204. /**
  205. * Convert an Coptic year, month, and day to a Julian day.
  206. *
  207. * @param year the extended year
  208. * @param month the month
  209. * @param day the day
  210. * @return Julian day
  211. * @internal
  212. */
  213. static int32_t copticToJD(int32_t year, int32_t month, int32_t day);
  214. #endif
  215. };
  216. U_NAMESPACE_END
  217. #endif /* #if !UCONFIG_NO_FORMATTING */
  218. #endif /* COPTCCAL_H */
  219. //eof