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