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