Coverage Report

Created: 2025-06-24 06:54

/src/icu/icu4c/source/i18n/ethpccal.h
Line
Count
Source
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
        NEHASSE,
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
2.14k
    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
protected:
145
    //-------------------------------------------------------------------------
146
    // Calendar framework
147
    //-------------------------------------------------------------------------
148
149
    /**
150
     * @internal
151
     */
152
    int32_t getRelatedYearDifference() const override;
153
154
    /**
155
     * Return the extended year defined by the current fields.
156
     * This calendar uses both AMETE_ALEM and AMETE_MIHRET.
157
     *
158
     * EXTENDED_YEAR       ERA           YEAR
159
     *             0       AMETE_ALEM    5500
160
     *             1       AMETE_MIHRET     1
161
     * @internal
162
     */
163
    virtual int32_t handleGetExtendedYear(UErrorCode& status) override;
164
165
    DECLARE_OVERRIDE_SYSTEM_DEFAULT_CENTURY
166
167
    /**
168
     * Return the date offset from Julian
169
     * @internal
170
     */
171
    int32_t getJDEpochOffset() const override;
172
173
    /**
174
     * Compute the era from extended year.
175
     * @internal
176
     */
177
    int32_t extendedYearToEra(int32_t extendedYear) const override;
178
179
    /**
180
     * Compute the year from extended year.
181
     * @internal
182
     */
183
    int32_t extendedYearToYear(int32_t extendedYear) const override;
184
185
public:
186
    /**
187
     * Override Calendar Returns a unique class ID POLYMORPHICALLY. Pure virtual
188
     * override. This method is to implement a simple version of RTTI, since not all C++
189
     * compilers support genuine RTTI. Polymorphic operator==() and clone() methods call
190
     * this method.
191
     *
192
     * @return   The class ID for this object. All objects of a given class have the
193
     *           same class ID. Objects of other classes have different class IDs.
194
     * @internal
195
     */
196
    virtual UClassID getDynamicClassID() const override;
197
198
    /**
199
     * Return the class ID for this class. This is useful only for comparing to a return
200
     * value from getDynamicClassID(). For example:
201
     *
202
     *      Base* polymorphic_pointer = createPolymorphicObject();
203
     *      if (polymorphic_pointer->getDynamicClassID() ==
204
     *          Derived::getStaticClassID()) ...
205
     *
206
     * @return   The class ID for all objects of this class.
207
     * @internal
208
     */
209
    U_I18N_API static UClassID U_EXPORT2 getStaticClassID();  
210
211
#if 0
212
// We do not want to introduce this API in ICU4C.
213
// It was accidentally introduced in ICU4J as a public API.
214
215
public:
216
    //-------------------------------------------------------------------------
217
    // Calendar system Conversion methods...
218
    //-------------------------------------------------------------------------
219
220
    /**
221
     * Convert an Ethiopic year, month, and day to a Julian day.
222
     *
223
     * @param year the extended year
224
     * @param month the month
225
     * @param day the day
226
     * @return Julian day
227
     * @internal
228
     */
229
    int32_t ethiopicToJD(int32_t year, int32_t month, int32_t day);
230
#endif
231
};
232
233
/**
234
 * Implement the Ethiopic Amete Alem calendar system.
235
 * @internal
236
 */
237
class EthiopicAmeteAlemCalendar : public EthiopicCalendar {
238
239
public:
240
    /**
241
     * Constructs a EthiopicAmeteAlemCalendar based on the current time in the default time zone
242
     * with the given locale.
243
     *
244
     * @param aLocale  The given locale.
245
     * @param success  Indicates the status of EthiopicCalendar object construction.
246
     *                 Returns U_ZERO_ERROR if constructed successfully.
247
     * @internal
248
     */
249
    EthiopicAmeteAlemCalendar(const Locale& aLocale, UErrorCode& success);
250
251
    /**
252
     * Copy Constructor
253
     * @internal
254
     */
255
825
    EthiopicAmeteAlemCalendar(const EthiopicAmeteAlemCalendar& other) = default;
256
257
    /**
258
     * Destructor.
259
     * @internal
260
     */
261
    virtual ~EthiopicAmeteAlemCalendar();
262
263
    /**
264
     * Create and return a polymorphic copy of this calendar.
265
     * @return    return a polymorphic copy of this calendar.
266
     * @internal
267
     */
268
    virtual EthiopicAmeteAlemCalendar* clone() const override;
269
270
    /**
271
     * Return the calendar type, "ethiopic-amete-alem"
272
     * @return calendar type
273
     * @internal
274
     */
275
    virtual const char * getType() const override;
276
277
    /**
278
     * Override Calendar Returns a unique class ID POLYMORPHICALLY. Pure virtual
279
     * override. This method is to implement a simple version of RTTI, since not all C++
280
     * compilers support genuine RTTI. Polymorphic operator==() and clone() methods call
281
     * this method.
282
     *
283
     * @return   The class ID for this object. All objects of a given class have the
284
     *           same class ID. Objects of other classes have different class IDs.
285
     * @internal
286
     */
287
    virtual UClassID getDynamicClassID() const override;
288
289
    /**
290
     * Return the class ID for this class. This is useful only for comparing to a return
291
     * value from getDynamicClassID(). For example:
292
     *
293
     *      Base* polymorphic_pointer = createPolymorphicObject();
294
     *      if (polymorphic_pointer->getDynamicClassID() ==
295
     *          Derived::getStaticClassID()) ...
296
     *
297
     * @return   The class ID for all objects of this class.
298
     * @internal
299
     */
300
    U_I18N_API static UClassID U_EXPORT2 getStaticClassID(); 
301
302
protected:
303
    //-------------------------------------------------------------------------
304
    // Calendar framework
305
    //-------------------------------------------------------------------------
306
307
    /**
308
     * @internal
309
     */
310
    int32_t getRelatedYearDifference() const override;
311
312
    /**
313
     * Return the extended year defined by the current fields.
314
     * This calendar use only AMETE_ALEM for the era.
315
     *
316
     * EXTENDED_YEAR       ERA         YEAR
317
     *             0       AMETE_ALEM  5500
318
     *             1       AMETE_ALEM  5501
319
     * @internal
320
     */
321
    virtual int32_t handleGetExtendedYear(UErrorCode& status) override;
322
323
    /**
324
     * Calculate the limit for a specified type of limit and field
325
     * @internal
326
     */
327
    virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const override;
328
    /**
329
     * Returns the year in which the default century begins
330
     * @internal
331
     */
332
    virtual int32_t defaultCenturyStartYear() const override;
333
334
    /**
335
     * Compute the era from extended year.
336
     * @internal
337
     */
338
    int32_t extendedYearToEra(int32_t extendedYear) const override;
339
340
    /**
341
     * Compute the year from extended year.
342
     * @internal
343
     */
344
    int32_t extendedYearToYear(int32_t extendedYear) const override;
345
};
346
347
U_NAMESPACE_END
348
#endif /* #if !UCONFIG_NO_FORMATTING */
349
#endif /* ETHPCCAL_H */
350
//eof