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