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