xref: /aosp_15_r20/external/icu/libicu/cts_headers/hebrwcal.h (revision 0e209d3975ff4a8c132096b14b0e9364a753506e)
1*0e209d39SAndroid Build Coastguard Worker // © 2016 and later: Unicode, Inc. and others.
2*0e209d39SAndroid Build Coastguard Worker // License & terms of use: http://www.unicode.org/copyright.html
3*0e209d39SAndroid Build Coastguard Worker /*
4*0e209d39SAndroid Build Coastguard Worker ******************************************************************************
5*0e209d39SAndroid Build Coastguard Worker * Copyright (C) 2003-2013, International Business Machines Corporation
6*0e209d39SAndroid Build Coastguard Worker * and others. All Rights Reserved.
7*0e209d39SAndroid Build Coastguard Worker ******************************************************************************
8*0e209d39SAndroid Build Coastguard Worker *
9*0e209d39SAndroid Build Coastguard Worker * File HEBRWCAL.H
10*0e209d39SAndroid Build Coastguard Worker *
11*0e209d39SAndroid Build Coastguard Worker * Modification History:
12*0e209d39SAndroid Build Coastguard Worker *
13*0e209d39SAndroid Build Coastguard Worker *   Date        Name        Description
14*0e209d39SAndroid Build Coastguard Worker *   05/13/2003  srl          copied from gregocal.h
15*0e209d39SAndroid Build Coastguard Worker *   11/26/2003  srl          copied from buddhcal.h
16*0e209d39SAndroid Build Coastguard Worker ******************************************************************************
17*0e209d39SAndroid Build Coastguard Worker */
18*0e209d39SAndroid Build Coastguard Worker 
19*0e209d39SAndroid Build Coastguard Worker #ifndef HEBRWCAL_H
20*0e209d39SAndroid Build Coastguard Worker #define HEBRWCAL_H
21*0e209d39SAndroid Build Coastguard Worker 
22*0e209d39SAndroid Build Coastguard Worker #include "unicode/utypes.h"
23*0e209d39SAndroid Build Coastguard Worker 
24*0e209d39SAndroid Build Coastguard Worker #if !UCONFIG_NO_FORMATTING
25*0e209d39SAndroid Build Coastguard Worker 
26*0e209d39SAndroid Build Coastguard Worker #include "unicode/calendar.h"
27*0e209d39SAndroid Build Coastguard Worker #include "unicode/gregocal.h"
28*0e209d39SAndroid Build Coastguard Worker 
29*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_BEGIN
30*0e209d39SAndroid Build Coastguard Worker 
31*0e209d39SAndroid Build Coastguard Worker /**
32*0e209d39SAndroid Build Coastguard Worker  * <code>HebrewCalendar</code> is a subclass of <code>Calendar</code>
33*0e209d39SAndroid Build Coastguard Worker  * that that implements the traditional Hebrew calendar.
34*0e209d39SAndroid Build Coastguard Worker  * This is the civil calendar in Israel and the liturgical calendar
35*0e209d39SAndroid Build Coastguard Worker  * of the Jewish faith worldwide.
36*0e209d39SAndroid Build Coastguard Worker  * <p>
37*0e209d39SAndroid Build Coastguard Worker  * The Hebrew calendar is lunisolar and thus has a number of interesting
38*0e209d39SAndroid Build Coastguard Worker  * properties that distinguish it from the Gregorian.  Months start
39*0e209d39SAndroid Build Coastguard Worker  * on the day of (an arithmetic approximation of) each new moon.  Since the
40*0e209d39SAndroid Build Coastguard Worker  * solar year (approximately 365.24 days) is not an even multiple of
41*0e209d39SAndroid Build Coastguard Worker  * the lunar month (approximately 29.53 days) an extra "leap month" is
42*0e209d39SAndroid Build Coastguard Worker  * inserted in 7 out of every 19 years.  To make matters even more
43*0e209d39SAndroid Build Coastguard Worker  * interesting, the start of a year can be delayed by up to three days
44*0e209d39SAndroid Build Coastguard Worker  * in order to prevent certain holidays from falling on the Sabbath and
45*0e209d39SAndroid Build Coastguard Worker  * to prevent certain illegal year lengths.  Finally, the lengths of certain
46*0e209d39SAndroid Build Coastguard Worker  * months can vary depending on the number of days in the year.
47*0e209d39SAndroid Build Coastguard Worker  * <p>
48*0e209d39SAndroid Build Coastguard Worker  * The leap month is known as "Adar 1" and is inserted between the
49*0e209d39SAndroid Build Coastguard Worker  * months of Shevat and Adar in leap years.  Since the leap month does
50*0e209d39SAndroid Build Coastguard Worker  * not come at the end of the year, calculations involving
51*0e209d39SAndroid Build Coastguard Worker  * month numbers are particularly complex.  Users of this class should
52*0e209d39SAndroid Build Coastguard Worker  * make sure to use the {@link #roll roll} and {@link #add add} methods
53*0e209d39SAndroid Build Coastguard Worker  * rather than attempting to perform date arithmetic by manipulating
54*0e209d39SAndroid Build Coastguard Worker  * the fields directly.
55*0e209d39SAndroid Build Coastguard Worker  * <p>
56*0e209d39SAndroid Build Coastguard Worker  * <b>Note:</b> In the traditional Hebrew calendar, days start at sunset.
57*0e209d39SAndroid Build Coastguard Worker  * However, in order to keep the time fields in this class
58*0e209d39SAndroid Build Coastguard Worker  * synchronized with those of the other calendars and with local clock time,
59*0e209d39SAndroid Build Coastguard Worker  * we treat days and months as beginning at midnight,
60*0e209d39SAndroid Build Coastguard Worker  * roughly 6 hours after the corresponding sunset.
61*0e209d39SAndroid Build Coastguard Worker  * <p>
62*0e209d39SAndroid Build Coastguard Worker  * If you are interested in more information on the rules behind the Hebrew
63*0e209d39SAndroid Build Coastguard Worker  * calendar, see one of the following references:
64*0e209d39SAndroid Build Coastguard Worker  * <ul>
65*0e209d39SAndroid Build Coastguard Worker  * <li>"<a href="http://www.amazon.com/exec/obidos/ASIN/0521564743">Calendrical Calculations</a>",
66*0e209d39SAndroid Build Coastguard Worker  *      by Nachum Dershowitz & Edward Reingold, Cambridge University Press, 1997, pages 85-91.
67*0e209d39SAndroid Build Coastguard Worker  *
68*0e209d39SAndroid Build Coastguard Worker  * <li>Hebrew Calendar Science and Myths,
69*0e209d39SAndroid Build Coastguard Worker  *      <a href="http://www.geocities.com/Athens/1584/">
70*0e209d39SAndroid Build Coastguard Worker  *      http://www.geocities.com/Athens/1584/</a>
71*0e209d39SAndroid Build Coastguard Worker  *
72*0e209d39SAndroid Build Coastguard Worker  * <li>The Calendar FAQ,
73*0e209d39SAndroid Build Coastguard Worker  *      <a href="http://www.faqs.org/faqs/calendars/faq/">
74*0e209d39SAndroid Build Coastguard Worker  *      http://www.faqs.org/faqs/calendars/faq/</a>
75*0e209d39SAndroid Build Coastguard Worker  * </ul>
76*0e209d39SAndroid Build Coastguard Worker  * <p>
77*0e209d39SAndroid Build Coastguard Worker  * @see com.ibm.icu.util.GregorianCalendar
78*0e209d39SAndroid Build Coastguard Worker  *
79*0e209d39SAndroid Build Coastguard Worker  * @author Laura Werner
80*0e209d39SAndroid Build Coastguard Worker  * @author Alan Liu
81*0e209d39SAndroid Build Coastguard Worker  * @author Steven R. Loomis
82*0e209d39SAndroid Build Coastguard Worker  * <p>
83*0e209d39SAndroid Build Coastguard Worker  * @internal
84*0e209d39SAndroid Build Coastguard Worker  */
85*0e209d39SAndroid Build Coastguard Worker class U_I18N_API HebrewCalendar : public Calendar {
86*0e209d39SAndroid Build Coastguard Worker public:
87*0e209d39SAndroid Build Coastguard Worker   /**
88*0e209d39SAndroid Build Coastguard Worker    * Useful constants for HebrewCalendar.
89*0e209d39SAndroid Build Coastguard Worker    * @internal
90*0e209d39SAndroid Build Coastguard Worker    */
91*0e209d39SAndroid Build Coastguard Worker   enum Month {
92*0e209d39SAndroid Build Coastguard Worker     /**
93*0e209d39SAndroid Build Coastguard Worker      * Constant for Tishri, the 1st month of the Hebrew year.
94*0e209d39SAndroid Build Coastguard Worker      */
95*0e209d39SAndroid Build Coastguard Worker       TISHRI,
96*0e209d39SAndroid Build Coastguard Worker       /**
97*0e209d39SAndroid Build Coastguard Worker      * Constant for Heshvan, the 2nd month of the Hebrew year.
98*0e209d39SAndroid Build Coastguard Worker      */
99*0e209d39SAndroid Build Coastguard Worker       HESHVAN,
100*0e209d39SAndroid Build Coastguard Worker       /**
101*0e209d39SAndroid Build Coastguard Worker      * Constant for Kislev, the 3rd month of the Hebrew year.
102*0e209d39SAndroid Build Coastguard Worker      */
103*0e209d39SAndroid Build Coastguard Worker       KISLEV,
104*0e209d39SAndroid Build Coastguard Worker 
105*0e209d39SAndroid Build Coastguard Worker     /**
106*0e209d39SAndroid Build Coastguard Worker      * Constant for Tevet, the 4th month of the Hebrew year.
107*0e209d39SAndroid Build Coastguard Worker      */
108*0e209d39SAndroid Build Coastguard Worker       TEVET,
109*0e209d39SAndroid Build Coastguard Worker 
110*0e209d39SAndroid Build Coastguard Worker     /**
111*0e209d39SAndroid Build Coastguard Worker      * Constant for Shevat, the 5th month of the Hebrew year.
112*0e209d39SAndroid Build Coastguard Worker      */
113*0e209d39SAndroid Build Coastguard Worker       SHEVAT,
114*0e209d39SAndroid Build Coastguard Worker 
115*0e209d39SAndroid Build Coastguard Worker     /**
116*0e209d39SAndroid Build Coastguard Worker      * Constant for Adar I, the 6th month of the Hebrew year
117*0e209d39SAndroid Build Coastguard Worker      * (present in leap years only). In non-leap years, the calendar
118*0e209d39SAndroid Build Coastguard Worker      * jumps from Shevat (5th month) to Adar (7th month).
119*0e209d39SAndroid Build Coastguard Worker      */
120*0e209d39SAndroid Build Coastguard Worker       ADAR_1,
121*0e209d39SAndroid Build Coastguard Worker 
122*0e209d39SAndroid Build Coastguard Worker     /**
123*0e209d39SAndroid Build Coastguard Worker      * Constant for the Adar, the 7th month of the Hebrew year.
124*0e209d39SAndroid Build Coastguard Worker      */
125*0e209d39SAndroid Build Coastguard Worker       ADAR,
126*0e209d39SAndroid Build Coastguard Worker 
127*0e209d39SAndroid Build Coastguard Worker     /**
128*0e209d39SAndroid Build Coastguard Worker      * Constant for Nisan, the 8th month of the Hebrew year.
129*0e209d39SAndroid Build Coastguard Worker      */
130*0e209d39SAndroid Build Coastguard Worker       NISAN,
131*0e209d39SAndroid Build Coastguard Worker 
132*0e209d39SAndroid Build Coastguard Worker     /**
133*0e209d39SAndroid Build Coastguard Worker      * Constant for Iyar, the 9th month of the Hebrew year.
134*0e209d39SAndroid Build Coastguard Worker      */
135*0e209d39SAndroid Build Coastguard Worker       IYAR,
136*0e209d39SAndroid Build Coastguard Worker 
137*0e209d39SAndroid Build Coastguard Worker     /**
138*0e209d39SAndroid Build Coastguard Worker      * Constant for Sivan, the 10th month of the Hebrew year.
139*0e209d39SAndroid Build Coastguard Worker      */
140*0e209d39SAndroid Build Coastguard Worker       SIVAN,
141*0e209d39SAndroid Build Coastguard Worker 
142*0e209d39SAndroid Build Coastguard Worker     /**
143*0e209d39SAndroid Build Coastguard Worker      * Constant for Tammuz, the 11th month of the Hebrew year.
144*0e209d39SAndroid Build Coastguard Worker      */
145*0e209d39SAndroid Build Coastguard Worker       TAMUZ,
146*0e209d39SAndroid Build Coastguard Worker 
147*0e209d39SAndroid Build Coastguard Worker     /**
148*0e209d39SAndroid Build Coastguard Worker      * Constant for Av, the 12th month of the Hebrew year.
149*0e209d39SAndroid Build Coastguard Worker      */
150*0e209d39SAndroid Build Coastguard Worker       AV,
151*0e209d39SAndroid Build Coastguard Worker 
152*0e209d39SAndroid Build Coastguard Worker     /**
153*0e209d39SAndroid Build Coastguard Worker      * Constant for Elul, the 13th month of the Hebrew year.
154*0e209d39SAndroid Build Coastguard Worker      */
155*0e209d39SAndroid Build Coastguard Worker       ELUL
156*0e209d39SAndroid Build Coastguard Worker     };
157*0e209d39SAndroid Build Coastguard Worker 
158*0e209d39SAndroid Build Coastguard Worker     /**
159*0e209d39SAndroid Build Coastguard Worker      * Constructs a HebrewCalendar based on the current time in the default time zone
160*0e209d39SAndroid Build Coastguard Worker      * with the given locale.
161*0e209d39SAndroid Build Coastguard Worker      *
162*0e209d39SAndroid Build Coastguard Worker      * @param aLocale  The given locale.
163*0e209d39SAndroid Build Coastguard Worker      * @param success  Indicates the status of HebrewCalendar object construction.
164*0e209d39SAndroid Build Coastguard Worker      *                 Returns U_ZERO_ERROR if constructed successfully.
165*0e209d39SAndroid Build Coastguard Worker      * @internal
166*0e209d39SAndroid Build Coastguard Worker      */
167*0e209d39SAndroid Build Coastguard Worker     HebrewCalendar(const Locale& aLocale, UErrorCode& success);
168*0e209d39SAndroid Build Coastguard Worker 
169*0e209d39SAndroid Build Coastguard Worker 
170*0e209d39SAndroid Build Coastguard Worker     /**
171*0e209d39SAndroid Build Coastguard Worker      * Destructor
172*0e209d39SAndroid Build Coastguard Worker      * @internal
173*0e209d39SAndroid Build Coastguard Worker      */
174*0e209d39SAndroid Build Coastguard Worker     virtual ~HebrewCalendar();
175*0e209d39SAndroid Build Coastguard Worker 
176*0e209d39SAndroid Build Coastguard Worker     /**
177*0e209d39SAndroid Build Coastguard Worker      * Copy constructor
178*0e209d39SAndroid Build Coastguard Worker      * @param source    the object to be copied.
179*0e209d39SAndroid Build Coastguard Worker      * @internal
180*0e209d39SAndroid Build Coastguard Worker      */
181*0e209d39SAndroid Build Coastguard Worker     HebrewCalendar(const HebrewCalendar& source);
182*0e209d39SAndroid Build Coastguard Worker 
183*0e209d39SAndroid Build Coastguard Worker     /**
184*0e209d39SAndroid Build Coastguard Worker      * Create and return a polymorphic copy of this calendar.
185*0e209d39SAndroid Build Coastguard Worker      * @return    return a polymorphic copy of this calendar.
186*0e209d39SAndroid Build Coastguard Worker      * @internal
187*0e209d39SAndroid Build Coastguard Worker      */
188*0e209d39SAndroid Build Coastguard Worker     virtual HebrewCalendar* clone() const override;
189*0e209d39SAndroid Build Coastguard Worker 
190*0e209d39SAndroid Build Coastguard Worker public:
191*0e209d39SAndroid Build Coastguard Worker     /**
192*0e209d39SAndroid Build Coastguard Worker      * Override Calendar Returns a unique class ID POLYMORPHICALLY. Pure virtual
193*0e209d39SAndroid Build Coastguard Worker      * override. This method is to implement a simple version of RTTI, since not all C++
194*0e209d39SAndroid Build Coastguard Worker      * compilers support genuine RTTI. Polymorphic operator==() and clone() methods call
195*0e209d39SAndroid Build Coastguard Worker      * this method.
196*0e209d39SAndroid Build Coastguard Worker      *
197*0e209d39SAndroid Build Coastguard Worker      * @return   The class ID for this object. All objects of a given class have the
198*0e209d39SAndroid Build Coastguard Worker      *           same class ID. Objects of other classes have different class IDs.
199*0e209d39SAndroid Build Coastguard Worker      * @internal
200*0e209d39SAndroid Build Coastguard Worker      */
201*0e209d39SAndroid Build Coastguard Worker     virtual UClassID getDynamicClassID() const override;
202*0e209d39SAndroid Build Coastguard Worker 
203*0e209d39SAndroid Build Coastguard Worker     /**
204*0e209d39SAndroid Build Coastguard Worker      * Return the class ID for this class. This is useful only for comparing to a return
205*0e209d39SAndroid Build Coastguard Worker      * value from getDynamicClassID(). For example:
206*0e209d39SAndroid Build Coastguard Worker      *
207*0e209d39SAndroid Build Coastguard Worker      *      Base* polymorphic_pointer = createPolymorphicObject();
208*0e209d39SAndroid Build Coastguard Worker      *      if (polymorphic_pointer->getDynamicClassID() ==
209*0e209d39SAndroid Build Coastguard Worker      *          Derived::getStaticClassID()) ...
210*0e209d39SAndroid Build Coastguard Worker      *
211*0e209d39SAndroid Build Coastguard Worker      * @return   The class ID for all objects of this class.
212*0e209d39SAndroid Build Coastguard Worker      * @internal
213*0e209d39SAndroid Build Coastguard Worker      */
214*0e209d39SAndroid Build Coastguard Worker     static UClassID U_EXPORT2 getStaticClassID();
215*0e209d39SAndroid Build Coastguard Worker 
216*0e209d39SAndroid Build Coastguard Worker     /**
217*0e209d39SAndroid Build Coastguard Worker      * return the calendar type, "hebrew".
218*0e209d39SAndroid Build Coastguard Worker      *
219*0e209d39SAndroid Build Coastguard Worker      * @return calendar type
220*0e209d39SAndroid Build Coastguard Worker      * @internal
221*0e209d39SAndroid Build Coastguard Worker      */
222*0e209d39SAndroid Build Coastguard Worker     virtual const char * getType() const override;
223*0e209d39SAndroid Build Coastguard Worker 
224*0e209d39SAndroid Build Coastguard Worker 
225*0e209d39SAndroid Build Coastguard Worker     // Calendar API
226*0e209d39SAndroid Build Coastguard Worker  public:
227*0e209d39SAndroid Build Coastguard Worker     /**
228*0e209d39SAndroid Build Coastguard Worker      * (Overrides Calendar) UDate Arithmetic function. Adds the specified (signed) amount
229*0e209d39SAndroid Build Coastguard Worker      * of time to the given time field, based on the calendar's rules.  For more
230*0e209d39SAndroid Build Coastguard Worker      * information, see the documentation for Calendar::add().
231*0e209d39SAndroid Build Coastguard Worker      *
232*0e209d39SAndroid Build Coastguard Worker      * @param field   The time field.
233*0e209d39SAndroid Build Coastguard Worker      * @param amount  The amount of date or time to be added to the field.
234*0e209d39SAndroid Build Coastguard Worker      * @param status  Output param set to success/failure code on exit. If any value
235*0e209d39SAndroid Build Coastguard Worker      *                previously set in the time field is invalid, this will be set to
236*0e209d39SAndroid Build Coastguard Worker      *                an error status.
237*0e209d39SAndroid Build Coastguard Worker      */
238*0e209d39SAndroid Build Coastguard Worker     virtual void add(UCalendarDateFields field, int32_t amount, UErrorCode& status) override;
239*0e209d39SAndroid Build Coastguard Worker     /**
240*0e209d39SAndroid Build Coastguard Worker      * @deprecated ICU 2.6 use UCalendarDateFields instead of EDateFields
241*0e209d39SAndroid Build Coastguard Worker      */
242*0e209d39SAndroid Build Coastguard Worker     virtual void add(EDateFields field, int32_t amount, UErrorCode& status) override;
243*0e209d39SAndroid Build Coastguard Worker 
244*0e209d39SAndroid Build Coastguard Worker 
245*0e209d39SAndroid Build Coastguard Worker     /**
246*0e209d39SAndroid Build Coastguard Worker      * (Overrides Calendar) Rolls up or down by the given amount in the specified field.
247*0e209d39SAndroid Build Coastguard Worker      * For more information, see the documentation for Calendar::roll().
248*0e209d39SAndroid Build Coastguard Worker      *
249*0e209d39SAndroid Build Coastguard Worker      * @param field   The time field.
250*0e209d39SAndroid Build Coastguard Worker      * @param amount  Indicates amount to roll.
251*0e209d39SAndroid Build Coastguard Worker      * @param status  Output param set to success/failure code on exit. If any value
252*0e209d39SAndroid Build Coastguard Worker      *                previously set in the time field is invalid, this will be set to
253*0e209d39SAndroid Build Coastguard Worker      *                an error status.
254*0e209d39SAndroid Build Coastguard Worker      * @internal
255*0e209d39SAndroid Build Coastguard Worker      */
256*0e209d39SAndroid Build Coastguard Worker     virtual void roll(UCalendarDateFields field, int32_t amount, UErrorCode& status) override;
257*0e209d39SAndroid Build Coastguard Worker 
258*0e209d39SAndroid Build Coastguard Worker     /**
259*0e209d39SAndroid Build Coastguard Worker      * (Overrides Calendar) Rolls up or down by the given amount in the specified field.
260*0e209d39SAndroid Build Coastguard Worker      * For more information, see the documentation for Calendar::roll().
261*0e209d39SAndroid Build Coastguard Worker      *
262*0e209d39SAndroid Build Coastguard Worker      * @param field   The time field.
263*0e209d39SAndroid Build Coastguard Worker      * @param amount  Indicates amount to roll.
264*0e209d39SAndroid Build Coastguard Worker      * @param status  Output param set to success/failure code on exit. If any value
265*0e209d39SAndroid Build Coastguard Worker      *                previously set in the time field is invalid, this will be set to
266*0e209d39SAndroid Build Coastguard Worker      *                an error status.
267*0e209d39SAndroid Build Coastguard Worker      * @deprecated ICU 2.6. Use roll(UCalendarDateFields field, int32_t amount, UErrorCode& status) instead.
268*0e209d39SAndroid Build Coastguard Worker `     */
269*0e209d39SAndroid Build Coastguard Worker     virtual void roll(EDateFields field, int32_t amount, UErrorCode& status) override;
270*0e209d39SAndroid Build Coastguard Worker 
271*0e209d39SAndroid Build Coastguard Worker     /**
272*0e209d39SAndroid Build Coastguard Worker      * @internal
273*0e209d39SAndroid Build Coastguard Worker      */
274*0e209d39SAndroid Build Coastguard Worker     static UBool isLeapYear(int32_t year) ;
275*0e209d39SAndroid Build Coastguard Worker 
276*0e209d39SAndroid Build Coastguard Worker     /**
277*0e209d39SAndroid Build Coastguard Worker      * @return      The related Gregorian year; will be obtained by modifying the value
278*0e209d39SAndroid Build Coastguard Worker      *              obtained by get from UCAL_EXTENDED_YEAR field
279*0e209d39SAndroid Build Coastguard Worker      * @internal
280*0e209d39SAndroid Build Coastguard Worker      */
281*0e209d39SAndroid Build Coastguard Worker     virtual int32_t getRelatedYear(UErrorCode &status) const override;
282*0e209d39SAndroid Build Coastguard Worker 
283*0e209d39SAndroid Build Coastguard Worker     /**
284*0e209d39SAndroid Build Coastguard Worker      * @param year  The related Gregorian year to set; will be modified as necessary then
285*0e209d39SAndroid Build Coastguard Worker      *              set in UCAL_EXTENDED_YEAR field
286*0e209d39SAndroid Build Coastguard Worker      * @internal
287*0e209d39SAndroid Build Coastguard Worker      */
288*0e209d39SAndroid Build Coastguard Worker     virtual void setRelatedYear(int32_t year) override;
289*0e209d39SAndroid Build Coastguard Worker 
290*0e209d39SAndroid Build Coastguard Worker  protected:
291*0e209d39SAndroid Build Coastguard Worker 
292*0e209d39SAndroid Build Coastguard Worker     /**
293*0e209d39SAndroid Build Coastguard Worker      * Subclass API for defining limits of different types.
294*0e209d39SAndroid Build Coastguard Worker      * Subclasses must implement this method to return limits for the
295*0e209d39SAndroid Build Coastguard Worker      * following fields:
296*0e209d39SAndroid Build Coastguard Worker      *
297*0e209d39SAndroid Build Coastguard Worker      * <pre>UCAL_ERA
298*0e209d39SAndroid Build Coastguard Worker      * UCAL_YEAR
299*0e209d39SAndroid Build Coastguard Worker      * UCAL_MONTH
300*0e209d39SAndroid Build Coastguard Worker      * UCAL_WEEK_OF_YEAR
301*0e209d39SAndroid Build Coastguard Worker      * UCAL_WEEK_OF_MONTH
302*0e209d39SAndroid Build Coastguard Worker      * UCAL_DATE (DAY_OF_MONTH on Java)
303*0e209d39SAndroid Build Coastguard Worker      * UCAL_DAY_OF_YEAR
304*0e209d39SAndroid Build Coastguard Worker      * UCAL_DAY_OF_WEEK_IN_MONTH
305*0e209d39SAndroid Build Coastguard Worker      * UCAL_YEAR_WOY
306*0e209d39SAndroid Build Coastguard Worker      * UCAL_EXTENDED_YEAR</pre>
307*0e209d39SAndroid Build Coastguard Worker      *
308*0e209d39SAndroid Build Coastguard Worker      * @param field one of the above field numbers
309*0e209d39SAndroid Build Coastguard Worker      * @param limitType one of <code>MINIMUM</code>, <code>GREATEST_MINIMUM</code>,
310*0e209d39SAndroid Build Coastguard Worker      * <code>LEAST_MAXIMUM</code>, or <code>MAXIMUM</code>
311*0e209d39SAndroid Build Coastguard Worker      * @internal
312*0e209d39SAndroid Build Coastguard Worker      */
313*0e209d39SAndroid Build Coastguard Worker     virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const override;
314*0e209d39SAndroid Build Coastguard Worker 
315*0e209d39SAndroid Build Coastguard Worker     /**
316*0e209d39SAndroid Build Coastguard Worker      * Return the number of days in the given month of the given extended
317*0e209d39SAndroid Build Coastguard Worker      * year of this calendar system.  Subclasses should override this
318*0e209d39SAndroid Build Coastguard Worker      * method if they can provide a more correct or more efficient
319*0e209d39SAndroid Build Coastguard Worker      * implementation than the default implementation in Calendar.
320*0e209d39SAndroid Build Coastguard Worker      * @internal
321*0e209d39SAndroid Build Coastguard Worker      */
322*0e209d39SAndroid Build Coastguard Worker     virtual int32_t handleGetMonthLength(int32_t extendedYear, int32_t month, UErrorCode& status) const override;
323*0e209d39SAndroid Build Coastguard Worker 
324*0e209d39SAndroid Build Coastguard Worker     /**
325*0e209d39SAndroid Build Coastguard Worker      * Return the number of days in the given extended year of this
326*0e209d39SAndroid Build Coastguard Worker      * calendar system.  Subclasses should override this method if they can
327*0e209d39SAndroid Build Coastguard Worker      * provide a more correct or more efficient implementation than the
328*0e209d39SAndroid Build Coastguard Worker      * default implementation in Calendar.
329*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 2.0
330*0e209d39SAndroid Build Coastguard Worker      */
331*0e209d39SAndroid Build Coastguard Worker     virtual int32_t handleGetYearLength(int32_t eyear) const override;
332*0e209d39SAndroid Build Coastguard Worker     /**
333*0e209d39SAndroid Build Coastguard Worker      * Subclasses may override this method to compute several fields
334*0e209d39SAndroid Build Coastguard Worker      * specific to each calendar system.  These are:
335*0e209d39SAndroid Build Coastguard Worker      *
336*0e209d39SAndroid Build Coastguard Worker      * <ul><li>ERA
337*0e209d39SAndroid Build Coastguard Worker      * <li>YEAR
338*0e209d39SAndroid Build Coastguard Worker      * <li>MONTH
339*0e209d39SAndroid Build Coastguard Worker      * <li>DAY_OF_MONTH
340*0e209d39SAndroid Build Coastguard Worker      * <li>DAY_OF_YEAR
341*0e209d39SAndroid Build Coastguard Worker      * <li>EXTENDED_YEAR</ul>
342*0e209d39SAndroid Build Coastguard Worker      *
343*0e209d39SAndroid Build Coastguard Worker      * <p>The GregorianCalendar implementation implements
344*0e209d39SAndroid Build Coastguard Worker      * a calendar with the specified Julian/Gregorian cutover date.
345*0e209d39SAndroid Build Coastguard Worker      * @internal
346*0e209d39SAndroid Build Coastguard Worker      */
347*0e209d39SAndroid Build Coastguard Worker     virtual void handleComputeFields(int32_t julianDay, UErrorCode &status) override;
348*0e209d39SAndroid Build Coastguard Worker     /**
349*0e209d39SAndroid Build Coastguard Worker      * Return the extended year defined by the current fields.  This will
350*0e209d39SAndroid Build Coastguard Worker      * use the UCAL_EXTENDED_YEAR field or the UCAL_YEAR and supra-year fields (such
351*0e209d39SAndroid Build Coastguard Worker      * as UCAL_ERA) specific to the calendar system, depending on which set of
352*0e209d39SAndroid Build Coastguard Worker      * fields is newer.
353*0e209d39SAndroid Build Coastguard Worker      * @param status
354*0e209d39SAndroid Build Coastguard Worker      * @return the extended year
355*0e209d39SAndroid Build Coastguard Worker      * @internal
356*0e209d39SAndroid Build Coastguard Worker      */
357*0e209d39SAndroid Build Coastguard Worker     virtual int32_t handleGetExtendedYear(UErrorCode& status) override;
358*0e209d39SAndroid Build Coastguard Worker     /**
359*0e209d39SAndroid Build Coastguard Worker      * Return the Julian day number of day before the first day of the
360*0e209d39SAndroid Build Coastguard Worker      * given month in the given extended year.  Subclasses should override
361*0e209d39SAndroid Build Coastguard Worker      * this method to implement their calendar system.
362*0e209d39SAndroid Build Coastguard Worker      * @param eyear the extended year
363*0e209d39SAndroid Build Coastguard Worker      * @param month the zero-based month, or 0 if useMonth is false
364*0e209d39SAndroid Build Coastguard Worker      * @param useMonth if false, compute the day before the first day of
365*0e209d39SAndroid Build Coastguard Worker      * the given year, otherwise, compute the day before the first day of
366*0e209d39SAndroid Build Coastguard Worker      * the given month
367*0e209d39SAndroid Build Coastguard Worker      * @param return the Julian day number of the day before the first
368*0e209d39SAndroid Build Coastguard Worker      * day of the given month and year
369*0e209d39SAndroid Build Coastguard Worker      * @internal
370*0e209d39SAndroid Build Coastguard Worker      */
371*0e209d39SAndroid Build Coastguard Worker     virtual int64_t handleComputeMonthStart(int32_t eyear, int32_t month,
372*0e209d39SAndroid Build Coastguard Worker                                                    UBool useMonth, UErrorCode& status) const override;
373*0e209d39SAndroid Build Coastguard Worker 
374*0e209d39SAndroid Build Coastguard Worker 
375*0e209d39SAndroid Build Coastguard Worker     /**
376*0e209d39SAndroid Build Coastguard Worker      * Validate a single field of this calendar.
377*0e209d39SAndroid Build Coastguard Worker      * Overrides Calendar::validateField(int) to provide
378*0e209d39SAndroid Build Coastguard Worker      * special handling for month validation for Hebrew calendar.
379*0e209d39SAndroid Build Coastguard Worker      * @internal
380*0e209d39SAndroid Build Coastguard Worker      */
381*0e209d39SAndroid Build Coastguard Worker     virtual void validateField(UCalendarDateFields field, UErrorCode &status) override;
382*0e209d39SAndroid Build Coastguard Worker 
383*0e209d39SAndroid Build Coastguard Worker  protected:
384*0e209d39SAndroid Build Coastguard Worker   DECLARE_OVERRIDE_SYSTEM_DEFAULT_CENTURY
385*0e209d39SAndroid Build Coastguard Worker 
386*0e209d39SAndroid Build Coastguard Worker  public:
387*0e209d39SAndroid Build Coastguard Worker   /**
388*0e209d39SAndroid Build Coastguard Worker    * Returns true if the date is in a leap year.
389*0e209d39SAndroid Build Coastguard Worker    *
390*0e209d39SAndroid Build Coastguard Worker    * @param status        ICU Error Code
391*0e209d39SAndroid Build Coastguard Worker    * @return       True if the date in the fields is in a Temporal proposal
392*0e209d39SAndroid Build Coastguard Worker    *               defined leap year. False otherwise.
393*0e209d39SAndroid Build Coastguard Worker    */
394*0e209d39SAndroid Build Coastguard Worker   virtual bool inTemporalLeapYear(UErrorCode& status) const override;
395*0e209d39SAndroid Build Coastguard Worker 
396*0e209d39SAndroid Build Coastguard Worker   /**
397*0e209d39SAndroid Build Coastguard Worker    * Gets The Temporal monthCode value corresponding to the month for the date.
398*0e209d39SAndroid Build Coastguard Worker    * The value is a string identifier that starts with the literal grapheme
399*0e209d39SAndroid Build Coastguard Worker    * "M" followed by two graphemes representing the zero-padded month number
400*0e209d39SAndroid Build Coastguard Worker    * of the current month in a normal (non-leap) year and suffixed by an
401*0e209d39SAndroid Build Coastguard Worker    * optional literal grapheme "L" if this is a leap month in a lunisolar
402*0e209d39SAndroid Build Coastguard Worker    * calendar. For the Hebrew calendar, the values are "M01" .. "M12" for
403*0e209d39SAndroid Build Coastguard Worker    * non-leap year, and "M01" .. "M05", "M05L", "M06" .. "M12" for leap year.
404*0e209d39SAndroid Build Coastguard Worker    *
405*0e209d39SAndroid Build Coastguard Worker    * @param status        ICU Error Code
406*0e209d39SAndroid Build Coastguard Worker    * @return       One of 13 possible strings in {"M01".. "M05", "M05L",
407*0e209d39SAndroid Build Coastguard Worker    * "M06" .. "M12"}.
408*0e209d39SAndroid Build Coastguard Worker    * @draft ICU 73
409*0e209d39SAndroid Build Coastguard Worker    */
410*0e209d39SAndroid Build Coastguard Worker   virtual const char* getTemporalMonthCode(UErrorCode& status) const override;
411*0e209d39SAndroid Build Coastguard Worker 
412*0e209d39SAndroid Build Coastguard Worker   /**
413*0e209d39SAndroid Build Coastguard Worker    * Sets The Temporal monthCode which is a string identifier that starts
414*0e209d39SAndroid Build Coastguard Worker    * with the literal grapheme "M" followed by two graphemes representing
415*0e209d39SAndroid Build Coastguard Worker    * the zero-padded month number of the current month in a normal
416*0e209d39SAndroid Build Coastguard Worker    * (non-leap) year and suffixed by an optional literal grapheme "L" if this
417*0e209d39SAndroid Build Coastguard Worker    * is a leap month in a lunisolar calendar. For Hebrew calendar, the values
418*0e209d39SAndroid Build Coastguard Worker    * are "M01" .. "M12" for non-leap years, and "M01" .. "M05", "M05L", "M06"
419*0e209d39SAndroid Build Coastguard Worker    * .. "M12" for leap year.
420*0e209d39SAndroid Build Coastguard Worker    *
421*0e209d39SAndroid Build Coastguard Worker    * @param temporalMonth  The value to be set for temporal monthCode.
422*0e209d39SAndroid Build Coastguard Worker    * @param status        ICU Error Code
423*0e209d39SAndroid Build Coastguard Worker    *
424*0e209d39SAndroid Build Coastguard Worker    * @draft ICU 73
425*0e209d39SAndroid Build Coastguard Worker    */
426*0e209d39SAndroid Build Coastguard Worker   virtual void setTemporalMonthCode(const char* code, UErrorCode& status ) override;
427*0e209d39SAndroid Build Coastguard Worker 
428*0e209d39SAndroid Build Coastguard Worker  protected:
429*0e209d39SAndroid Build Coastguard Worker    virtual int32_t internalGetMonth(UErrorCode& status) const override;
430*0e209d39SAndroid Build Coastguard Worker 
431*0e209d39SAndroid Build Coastguard Worker  private: // Calendar-specific implementation
432*0e209d39SAndroid Build Coastguard Worker     /**
433*0e209d39SAndroid Build Coastguard Worker      * Finds the day # of the first day in the given Hebrew year.
434*0e209d39SAndroid Build Coastguard Worker      * To do this, we want to calculate the time of the Tishri 1 new moon
435*0e209d39SAndroid Build Coastguard Worker      * in that year.
436*0e209d39SAndroid Build Coastguard Worker      * <p>
437*0e209d39SAndroid Build Coastguard Worker      * The algorithm here is similar to ones described in a number of
438*0e209d39SAndroid Build Coastguard Worker      * references, including:
439*0e209d39SAndroid Build Coastguard Worker      * <ul>
440*0e209d39SAndroid Build Coastguard Worker      * <li>"Calendrical Calculations", by Nachum Dershowitz & Edward Reingold,
441*0e209d39SAndroid Build Coastguard Worker      *     Cambridge University Press, 1997, pages 85-91.
442*0e209d39SAndroid Build Coastguard Worker      *
443*0e209d39SAndroid Build Coastguard Worker      * <li>Hebrew Calendar Science and Myths,
444*0e209d39SAndroid Build Coastguard Worker      *     <a href="http://www.geocities.com/Athens/1584/">
445*0e209d39SAndroid Build Coastguard Worker      *     http://www.geocities.com/Athens/1584/</a>
446*0e209d39SAndroid Build Coastguard Worker      *
447*0e209d39SAndroid Build Coastguard Worker      * <li>The Calendar FAQ,
448*0e209d39SAndroid Build Coastguard Worker      *      <a href="http://www.faqs.org/faqs/calendars/faq/">
449*0e209d39SAndroid Build Coastguard Worker      *      http://www.faqs.org/faqs/calendars/faq/</a>
450*0e209d39SAndroid Build Coastguard Worker      * </ul>
451*0e209d39SAndroid Build Coastguard Worker      * @param year extended year
452*0e209d39SAndroid Build Coastguard Worker      * @return day number (JD)
453*0e209d39SAndroid Build Coastguard Worker      * @internal
454*0e209d39SAndroid Build Coastguard Worker      */
455*0e209d39SAndroid Build Coastguard Worker     static int32_t startOfYear(int32_t year, UErrorCode& status);
456*0e209d39SAndroid Build Coastguard Worker 
457*0e209d39SAndroid Build Coastguard Worker     static int32_t absoluteDayToDayOfWeek(int32_t day) ;
458*0e209d39SAndroid Build Coastguard Worker 
459*0e209d39SAndroid Build Coastguard Worker     /**
460*0e209d39SAndroid Build Coastguard Worker      * @internal
461*0e209d39SAndroid Build Coastguard Worker      */
462*0e209d39SAndroid Build Coastguard Worker     int32_t yearType(int32_t year) const;
463*0e209d39SAndroid Build Coastguard Worker 
464*0e209d39SAndroid Build Coastguard Worker     /**
465*0e209d39SAndroid Build Coastguard Worker      * @internal
466*0e209d39SAndroid Build Coastguard Worker      */
467*0e209d39SAndroid Build Coastguard Worker     static int32_t monthsInYear(int32_t year) ;
468*0e209d39SAndroid Build Coastguard Worker };
469*0e209d39SAndroid Build Coastguard Worker 
470*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_END
471*0e209d39SAndroid Build Coastguard Worker 
472*0e209d39SAndroid Build Coastguard Worker #endif /* #if !UCONFIG_NO_FORMATTING */
473*0e209d39SAndroid Build Coastguard Worker 
474*0e209d39SAndroid Build Coastguard Worker #endif
475*0e209d39SAndroid Build Coastguard Worker //eof
476*0e209d39SAndroid Build Coastguard Worker 
477