1b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/*
2b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru********************************************************************************
3fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius*   Copyright (C) 1997-2014, International Business Machines
4b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*   Corporation and others.  All Rights Reserved.
5b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru********************************************************************************
6b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*
7b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* File CALENDAR.H
8b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*
9b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* Modification History:
10b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*
11b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*   Date        Name        Description
12b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*   04/22/97    aliu        Expanded and corrected comments and other header
13b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*                           contents.
14b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*   05/01/97    aliu        Made equals(), before(), after() arguments const.
15b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*   05/20/97    aliu        Replaced fAreFieldsSet with fAreFieldsInSync and
16b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*                           fAreAllFieldsSet.
17b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*   07/27/98    stephen     Sync up with JDK 1.2
18b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*   11/15/99    weiv        added YEAR_WOY and DOW_LOCAL
19b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*                           to EDateFields
20b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*    8/19/2002  srl         Removed Javaisms
21b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*   11/07/2003  srl         Update, clean up documentation.
22b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru********************************************************************************
23b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*/
24b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
25b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#ifndef CALENDAR_H
26b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define CALENDAR_H
27b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
28b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/utypes.h"
29b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
30b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
31b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \file
32b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \brief C++ API: Calendar object
33b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
34b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_FORMATTING
35b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
36b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/uobject.h"
37b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/locid.h"
38b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/timezone.h"
39b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/ucal.h"
40b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/umisc.h"
41b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
42b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_NAMESPACE_BEGIN
43b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
44b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruclass ICUServiceFactory;
45b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
46b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
47b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @internal
48b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
49b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querutypedef int32_t UFieldResolutionTable[12][8];
50b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
51103e9ffba2cba345d0078eb8b8db33249f81840aCraig Corneliusclass BasicTimeZone;
52b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
53b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <code>Calendar</code> is an abstract base class for converting between
54b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * a <code>UDate</code> object and a set of integer fields such as
55b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <code>YEAR</code>, <code>MONTH</code>, <code>DAY</code>, <code>HOUR</code>,
56b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * and so on. (A <code>UDate</code> object represents a specific instant in
57b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * time with millisecond precision. See UDate
58b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * for information about the <code>UDate</code> class.)
59b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
60b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <p>
61b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Subclasses of <code>Calendar</code> interpret a <code>UDate</code>
62b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * according to the rules of a specific calendar system.
63b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The most commonly used subclass of <code>Calendar</code> is
64b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <code>GregorianCalendar</code>. Other subclasses could represent
65b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the various types of lunar calendars in use in many parts of the world.
66b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
67b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <p>
68b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <b>NOTE</b>: (ICU 2.6) The subclass interface should be considered unstable
69b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - it WILL change.
70b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
71b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <p>
72b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Like other locale-sensitive classes, <code>Calendar</code> provides a
73b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * static method, <code>createInstance</code>, for getting a generally useful
74b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * object of this type. <code>Calendar</code>'s <code>createInstance</code> method
75b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * returns the appropriate <code>Calendar</code> subclass whose
76b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * time fields have been initialized with the current date and time:
77b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \htmlonly<blockquote>\endhtmlonly
78b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <pre>
79b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Calendar *rightNow = Calendar::createInstance(errCode);
80b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * </pre>
81b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \htmlonly</blockquote>\endhtmlonly
82b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
83b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <p>
84b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * A <code>Calendar</code> object can produce all the time field values
85b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * needed to implement the date-time formatting for a particular language
86b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * and calendar style (for example, Japanese-Gregorian, Japanese-Traditional).
87b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
88b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <p>
8954dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * When computing a <code>UDate</code> from time fields, some special circumstances
90b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * may arise: there may be insufficient information to compute the
91b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <code>UDate</code> (such as only year and month but no day in the month),
9254dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * there may be inconsistent information (such as "Tuesday, July 15, 1996"
9354dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * -- July 15, 1996 is actually a Monday), or the input time might be ambiguous
9454dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * because of time zone transition.
95b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
96b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <p>
97b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <strong>Insufficient information.</strong> The calendar will use default
98b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * information to specify the missing fields. This may vary by calendar; for
99b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the Gregorian calendar, the default for a field is the same as that of the
100b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * start of the epoch: i.e., YEAR = 1970, MONTH = JANUARY, DATE = 1, etc.
101b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
102b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <p>
103b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <strong>Inconsistent information.</strong> If fields conflict, the calendar
104b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * will give preference to fields set more recently. For example, when
105b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * determining the day, the calendar will look for one of the following
106b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * combinations of fields.  The most recent combination, as determined by the
107b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * most recently set single field, will be used.
108b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
109b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \htmlonly<blockquote>\endhtmlonly
110b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <pre>
111b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * MONTH + DAY_OF_MONTH
112b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * MONTH + WEEK_OF_MONTH + DAY_OF_WEEK
113b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * MONTH + DAY_OF_WEEK_IN_MONTH + DAY_OF_WEEK
114b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * DAY_OF_YEAR
115b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * DAY_OF_WEEK + WEEK_OF_YEAR
116b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * </pre>
117b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \htmlonly</blockquote>\endhtmlonly
118b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
119b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * For the time of day:
120b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
121b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \htmlonly<blockquote>\endhtmlonly
122b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <pre>
123b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * HOUR_OF_DAY
124b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * AM_PM + HOUR
125b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * </pre>
126b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \htmlonly</blockquote>\endhtmlonly
127b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
128b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <p>
12954dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * <strong>Ambiguous Wall Clock Time.</strong> When time offset from UTC has
13054dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * changed, it produces ambiguous time slot around the transition. For example,
13154dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * many US locations observe daylight saving time. On the date switching to daylight
13254dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * saving time in US, wall clock time jumps from 1:00 AM (standard) to 2:00 AM
13354dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * (daylight). Therefore, wall clock time from 1:00 AM to 1:59 AM do not exist on
13454dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * the date. When the input wall time fall into this missing time slot, the ICU
13554dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * Calendar resolves the time using the UTC offset before the transition by default.
13654dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * In this example, 1:30 AM is interpreted as 1:30 AM standard time (non-exist),
13754dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * so the final result will be 2:30 AM daylight time.
13854dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius *
13954dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * <p>On the date switching back to standard time, wall clock time is moved back one
14054dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * hour at 2:00 AM. So wall clock time from 1:00 AM to 1:59 AM occur twice. In this
14154dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * case, the ICU Calendar resolves the time using the UTC offset after the transition
14254dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * by default. For example, 1:30 AM on the date is resolved as 1:30 AM standard time.
14354dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius *
14454dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * <p>Ambiguous wall clock time resolution behaviors can be customized by Calendar APIs
14554dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * {@link #setRepeatedWallTimeOption} and {@link #setSkippedWallTimeOption}.
14654dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * These methods are available in ICU 49 or later versions.
14754dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius *
14854dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * <p>
149b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <strong>Note:</strong> for some non-Gregorian calendars, different
150b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * fields may be necessary for complete disambiguation. For example, a full
151b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * specification of the historial Arabic astronomical calendar requires year,
152b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * month, day-of-month <em>and</em> day-of-week in some cases.
153b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
154b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <p>
155b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <strong>Note:</strong> There are certain possible ambiguities in
156b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * interpretation of certain singular times, which are resolved in the
157b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * following ways:
158b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <ol>
159b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *     <li> 24:00:00 "belongs" to the following day. That is,
160b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *          23:59 on Dec 31, 1969 &lt; 24:00 on Jan 1, 1970 &lt; 24:01:00 on Jan 1, 1970
161b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
162b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *     <li> Although historically not precise, midnight also belongs to "am",
163b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *          and noon belongs to "pm", so on the same day,
164b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *          12:00 am (midnight) &lt; 12:01 am, and 12:00 pm (noon) &lt; 12:01 pm
165b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * </ol>
166b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
167b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <p>
168b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The date or time format strings are not part of the definition of a
169b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * calendar, as those must be modifiable or overridable by the user at
170b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * runtime. Use {@link DateFormat}
171b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * to format dates.
172b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
173b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <p>
174b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <code>Calendar</code> provides an API for field "rolling", where fields
175b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * can be incremented or decremented, but wrap around. For example, rolling the
176b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * month up in the date <code>December 12, <b>1996</b></code> results in
177b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <code>January 12, <b>1996</b></code>.
178b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
179b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <p>
180b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <code>Calendar</code> also provides a date arithmetic function for
181b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * adding the specified (signed) amount of time to a particular time field.
182b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * For example, subtracting 5 days from the date <code>September 12, 1996</code>
183b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * results in <code>September 7, 1996</code>.
184b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
18554dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * <p><big><b>Supported range</b></big>
18654dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius *
18754dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * <p>The allowable range of <code>Calendar</code> has been
18854dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * narrowed. <code>GregorianCalendar</code> used to attempt to support
18954dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * the range of dates with millisecond values from
19054dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * <code>Long.MIN_VALUE</code> to <code>Long.MAX_VALUE</code>.
19154dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * The new <code>Calendar</code> protocol specifies the
19254dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * maximum range of supportable dates as those having Julian day numbers
19354dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * of <code>-0x7F000000</code> to <code>+0x7F000000</code>. This
19454dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * corresponds to years from ~5,800,000 BCE to ~5,800,000 CE. Programmers
19554dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * should use the protected constants in <code>Calendar</code> to
19654dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * specify an extremely early or extremely late date.</p>
19754dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius *
198b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0
199b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
200b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruclass U_I18N_API Calendar : public UObject {
201b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querupublic:
202b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
203b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
204b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Field IDs for date and time. Used to specify date/time fields. ERA is calendar
205b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * specific. Example ranges given are for illustration only; see specific Calendar
206b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * subclasses for actual ranges.
207b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @deprecated ICU 2.6. Use C enum UCalendarDateFields defined in ucal.h
208b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
209b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    enum EDateFields {
210b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#ifndef U_HIDE_DEPRECATED_API
21150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho/*
21250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * ERA may be defined on other platforms. To avoid any potential problems undefined it here.
21350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho */
21450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#ifdef ERA
21550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#undef ERA
21650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#endif
217b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        ERA,                  // Example: 0..1
218b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        YEAR,                 // Example: 1..big number
219b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        MONTH,                // Example: 0..11
220b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        WEEK_OF_YEAR,         // Example: 1..53
221b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        WEEK_OF_MONTH,        // Example: 1..4
222b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        DATE,                 // Example: 1..31
223b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        DAY_OF_YEAR,          // Example: 1..365
224b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        DAY_OF_WEEK,          // Example: 1..7
225b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        DAY_OF_WEEK_IN_MONTH, // Example: 1..4, may be specified as -1
226b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        AM_PM,                // Example: 0..1
227b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        HOUR,                 // Example: 0..11
228b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        HOUR_OF_DAY,          // Example: 0..23
229b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        MINUTE,               // Example: 0..59
230b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        SECOND,               // Example: 0..59
231b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        MILLISECOND,          // Example: 0..999
232b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        ZONE_OFFSET,          // Example: -12*U_MILLIS_PER_HOUR..12*U_MILLIS_PER_HOUR
233b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        DST_OFFSET,           // Example: 0 or U_MILLIS_PER_HOUR
234b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        YEAR_WOY,             // 'Y' Example: 1..big number - Year of Week of Year
235b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        DOW_LOCAL,            // 'e' Example: 1..7 - Day of Week / Localized
23650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
23750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho        EXTENDED_YEAR,
23850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho        JULIAN_DAY,
23950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho        MILLISECONDS_IN_DAY,
24050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho        IS_LEAP_MONTH,
241b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
242b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        FIELD_COUNT = UCAL_FIELD_COUNT // See ucal.h for other fields.
243b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif /* U_HIDE_DEPRECATED_API */
244b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    };
245b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
246103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_HIDE_DEPRECATED_API
247b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
248b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Useful constant for days of week. Note: Calendar day-of-week is 1-based. Clients
249b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * who create locale resources for the field of first-day-of-week should be aware of
250b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * this. For instance, in US locale, first-day-of-week is set to 1, i.e., SUNDAY.
251b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @deprecated ICU 2.6. Use C enum UCalendarDaysOfWeek defined in ucal.h
252b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
253b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    enum EDaysOfWeek {
254b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        SUNDAY = 1,
255b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        MONDAY,
256b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        TUESDAY,
257b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        WEDNESDAY,
258b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        THURSDAY,
259b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        FRIDAY,
260b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        SATURDAY
261b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    };
262b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
263b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
264b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Useful constants for month. Note: Calendar month is 0-based.
265b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @deprecated ICU 2.6. Use C enum UCalendarMonths defined in ucal.h
266b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
267b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    enum EMonths {
268b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        JANUARY,
269b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        FEBRUARY,
270b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        MARCH,
271b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        APRIL,
272b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        MAY,
273b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        JUNE,
274b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        JULY,
275b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        AUGUST,
276b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        SEPTEMBER,
277b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        OCTOBER,
278b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        NOVEMBER,
279b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        DECEMBER,
280b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        UNDECIMBER
281b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    };
282b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
283b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
284b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Useful constants for hour in 12-hour clock. Used in GregorianCalendar.
285b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @deprecated ICU 2.6. Use C enum UCalendarAMPMs defined in ucal.h
286b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
287b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    enum EAmpm {
288b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        AM,
289b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        PM
290b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    };
291103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif  /* U_HIDE_DEPRECATED_API */
292b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
293b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
294b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * destructor
295b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
296b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
297b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual ~Calendar();
298b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
299b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
300b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Create and return a polymorphic copy of this calendar.
301b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
302b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return    a polymorphic copy of this calendar.
303b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
304b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
305b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual Calendar* clone(void) const = 0;
306b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
307b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
308b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Creates a Calendar using the default timezone and locale. Clients are responsible
309b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * for deleting the object returned.
310b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
311b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param success  Indicates the success/failure of Calendar creation. Filled in
312b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                 with U_ZERO_ERROR if created successfully, set to a failure result
313b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                 otherwise. U_MISSING_RESOURCE_ERROR will be returned if the resource data
314b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                 requests a calendar type which has not been installed.
315b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return         A Calendar if created successfully. NULL otherwise.
316b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
317b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
318b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    static Calendar* U_EXPORT2 createInstance(UErrorCode& success);
319b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
320b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
321b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Creates a Calendar using the given timezone and the default locale.
322b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * The Calendar takes ownership of zoneToAdopt; the
323b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * client must not delete it.
324b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
325b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param zoneToAdopt  The given timezone to be adopted.
326b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param success      Indicates the success/failure of Calendar creation. Filled in
327b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                     with U_ZERO_ERROR if created successfully, set to a failure result
328b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                     otherwise.
329b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return             A Calendar if created successfully. NULL otherwise.
330b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
331b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
332b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    static Calendar* U_EXPORT2 createInstance(TimeZone* zoneToAdopt, UErrorCode& success);
333b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
334b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
335b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Creates a Calendar using the given timezone and the default locale.  The TimeZone
336b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * is _not_ adopted; the client is still responsible for deleting it.
337b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
338b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param zone  The timezone.
339b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param success      Indicates the success/failure of Calendar creation. Filled in
340b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                     with U_ZERO_ERROR if created successfully, set to a failure result
341b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                     otherwise.
342b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return             A Calendar if created successfully. NULL otherwise.
343b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
344b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
345b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    static Calendar* U_EXPORT2 createInstance(const TimeZone& zone, UErrorCode& success);
346b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
347b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
348b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Creates a Calendar using the default timezone and the given locale.
349b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
350b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param aLocale  The given locale.
351b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param success  Indicates the success/failure of Calendar creation. Filled in
352b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                 with U_ZERO_ERROR if created successfully, set to a failure result
353b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                 otherwise.
354b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return         A Calendar if created successfully. NULL otherwise.
355b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
356b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
357b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    static Calendar* U_EXPORT2 createInstance(const Locale& aLocale, UErrorCode& success);
358b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
359b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
360b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Creates a Calendar using the given timezone and given locale.
361b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * The Calendar takes ownership of zoneToAdopt; the
362b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * client must not delete it.
363b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
364b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param zoneToAdopt  The given timezone to be adopted.
365b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param aLocale      The given locale.
366b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param success      Indicates the success/failure of Calendar creation. Filled in
367b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                     with U_ZERO_ERROR if created successfully, set to a failure result
368b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                     otherwise.
369b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return             A Calendar if created successfully. NULL otherwise.
370b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
371b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
372b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    static Calendar* U_EXPORT2 createInstance(TimeZone* zoneToAdopt, const Locale& aLocale, UErrorCode& success);
373b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
374b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
375b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Gets a Calendar using the given timezone and given locale.  The TimeZone
376b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * is _not_ adopted; the client is still responsible for deleting it.
377b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
37854dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * @param zone         The given timezone.
379b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param aLocale      The given locale.
380b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param success      Indicates the success/failure of Calendar creation. Filled in
381b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                     with U_ZERO_ERROR if created successfully, set to a failure result
382b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                     otherwise.
383b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return             A Calendar if created successfully. NULL otherwise.
384b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
385b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
38654dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius    static Calendar* U_EXPORT2 createInstance(const TimeZone& zone, const Locale& aLocale, UErrorCode& success);
387b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
388b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
389b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Returns a list of the locales for which Calendars are installed.
390b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
391b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param count  Number of locales returned.
392b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return       An array of Locale objects representing the set of locales for which
393b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *               Calendars are installed.  The system retains ownership of this list;
394b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *               the caller must NOT delete it. Does not include user-registered Calendars.
395b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
396b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
397b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
398b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
399b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru
400b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru    /**
401b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru     * Given a key and a locale, returns an array of string values in a preferred
402b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru     * order that would make a difference. These are all and only those values where
403b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru     * the open (creation) of the service with the locale formed from the input locale
404b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru     * plus input keyword and that value has different behavior than creation with the
405b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru     * input locale alone.
406b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru     * @param key           one of the keys supported by this service.  For now, only
407b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru     *                      "calendar" is supported.
408b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru     * @param locale        the locale
409b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru     * @param commonlyUsed  if set to true it will return only commonly used values
410b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru     *                      with the given locale in preferred order.  Otherwise,
411b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru     *                      it will return all the available values for the locale.
412b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru     * @param status        ICU Error Code
413b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru     * @return a string enumeration over keyword values for the given key and the locale.
41450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * @stable ICU 4.2
415b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru     */
416b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru    static StringEnumeration* U_EXPORT2 getKeywordValuesForLocale(const char* key,
417b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru                    const Locale& locale, UBool commonlyUsed, UErrorCode& status);
418b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru
419b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
420b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Returns the current UTC (GMT) time measured in milliseconds since 0:00:00 on 1/1/70
421b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * (derived from the system time).
422b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
423b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return   The current UTC time in milliseconds.
424b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
425b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
426b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    static UDate U_EXPORT2 getNow(void);
427b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
428b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
429b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Gets this Calendar's time as milliseconds. May involve recalculation of time due
430b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * to previous calls to set time field values. The time specified is non-local UTC
431b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * (GMT) time. Although this method is const, this object may actually be changed
432b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * (semantically const).
433b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
434b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status  Output param set to success/failure code on exit. If any value
435b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                previously set in the time field is invalid or restricted by
436b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                leniency, this will be set to an error status.
437b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return        The current time in UTC (GMT) time, or zero if the operation
438b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                failed.
439b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
440b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
441b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    inline UDate getTime(UErrorCode& status) const { return getTimeInMillis(status); }
442b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
443b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
444b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Sets this Calendar's current time with the given UDate. The time specified should
445b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * be in non-local UTC (GMT) time.
446b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
447b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param date  The given UDate in UTC (GMT) time.
448b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status  Output param set to success/failure code on exit. If any value
449b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                set in the time field is invalid or restricted by
450b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                leniency, this will be set to an error status.
451b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
452b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
453b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    inline void setTime(UDate date, UErrorCode& status) { setTimeInMillis(date, status); }
454b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
455b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
456b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Compares the equality of two Calendar objects. Objects of different subclasses
457b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * are considered unequal. This comparison is very exacting; two Calendar objects
458b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * must be in exactly the same state to be considered equal. To compare based on the
459b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * represented time, use equals() instead.
460b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
461b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param that  The Calendar object to be compared with.
462b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return      True if the given Calendar is the same as this Calendar; false
463b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *              otherwise.
464b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
465b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
466b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual UBool operator==(const Calendar& that) const;
467b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
468b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
469b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Compares the inequality of two Calendar objects.
470b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
471b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param that  The Calendar object to be compared with.
472b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return      True if the given Calendar is not the same as this Calendar; false
473b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *              otherwise.
474b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
475b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
476b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool operator!=(const Calendar& that) const {return !operator==(that);}
477b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
478b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
479b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Returns TRUE if the given Calendar object is equivalent to this
480b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * one.  An equivalent Calendar will behave exactly as this one
481b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * does, but it may be set to a different time.  By contrast, for
482b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * the operator==() method to return TRUE, the other Calendar must
483b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * be set to the same time.
484b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
485b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param other the Calendar to be compared with this Calendar
486b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.4
487b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
488b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual UBool isEquivalentTo(const Calendar& other) const;
489b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
490b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
491b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Compares the Calendar time, whereas Calendar::operator== compares the equality of
492b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Calendar objects.
493b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
494b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param when    The Calendar to be compared with this Calendar. Although this is a
495b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                const parameter, the object may be modified physically
496b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                (semantically const).
497b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status  Output param set to success/failure code on exit. If any value
498b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                previously set in the time field is invalid or restricted by
499b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                leniency, this will be set to an error status.
500b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return        True if the current time of this Calendar is equal to the time of
501b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                Calendar when; false otherwise.
502b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
503b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
504b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool equals(const Calendar& when, UErrorCode& status) const;
505b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
506b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
507b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Returns true if this Calendar's current time is before "when"'s current time.
508b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
509b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param when    The Calendar to be compared with this Calendar. Although this is a
510b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                const parameter, the object may be modified physically
511b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                (semantically const).
512b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status  Output param set to success/failure code on exit. If any value
513b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                previously set in the time field is invalid or restricted by
514b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                leniency, this will be set to an error status.
515b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return        True if the current time of this Calendar is before the time of
516b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                Calendar when; false otherwise.
517b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
518b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
519b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool before(const Calendar& when, UErrorCode& status) const;
520b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
521b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
522b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Returns true if this Calendar's current time is after "when"'s current time.
523b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
524b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param when    The Calendar to be compared with this Calendar. Although this is a
525b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                const parameter, the object may be modified physically
526b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                (semantically const).
527b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status  Output param set to success/failure code on exit. If any value
528b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                previously set in the time field is invalid or restricted by
529b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                leniency, this will be set to an error status.
530b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return        True if the current time of this Calendar is after the time of
531b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                Calendar when; false otherwise.
532b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
533b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
534b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool after(const Calendar& when, UErrorCode& status) const;
535b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
536b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
537b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * UDate Arithmetic function. Adds the specified (signed) amount of time to the given
538b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * time field, based on the calendar's rules. For example, to subtract 5 days from
539b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * the current time of the calendar, call add(Calendar::DATE, -5). When adding on
540b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * the month or Calendar::MONTH field, other fields like date might conflict and
541b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * need to be changed. For instance, adding 1 month on the date 01/31/96 will result
542b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * in 02/29/96.
54354dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * Adding a positive value always means moving forward in time, so for the Gregorian calendar,
54454dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * starting with 100 BC and adding +1 to year results in 99 BC (even though this actually reduces
54554dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * the numeric value of the field itself).
546b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
547b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param field   Specifies which date field to modify.
548b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param amount  The amount of time to be added to the field, in the natural unit
549b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                for that field (e.g., days for the day fields, hours for the hour
550b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                field.)
551b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status  Output param set to success/failure code on exit. If any value
552b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                previously set in the time field is invalid or restricted by
553b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                leniency, this will be set to an error status.
554b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @deprecated ICU 2.6. use add(UCalendarDateFields field, int32_t amount, UErrorCode& status) instead.
555b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
556b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual void add(EDateFields field, int32_t amount, UErrorCode& status);
557b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
558b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
559b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * UDate Arithmetic function. Adds the specified (signed) amount of time to the given
560b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * time field, based on the calendar's rules. For example, to subtract 5 days from
561b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * the current time of the calendar, call add(Calendar::DATE, -5). When adding on
562b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * the month or Calendar::MONTH field, other fields like date might conflict and
563b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * need to be changed. For instance, adding 1 month on the date 01/31/96 will result
564b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * in 02/29/96.
56554dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * Adding a positive value always means moving forward in time, so for the Gregorian calendar,
56654dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * starting with 100 BC and adding +1 to year results in 99 BC (even though this actually reduces
56754dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * the numeric value of the field itself).
568b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
569b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param field   Specifies which date field to modify.
570b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param amount  The amount of time to be added to the field, in the natural unit
571b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                for that field (e.g., days for the day fields, hours for the hour
572b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                field.)
573b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status  Output param set to success/failure code on exit. If any value
574b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                previously set in the time field is invalid or restricted by
575b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                leniency, this will be set to an error status.
576b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.6.
577b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
578b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual void add(UCalendarDateFields field, int32_t amount, UErrorCode& status);
579b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
580103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_HIDE_DEPRECATED_API
581b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
582b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Time Field Rolling function. Rolls (up/down) a single unit of time on the given
583b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * time field. For example, to roll the current date up by one day, call
584b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * roll(Calendar::DATE, true). When rolling on the year or Calendar::YEAR field, it
585b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * will roll the year value in the range between getMinimum(Calendar::YEAR) and the
586b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * value returned by getMaximum(Calendar::YEAR). When rolling on the month or
587b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Calendar::MONTH field, other fields like date might conflict and, need to be
588b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * changed. For instance, rolling the month up on the date 01/31/96 will result in
58954dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * 02/29/96. Rolling up always means rolling forward in time (unless the limit of the
59054dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * field is reached, in which case it may pin or wrap), so for Gregorian calendar,
59154dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * starting with 100 BC and rolling the year up results in 99 BC.
59254dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * When eras have a definite beginning and end (as in the Chinese calendar, or as in
59354dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * most eras in the Japanese calendar) then rolling the year past either limit of the
59454dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * era will cause the year to wrap around. When eras only have a limit at one end,
59554dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * then attempting to roll the year past that limit will result in pinning the year
59654dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * at that limit. Note that for most calendars in which era 0 years move forward in
59754dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * time (such as Buddhist, Hebrew, or Islamic), it is possible for add or roll to
59854dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * result in negative years for era 0 (that is the only way to represent years before
59954dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * the calendar epoch).
60054dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * When rolling on the hour-in-day or Calendar::HOUR_OF_DAY field, it will roll the
60154dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * hour value in the range between 0 and 23, which is zero-based.
602b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <P>
603b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * NOTE: Do not use this method -- use roll(EDateFields, int, UErrorCode&) instead.
604b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
605b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param field   The time field.
606b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param up      Indicates if the value of the specified time field is to be rolled
607b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                up or rolled down. Use true if rolling up, false otherwise.
608b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status  Output param set to success/failure code on exit. If any value
609b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                previously set in the time field is invalid or restricted by
610b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                leniency, this will be set to an error status.
611b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @deprecated ICU 2.6. Use roll(UCalendarDateFields field, UBool up, UErrorCode& status) instead.
612b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
613b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    inline void roll(EDateFields field, UBool up, UErrorCode& status);
614103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif  /* U_HIDE_DEPRECATED_API */
615b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
616b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
617b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Time Field Rolling function. Rolls (up/down) a single unit of time on the given
618b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * time field. For example, to roll the current date up by one day, call
619b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * roll(Calendar::DATE, true). When rolling on the year or Calendar::YEAR field, it
620b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * will roll the year value in the range between getMinimum(Calendar::YEAR) and the
621b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * value returned by getMaximum(Calendar::YEAR). When rolling on the month or
622b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Calendar::MONTH field, other fields like date might conflict and, need to be
623b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * changed. For instance, rolling the month up on the date 01/31/96 will result in
62454dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * 02/29/96. Rolling up always means rolling forward in time (unless the limit of the
62554dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * field is reached, in which case it may pin or wrap), so for Gregorian calendar,
62654dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * starting with 100 BC and rolling the year up results in 99 BC.
62754dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * When eras have a definite beginning and end (as in the Chinese calendar, or as in
62854dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * most eras in the Japanese calendar) then rolling the year past either limit of the
62954dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * era will cause the year to wrap around. When eras only have a limit at one end,
63054dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * then attempting to roll the year past that limit will result in pinning the year
63154dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * at that limit. Note that for most calendars in which era 0 years move forward in
63254dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * time (such as Buddhist, Hebrew, or Islamic), it is possible for add or roll to
63354dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * result in negative years for era 0 (that is the only way to represent years before
63454dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * the calendar epoch).
63554dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * When rolling on the hour-in-day or Calendar::HOUR_OF_DAY field, it will roll the
63654dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * hour value in the range between 0 and 23, which is zero-based.
637b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <P>
638b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * NOTE: Do not use this method -- use roll(UCalendarDateFields, int, UErrorCode&) instead.
639b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
640b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param field   The time field.
641b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param up      Indicates if the value of the specified time field is to be rolled
642b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                up or rolled down. Use true if rolling up, false otherwise.
643b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status  Output param set to success/failure code on exit. If any value
644b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                previously set in the time field is invalid or restricted by
645b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                leniency, this will be set to an error status.
646b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.6.
647b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
648b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    inline void roll(UCalendarDateFields field, UBool up, UErrorCode& status);
649b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
650b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
651b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Time Field Rolling function. Rolls by the given amount on the given
652b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * time field. For example, to roll the current date up by one day, call
653b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * roll(Calendar::DATE, +1, status). When rolling on the month or
654b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Calendar::MONTH field, other fields like date might conflict and, need to be
655b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * changed. For instance, rolling the month up on the date 01/31/96 will result in
65654dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * 02/29/96. Rolling by a positive value always means rolling forward in time (unless
65754dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * the limit of the field is reached, in which case it may pin or wrap), so for
65854dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * Gregorian calendar, starting with 100 BC and rolling the year by + 1 results in 99 BC.
65954dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * When eras have a definite beginning and end (as in the Chinese calendar, or as in
66054dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * most eras in the Japanese calendar) then rolling the year past either limit of the
66154dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * era will cause the year to wrap around. When eras only have a limit at one end,
66254dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * then attempting to roll the year past that limit will result in pinning the year
66354dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * at that limit. Note that for most calendars in which era 0 years move forward in
66454dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * time (such as Buddhist, Hebrew, or Islamic), it is possible for add or roll to
66554dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * result in negative years for era 0 (that is the only way to represent years before
66654dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * the calendar epoch).
66754dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * When rolling on the hour-in-day or Calendar::HOUR_OF_DAY field, it will roll the
66854dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * hour value in the range between 0 and 23, which is zero-based.
669b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <P>
670b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * The only difference between roll() and add() is that roll() does not change
671b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * the value of more significant fields when it reaches the minimum or maximum
672b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * of its range, whereas add() does.
673b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
674b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param field   The time field.
675b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param amount  Indicates amount to roll.
676b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status  Output param set to success/failure code on exit. If any value
677b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                previously set in the time field is invalid, this will be set to
678b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                an error status.
679b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @deprecated ICU 2.6. Use roll(UCalendarDateFields field, int32_t amount, UErrorCode& status) instead.
680b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
681b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual void roll(EDateFields field, int32_t amount, UErrorCode& status);
682b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
683b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
684b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Time Field Rolling function. Rolls by the given amount on the given
685b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * time field. For example, to roll the current date up by one day, call
686b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * roll(Calendar::DATE, +1, status). When rolling on the month or
687b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Calendar::MONTH field, other fields like date might conflict and, need to be
688b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * changed. For instance, rolling the month up on the date 01/31/96 will result in
68954dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * 02/29/96. Rolling by a positive value always means rolling forward in time (unless
69054dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * the limit of the field is reached, in which case it may pin or wrap), so for
69154dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * Gregorian calendar, starting with 100 BC and rolling the year by + 1 results in 99 BC.
69254dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * When eras have a definite beginning and end (as in the Chinese calendar, or as in
69354dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * most eras in the Japanese calendar) then rolling the year past either limit of the
69454dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * era will cause the year to wrap around. When eras only have a limit at one end,
69554dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * then attempting to roll the year past that limit will result in pinning the year
69654dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * at that limit. Note that for most calendars in which era 0 years move forward in
69754dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * time (such as Buddhist, Hebrew, or Islamic), it is possible for add or roll to
69854dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * result in negative years for era 0 (that is the only way to represent years before
69954dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * the calendar epoch).
70054dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * When rolling on the hour-in-day or Calendar::HOUR_OF_DAY field, it will roll the
70154dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius     * hour value in the range between 0 and 23, which is zero-based.
702b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <P>
703b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * The only difference between roll() and add() is that roll() does not change
704b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * the value of more significant fields when it reaches the minimum or maximum
705b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * of its range, whereas add() does.
706b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
707b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param field   The time field.
708b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param amount  Indicates amount to roll.
709b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status  Output param set to success/failure code on exit. If any value
710b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                previously set in the time field is invalid, this will be set to
711b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                an error status.
712b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.6.
713b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
714b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual void roll(UCalendarDateFields field, int32_t amount, UErrorCode& status);
715b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
716b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
717b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Return the difference between the given time and the time this
718b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * calendar object is set to.  If this calendar is set
719b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <em>before</em> the given time, the returned value will be
720b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * positive.  If this calendar is set <em>after</em> the given
721b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * time, the returned value will be negative.  The
722b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <code>field</code> parameter specifies the units of the return
723b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * value.  For example, if <code>fieldDifference(when,
724b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Calendar::MONTH)</code> returns 3, then this calendar is set to
725b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * 3 months before <code>when</code>, and possibly some addition
726b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * time less than one month.
727b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
728b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <p>As a side effect of this call, this calendar is advanced
729b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * toward <code>when</code> by the given amount.  That is, calling
730b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * this method has the side effect of calling <code>add(field,
731b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * n)</code>, where <code>n</code> is the return value.
732b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
733b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <p>Usage: To use this method, call it first with the largest
734b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * field of interest, then with progressively smaller fields.  For
735b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * example:
736b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
737b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <pre>
738b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * int y = cal->fieldDifference(when, Calendar::YEAR, err);
739b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * int m = cal->fieldDifference(when, Calendar::MONTH, err);
740b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * int d = cal->fieldDifference(when, Calendar::DATE, err);</pre>
741b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
742b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * computes the difference between <code>cal</code> and
743b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <code>when</code> in years, months, and days.
744b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
745b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <p>Note: <code>fieldDifference()</code> is
746b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <em>asymmetrical</em>.  That is, in the following code:
747b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
748b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <pre>
749b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * cal->setTime(date1, err);
750b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * int m1 = cal->fieldDifference(date2, Calendar::MONTH, err);
751b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * int d1 = cal->fieldDifference(date2, Calendar::DATE, err);
752b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * cal->setTime(date2, err);
753b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * int m2 = cal->fieldDifference(date1, Calendar::MONTH, err);
754b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * int d2 = cal->fieldDifference(date1, Calendar::DATE, err);</pre>
755b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
756b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * one might expect that <code>m1 == -m2 && d1 == -d2</code>.
757b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * However, this is not generally the case, because of
758b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * irregularities in the underlying calendar system (e.g., the
759b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Gregorian calendar has a varying number of days per month).
760b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
761b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param when the date to compare this calendar's time to
762b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param field the field in which to compute the result
763b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status  Output param set to success/failure code on exit. If any value
764b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                previously set in the time field is invalid, this will be set to
765b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                an error status.
766b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return the difference, either positive or negative, between
767b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * this calendar's time and <code>when</code>, in terms of
768b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <code>field</code>.
769b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @deprecated ICU 2.6. Use fieldDifference(UDate when, UCalendarDateFields field, UErrorCode& status).
770b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
771b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual int32_t fieldDifference(UDate when, EDateFields field, UErrorCode& status);
772b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
773b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
774b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Return the difference between the given time and the time this
775b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * calendar object is set to.  If this calendar is set
776b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <em>before</em> the given time, the returned value will be
777b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * positive.  If this calendar is set <em>after</em> the given
778b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * time, the returned value will be negative.  The
779b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <code>field</code> parameter specifies the units of the return
780b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * value.  For example, if <code>fieldDifference(when,
781b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Calendar::MONTH)</code> returns 3, then this calendar is set to
782b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * 3 months before <code>when</code>, and possibly some addition
783b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * time less than one month.
784b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
785b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <p>As a side effect of this call, this calendar is advanced
786b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * toward <code>when</code> by the given amount.  That is, calling
787b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * this method has the side effect of calling <code>add(field,
788b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * n)</code>, where <code>n</code> is the return value.
789b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
790b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <p>Usage: To use this method, call it first with the largest
791b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * field of interest, then with progressively smaller fields.  For
792b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * example:
793b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
794b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <pre>
795b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * int y = cal->fieldDifference(when, Calendar::YEAR, err);
796b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * int m = cal->fieldDifference(when, Calendar::MONTH, err);
797b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * int d = cal->fieldDifference(when, Calendar::DATE, err);</pre>
798b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
799b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * computes the difference between <code>cal</code> and
800b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <code>when</code> in years, months, and days.
801b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
802b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <p>Note: <code>fieldDifference()</code> is
803b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <em>asymmetrical</em>.  That is, in the following code:
804b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
805b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <pre>
806b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * cal->setTime(date1, err);
807b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * int m1 = cal->fieldDifference(date2, Calendar::MONTH, err);
808b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * int d1 = cal->fieldDifference(date2, Calendar::DATE, err);
809b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * cal->setTime(date2, err);
810b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * int m2 = cal->fieldDifference(date1, Calendar::MONTH, err);
811b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * int d2 = cal->fieldDifference(date1, Calendar::DATE, err);</pre>
812b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
813b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * one might expect that <code>m1 == -m2 && d1 == -d2</code>.
814b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * However, this is not generally the case, because of
815b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * irregularities in the underlying calendar system (e.g., the
816b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Gregorian calendar has a varying number of days per month).
817b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
818b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param when the date to compare this calendar's time to
819b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param field the field in which to compute the result
820b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status  Output param set to success/failure code on exit. If any value
821b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                previously set in the time field is invalid, this will be set to
822b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                an error status.
823b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return the difference, either positive or negative, between
824b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * this calendar's time and <code>when</code>, in terms of
825b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <code>field</code>.
826b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.6.
827b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
828b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual int32_t fieldDifference(UDate when, UCalendarDateFields field, UErrorCode& status);
829b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
830b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
831b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Sets the calendar's time zone to be the one passed in. The Calendar takes ownership
832b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * of the TimeZone; the caller is no longer responsible for deleting it.  If the
833b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * given time zone is NULL, this function has no effect.
834b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
835b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param value  The given time zone.
836b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
837b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
838b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void adoptTimeZone(TimeZone* value);
839b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
840b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
841b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Sets the calendar's time zone to be the same as the one passed in. The TimeZone
842b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * passed in is _not_ adopted; the client is still responsible for deleting it.
843b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
844b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param zone  The given time zone.
845b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
846b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
847b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void setTimeZone(const TimeZone& zone);
848b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
849b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
850b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Returns a reference to the time zone owned by this calendar. The returned reference
851b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * is only valid until clients make another call to adoptTimeZone or setTimeZone,
852b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * or this Calendar is destroyed.
853b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
854b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return   The time zone object associated with this calendar.
855b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
856b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
857b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    const TimeZone& getTimeZone(void) const;
858b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
859b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
860b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Returns the time zone owned by this calendar. The caller owns the returned object
861b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * and must delete it when done.  After this call, the new time zone associated
862b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * with this Calendar is the default TimeZone as returned by TimeZone::createDefault().
863b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
864b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return   The time zone object which was associated with this calendar.
865b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
866b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
867b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TimeZone* orphanTimeZone(void);
868b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
869b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
870b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Queries if the current date for this Calendar is in Daylight Savings Time.
871b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
872b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status Fill-in parameter which receives the status of this operation.
873b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return   True if the current date for this Calendar is in Daylight Savings Time,
874b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *           false, otherwise.
875b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
876b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
877b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual UBool inDaylightTime(UErrorCode& status) const = 0;
878b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
879b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
880b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Specifies whether or not date/time interpretation is to be lenient. With lenient
881b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * interpretation, a date such as "February 942, 1996" will be treated as being
882b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * equivalent to the 941st day after February 1, 1996. With strict interpretation,
883b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * such dates will cause an error when computing time from the time field values
884b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * representing the dates.
885b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
886b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param lenient  True specifies date/time interpretation to be lenient.
887b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
888b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @see            DateFormat#setLenient
889b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
890b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
891b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void setLenient(UBool lenient);
892b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
893b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
894b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Tells whether date/time interpretation is to be lenient.
895b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
896b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return   True tells that date/time interpretation is to be lenient.
897b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
898b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
899b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool isLenient(void) const;
900b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
901103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius    /**
902103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * Sets the behavior for handling wall time repeating multiple times
903103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * at negative time zone offset transitions. For example, 1:30 AM on
904103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * November 6, 2011 in US Eastern time (Ameirca/New_York) occurs twice;
905103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * 1:30 AM EDT, then 1:30 AM EST one hour later. When <code>UCAL_WALLTIME_FIRST</code>
906103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * is used, the wall time 1:30AM in this example will be interpreted as 1:30 AM EDT
907103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * (first occurrence). When <code>UCAL_WALLTIME_LAST</code> is used, it will be
908103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * interpreted as 1:30 AM EST (last occurrence). The default value is
909103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * <code>UCAL_WALLTIME_LAST</code>.
910103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * <p>
911103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * <b>Note:</b>When <code>UCAL_WALLTIME_NEXT_VALID</code> is not a valid
912103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * option for this. When the argument is neither <code>UCAL_WALLTIME_FIRST</code>
913103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * nor <code>UCAL_WALLTIME_LAST</code>, this method has no effect and will keep
914103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * the current setting.
915103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     *
916103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * @param option the behavior for handling repeating wall time, either
917103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * <code>UCAL_WALLTIME_FIRST</code> or <code>UCAL_WALLTIME_LAST</code>.
918103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * @see #getRepeatedWallTimeOption
9198393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius     * @stable ICU 49
920103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     */
921103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius    void setRepeatedWallTimeOption(UCalendarWallTimeOption option);
922103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius
923103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius    /**
924103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * Gets the behavior for handling wall time repeating multiple times
925103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * at negative time zone offset transitions.
926103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     *
927103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * @return the behavior for handling repeating wall time, either
928103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * <code>UCAL_WALLTIME_FIRST</code> or <code>UCAL_WALLTIME_LAST</code>.
929103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * @see #setRepeatedWallTimeOption
9308393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius     * @stable ICU 49
931103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     */
932103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius    UCalendarWallTimeOption getRepeatedWallTimeOption(void) const;
933103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius
934103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius    /**
935103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * Sets the behavior for handling skipped wall time at positive time zone offset
936103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * transitions. For example, 2:30 AM on March 13, 2011 in US Eastern time (America/New_York)
937103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * does not exist because the wall time jump from 1:59 AM EST to 3:00 AM EDT. When
938103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * <code>UCAL_WALLTIME_FIRST</code> is used, 2:30 AM is interpreted as 30 minutes before 3:00 AM
939103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * EDT, therefore, it will be resolved as 1:30 AM EST. When <code>UCAL_WALLTIME_LAST</code>
940103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * is used, 2:30 AM is interpreted as 31 minutes after 1:59 AM EST, therefore, it will be
941103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * resolved as 3:30 AM EDT. When <code>UCAL_WALLTIME_NEXT_VALID</code> is used, 2:30 AM will
942103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * be resolved as next valid wall time, that is 3:00 AM EDT. The default value is
943103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * <code>UCAL_WALLTIME_LAST</code>.
944103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * <p>
945103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * <b>Note:</b>This option is effective only when this calendar is lenient.
946103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * When the calendar is strict, such non-existing wall time will cause an error.
947103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     *
948103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * @param option the behavior for handling skipped wall time at positive time zone
949103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * offset transitions, one of <code>UCAL_WALLTIME_FIRST</code>, <code>UCAL_WALLTIME_LAST</code> and
950103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * <code>UCAL_WALLTIME_NEXT_VALID</code>.
951103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * @see #getSkippedWallTimeOption
952103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     *
9538393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius     * @stable ICU 49
954103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     */
955103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius    void setSkippedWallTimeOption(UCalendarWallTimeOption option);
956103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius
957103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius    /**
958103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * Gets the behavior for handling skipped wall time at positive time zone offset
959103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * transitions.
960103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     *
961103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * @return the behavior for handling skipped wall time, one of
962103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * <code>UCAL_WALLTIME_FIRST</code>, <code>UCAL_WALLTIME_LAST</code>
963103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * and <code>UCAL_WALLTIME_NEXT_VALID</code>.
964103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * @see #setSkippedWallTimeOption
9658393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius     * @stable ICU 49
966103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     */
967103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius    UCalendarWallTimeOption getSkippedWallTimeOption(void) const;
968103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius
969103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_HIDE_DEPRECATED_API
970b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
971b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Sets what the first day of the week is; e.g., Sunday in US, Monday in France.
972b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
973b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param value  The given first day of the week.
974b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @deprecated ICU 2.6. Use setFirstDayOfWeek(UCalendarDaysOfWeek value) instead.
975b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
976b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void setFirstDayOfWeek(EDaysOfWeek value);
977103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif  /* U_HIDE_DEPRECATED_API */
978b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
979b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
980b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Sets what the first day of the week is; e.g., Sunday in US, Monday in France.
981b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
982b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param value  The given first day of the week.
983b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.6.
984b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
985b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void setFirstDayOfWeek(UCalendarDaysOfWeek value);
986b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
987103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_HIDE_DEPRECATED_API
988b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
989b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Gets what the first day of the week is; e.g., Sunday in US, Monday in France.
990b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
991b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return   The first day of the week.
992b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @deprecated ICU 2.6 use the overload with error code
993b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
994b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    EDaysOfWeek getFirstDayOfWeek(void) const;
995103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif  /* U_HIDE_DEPRECATED_API */
996b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
997b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
998b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Gets what the first day of the week is; e.g., Sunday in US, Monday in France.
999b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1000b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status error code
1001b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return   The first day of the week.
1002b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.6
1003b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1004b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UCalendarDaysOfWeek getFirstDayOfWeek(UErrorCode &status) const;
1005b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1006b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1007b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Sets what the minimal days required in the first week of the year are; For
1008b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * example, if the first week is defined as one that contains the first day of the
1009b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * first month of a year, call the method with value 1. If it must be a full week,
1010b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * use value 7.
1011b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1012b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param value  The given minimal days required in the first week of the year.
1013b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
1014b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1015b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void setMinimalDaysInFirstWeek(uint8_t value);
1016b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1017b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1018b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Gets what the minimal days required in the first week of the year are; e.g., if
1019b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * the first week is defined as one that contains the first day of the first month
1020b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * of a year, getMinimalDaysInFirstWeek returns 1. If the minimal days required must
1021b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * be a full week, getMinimalDaysInFirstWeek returns 7.
1022b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1023b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return   The minimal days required in the first week of the year.
1024b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
1025b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1026b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    uint8_t getMinimalDaysInFirstWeek(void) const;
1027b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1028b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1029b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Gets the minimum value for the given time field. e.g., for Gregorian
1030b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * DAY_OF_MONTH, 1.
1031b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1032b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param field  The given time field.
1033b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return       The minimum value for the given time field.
1034b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @deprecated ICU 2.6. Use getMinimum(UCalendarDateFields field) instead.
1035b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1036b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual int32_t getMinimum(EDateFields field) const;
1037b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1038b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1039b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Gets the minimum value for the given time field. e.g., for Gregorian
1040b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * DAY_OF_MONTH, 1.
1041b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1042b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param field  The given time field.
1043b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return       The minimum value for the given time field.
1044b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.6.
1045b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1046b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual int32_t getMinimum(UCalendarDateFields field) const;
1047b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1048b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1049b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Gets the maximum value for the given time field. e.g. for Gregorian DAY_OF_MONTH,
1050b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * 31.
1051b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1052b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param field  The given time field.
1053b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return       The maximum value for the given time field.
1054b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @deprecated ICU 2.6. Use getMaximum(UCalendarDateFields field) instead.
1055b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1056b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual int32_t getMaximum(EDateFields field) const;
1057b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1058b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1059b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Gets the maximum value for the given time field. e.g. for Gregorian DAY_OF_MONTH,
1060b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * 31.
1061b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1062b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param field  The given time field.
1063b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return       The maximum value for the given time field.
1064b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.6.
1065b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1066b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual int32_t getMaximum(UCalendarDateFields field) const;
1067b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1068b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1069b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Gets the highest minimum value for the given field if varies. Otherwise same as
1070b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * getMinimum(). For Gregorian, no difference.
1071b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1072b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param field  The given time field.
1073b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return       The highest minimum value for the given time field.
1074b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @deprecated ICU 2.6. Use getGreatestMinimum(UCalendarDateFields field) instead.
1075b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1076b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual int32_t getGreatestMinimum(EDateFields field) const;
1077b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1078b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1079b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Gets the highest minimum value for the given field if varies. Otherwise same as
1080b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * getMinimum(). For Gregorian, no difference.
1081b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1082b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param field  The given time field.
1083b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return       The highest minimum value for the given time field.
1084b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.6.
1085b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1086b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual int32_t getGreatestMinimum(UCalendarDateFields field) const;
1087b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1088b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1089b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Gets the lowest maximum value for the given field if varies. Otherwise same as
1090b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * getMaximum(). e.g., for Gregorian DAY_OF_MONTH, 28.
1091b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1092b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param field  The given time field.
1093b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return       The lowest maximum value for the given time field.
1094b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @deprecated ICU 2.6. Use getLeastMaximum(UCalendarDateFields field) instead.
1095b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1096b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual int32_t getLeastMaximum(EDateFields field) const;
1097b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1098b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1099b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Gets the lowest maximum value for the given field if varies. Otherwise same as
1100b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * getMaximum(). e.g., for Gregorian DAY_OF_MONTH, 28.
1101b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1102b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param field  The given time field.
1103b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return       The lowest maximum value for the given time field.
1104b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.6.
1105b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1106b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual int32_t getLeastMaximum(UCalendarDateFields field) const;
1107b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1108103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_HIDE_DEPRECATED_API
1109b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1110b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Return the minimum value that this field could have, given the current date.
1111b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * For the Gregorian calendar, this is the same as getMinimum() and getGreatestMinimum().
1112b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1113b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * The version of this function on Calendar uses an iterative algorithm to determine the
1114b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * actual minimum value for the field.  There is almost always a more efficient way to
1115b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * accomplish this (in most cases, you can simply return getMinimum()).  GregorianCalendar
1116b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * overrides this function with a more efficient implementation.
1117b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1118b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param field    the field to determine the minimum of
1119b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status   Fill-in parameter which receives the status of this operation.
1120b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return         the minimum of the given field for the current date of this Calendar
1121b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @deprecated ICU 2.6. Use getActualMinimum(UCalendarDateFields field, UErrorCode& status) instead.
1122b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1123b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t getActualMinimum(EDateFields field, UErrorCode& status) const;
1124103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif  /* U_HIDE_DEPRECATED_API */
1125b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1126b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1127b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Return the minimum value that this field could have, given the current date.
1128b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * For the Gregorian calendar, this is the same as getMinimum() and getGreatestMinimum().
1129b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1130b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * The version of this function on Calendar uses an iterative algorithm to determine the
1131b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * actual minimum value for the field.  There is almost always a more efficient way to
1132b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * accomplish this (in most cases, you can simply return getMinimum()).  GregorianCalendar
1133b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * overrides this function with a more efficient implementation.
1134b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1135b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param field    the field to determine the minimum of
1136b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status   Fill-in parameter which receives the status of this operation.
1137b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return         the minimum of the given field for the current date of this Calendar
1138b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.6.
1139b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1140c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    virtual int32_t getActualMinimum(UCalendarDateFields field, UErrorCode& status) const;
1141b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1142103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_HIDE_DEPRECATED_API
1143b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1144b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Return the maximum value that this field could have, given the current date.
1145b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * For example, with the date "Feb 3, 1997" and the DAY_OF_MONTH field, the actual
1146b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * maximum would be 28; for "Feb 3, 1996" it s 29.  Similarly for a Hebrew calendar,
1147b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * for some years the actual maximum for MONTH is 12, and for others 13.
1148b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1149b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * The version of this function on Calendar uses an iterative algorithm to determine the
1150b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * actual maximum value for the field.  There is almost always a more efficient way to
1151b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * accomplish this (in most cases, you can simply return getMaximum()).  GregorianCalendar
1152b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * overrides this function with a more efficient implementation.
1153b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1154b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param field    the field to determine the maximum of
1155b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status   Fill-in parameter which receives the status of this operation.
1156b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return         the maximum of the given field for the current date of this Calendar
1157b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @deprecated ICU 2.6. Use getActualMaximum(UCalendarDateFields field, UErrorCode& status) instead.
1158b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1159b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t getActualMaximum(EDateFields field, UErrorCode& status) const;
1160103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif  /* U_HIDE_DEPRECATED_API */
1161b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1162b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1163b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Return the maximum value that this field could have, given the current date.
1164b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * For example, with the date "Feb 3, 1997" and the DAY_OF_MONTH field, the actual
1165b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * maximum would be 28; for "Feb 3, 1996" it s 29.  Similarly for a Hebrew calendar,
1166b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * for some years the actual maximum for MONTH is 12, and for others 13.
1167b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1168b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * The version of this function on Calendar uses an iterative algorithm to determine the
1169b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * actual maximum value for the field.  There is almost always a more efficient way to
1170b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * accomplish this (in most cases, you can simply return getMaximum()).  GregorianCalendar
1171b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * overrides this function with a more efficient implementation.
1172b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1173b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param field    the field to determine the maximum of
1174b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status   Fill-in parameter which receives the status of this operation.
1175b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return         the maximum of the given field for the current date of this Calendar
1176b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.6.
1177b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1178c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    virtual int32_t getActualMaximum(UCalendarDateFields field, UErrorCode& status) const;
1179b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1180103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_HIDE_DEPRECATED_API
1181b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1182b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Gets the value for a given time field. Recalculate the current time field values
1183b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * if the time value has been changed by a call to setTime(). Return zero for unset
1184b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * fields if any fields have been explicitly set by a call to set(). To force a
1185b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * recomputation of all fields regardless of the previous state, call complete().
1186b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * This method is semantically const, but may alter the object in memory.
1187b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1188b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param field  The given time field.
1189b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status Fill-in parameter which receives the status of the operation.
1190b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return       The value for the given time field, or zero if the field is unset,
1191b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *               and set() has been called for any other field.
1192b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @deprecated ICU 2.6. Use get(UCalendarDateFields field, UErrorCode& status) instead.
1193b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1194b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t get(EDateFields field, UErrorCode& status) const;
1195103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif  /* U_HIDE_DEPRECATED_API */
1196b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1197b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1198b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Gets the value for a given time field. Recalculate the current time field values
1199b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * if the time value has been changed by a call to setTime(). Return zero for unset
1200b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * fields if any fields have been explicitly set by a call to set(). To force a
1201b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * recomputation of all fields regardless of the previous state, call complete().
1202b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * This method is semantically const, but may alter the object in memory.
1203b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1204b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param field  The given time field.
1205b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status Fill-in parameter which receives the status of the operation.
1206b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return       The value for the given time field, or zero if the field is unset,
1207b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *               and set() has been called for any other field.
1208b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.6.
1209b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1210b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t get(UCalendarDateFields field, UErrorCode& status) const;
1211b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1212103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_HIDE_DEPRECATED_API
1213b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1214b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Determines if the given time field has a value set. This can affect in the
1215b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * resolving of time in Calendar. Unset fields have a value of zero, by definition.
1216b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1217b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param field  The given time field.
1218b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return   True if the given time field has a value set; false otherwise.
1219b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @deprecated ICU 2.6. Use isSet(UCalendarDateFields field) instead.
1220b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1221b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool isSet(EDateFields field) const;
1222103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif  /* U_HIDE_DEPRECATED_API */
1223b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1224b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1225b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Determines if the given time field has a value set. This can affect in the
1226b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * resolving of time in Calendar. Unset fields have a value of zero, by definition.
1227b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1228b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param field  The given time field.
1229b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return   True if the given time field has a value set; false otherwise.
1230b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.6.
1231b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1232b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool isSet(UCalendarDateFields field) const;
1233b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1234103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_HIDE_DEPRECATED_API
1235b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1236b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Sets the given time field with the given value.
1237b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1238b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param field  The given time field.
1239b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param value  The value to be set for the given time field.
1240b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @deprecated ICU 2.6. Use set(UCalendarDateFields field, int32_t value) instead.
1241b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1242b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void set(EDateFields field, int32_t value);
1243103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif  /* U_HIDE_DEPRECATED_API */
1244b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1245b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1246b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Sets the given time field with the given value.
1247b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1248b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param field  The given time field.
1249b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param value  The value to be set for the given time field.
1250b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.6.
1251b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1252b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void set(UCalendarDateFields field, int32_t value);
1253b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1254b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1255b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Sets the values for the fields YEAR, MONTH, and DATE. Other field values are
1256b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * retained; call clear() first if this is not desired.
1257b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1258b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param year   The value used to set the YEAR time field.
1259b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param month  The value used to set the MONTH time field. Month value is 0-based.
1260b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *               e.g., 0 for January.
1261b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param date   The value used to set the DATE time field.
1262b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
1263b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1264b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void set(int32_t year, int32_t month, int32_t date);
1265b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1266b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1267b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Sets the values for the fields YEAR, MONTH, DATE, HOUR_OF_DAY, and MINUTE. Other
1268b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * field values are retained; call clear() first if this is not desired.
1269b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1270b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param year    The value used to set the YEAR time field.
1271b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param month   The value used to set the MONTH time field. Month value is
1272b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                0-based. E.g., 0 for January.
1273b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param date    The value used to set the DATE time field.
1274b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param hour    The value used to set the HOUR_OF_DAY time field.
1275b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param minute  The value used to set the MINUTE time field.
1276b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
1277b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1278b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void set(int32_t year, int32_t month, int32_t date, int32_t hour, int32_t minute);
1279b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1280b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1281b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Sets the values for the fields YEAR, MONTH, DATE, HOUR_OF_DAY, MINUTE, and SECOND.
1282b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Other field values are retained; call clear() first if this is not desired.
1283b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1284b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param year    The value used to set the YEAR time field.
1285b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param month   The value used to set the MONTH time field. Month value is
1286b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                0-based. E.g., 0 for January.
1287b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param date    The value used to set the DATE time field.
1288b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param hour    The value used to set the HOUR_OF_DAY time field.
1289b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param minute  The value used to set the MINUTE time field.
1290b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param second  The value used to set the SECOND time field.
1291b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
1292b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1293b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void set(int32_t year, int32_t month, int32_t date, int32_t hour, int32_t minute, int32_t second);
1294b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1295b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1296b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Clears the values of all the time fields, making them both unset and assigning
1297b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * them a value of zero. The field values will be determined during the next
1298b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * resolving of time into time fields.
1299b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
1300b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1301b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void clear(void);
1302b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1303103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_HIDE_DEPRECATED_API
1304b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1305b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Clears the value in the given time field, both making it unset and assigning it a
1306b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * value of zero. This field value will be determined during the next resolving of
1307b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * time into time fields.
1308b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1309b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param field  The time field to be cleared.
1310b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @deprecated ICU 2.6. Use clear(UCalendarDateFields field) instead.
1311b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1312b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void clear(EDateFields field);
1313103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif  /* U_HIDE_DEPRECATED_API */
1314b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1315b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1316b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Clears the value in the given time field, both making it unset and assigning it a
1317b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * value of zero. This field value will be determined during the next resolving of
1318b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * time into time fields.
1319b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1320b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param field  The time field to be cleared.
1321b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.6.
1322b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1323b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void clear(UCalendarDateFields field);
1324b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1325b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1326b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Returns a unique class ID POLYMORPHICALLY. Pure virtual method. This method is to
1327b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * implement a simple version of RTTI, since not all C++ compilers support genuine
1328b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * RTTI. Polymorphic operator==() and clone() methods call this method.
1329b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <P>
1330b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Concrete subclasses of Calendar must implement getDynamicClassID() and also a
1331b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * static method and data member:
1332b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1333b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *      static UClassID getStaticClassID() { return (UClassID)&amp;fgClassID; }
1334b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *      static char fgClassID;
1335b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1336b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return   The class ID for this object. All objects of a given class have the
1337b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *           same class ID. Objects of other classes have different class IDs.
1338b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
1339b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1340b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual UClassID getDynamicClassID(void) const = 0;
1341b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1342b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1343103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * Returns the calendar type name string for this Calendar object.
1344103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * The returned string is the legacy ICU calendar attribute value,
1345103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * for example, "gregorian" or "japanese".
1346103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     *
1347103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * See type="old type name" for the calendar attribute of locale IDs
1348103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * at http://www.unicode.org/reports/tr35/#Key_Type_Definitions
1349103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     *
1350103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * Sample code for getting the LDML/BCP 47 calendar key value:
1351103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * \code
1352103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * const char *calType = cal->getType();
1353103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * if (0 == strcmp(calType, "unknown")) {
1354103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     *     // deal with unknown calendar type
1355103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * } else {
1356103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     *     string localeID("root@calendar=");
1357103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     *     localeID.append(calType);
1358103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     *     char langTag[100];
1359103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     *     UErrorCode errorCode = U_ZERO_ERROR;
1360103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     *     int32_t length = uloc_toLanguageTag(localeID.c_str(), langTag, (int32_t)sizeof(langTag), TRUE, &errorCode);
1361103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     *     if (U_FAILURE(errorCode)) {
1362103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     *         // deal with errors & overflow
1363103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     *     }
1364103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     *     string lang(langTag, length);
1365103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     *     size_t caPos = lang.find("-ca-");
1366103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     *     lang.erase(0, caPos + 4);
1367103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     *     // lang now contains the LDML calendar type
1368103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * }
1369103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * \endcode
1370103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     *
1371103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * @return legacy calendar type name string
13728393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius     * @stable ICU 49
1373b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1374b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual const char * getType() const = 0;
1375b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
137650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    /**
137759d709d503bab6e2b61931737e662dd293b40578ccornelius     * Returns whether the given day of the week is a weekday, a weekend day,
137859d709d503bab6e2b61931737e662dd293b40578ccornelius     * or a day that transitions from one to the other, for the locale and
137959d709d503bab6e2b61931737e662dd293b40578ccornelius     * calendar system associated with this Calendar (the locale's region is
138059d709d503bab6e2b61931737e662dd293b40578ccornelius     * often the most determinant factor). If a transition occurs at midnight,
138150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * then the days before and after the transition will have the
138250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * type UCAL_WEEKDAY or UCAL_WEEKEND. If a transition occurs at a time
138350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * other than midnight, then the day of the transition will have
138450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * the type UCAL_WEEKEND_ONSET or UCAL_WEEKEND_CEASE. In this case, the
138550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * method getWeekendTransition() will return the point of
138650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * transition.
138750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * @param dayOfWeek The day of the week whose type is desired (UCAL_SUNDAY..UCAL_SATURDAY).
138850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * @param status The error code for the operation.
138950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * @return The UCalendarWeekdayType for the day of the week.
139027f654740f2a26ad62a5c155af9199af9e69b889claireho     * @stable ICU 4.4
139150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     */
139250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    virtual UCalendarWeekdayType getDayOfWeekType(UCalendarDaysOfWeek dayOfWeek, UErrorCode &status) const;
139350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
139450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    /**
139550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * Returns the time during the day at which the weekend begins or ends in
139659d709d503bab6e2b61931737e662dd293b40578ccornelius     * this calendar system.  If getDayOfWeekType() returns UCAL_WEEKEND_ONSET
139750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * for the specified dayOfWeek, return the time at which the weekend begins.
139850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * If getDayOfWeekType() returns UCAL_WEEKEND_CEASE for the specified dayOfWeek,
139950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * return the time at which the weekend ends. If getDayOfWeekType() returns
140050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * some other UCalendarWeekdayType for the specified dayOfWeek, is it an error condition
140150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * (U_ILLEGAL_ARGUMENT_ERROR).
140250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * @param dayOfWeek The day of the week for which the weekend transition time is
140350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * desired (UCAL_SUNDAY..UCAL_SATURDAY).
140450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * @param status The error code for the operation.
140550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * @return The milliseconds after midnight at which the weekend begins or ends.
140627f654740f2a26ad62a5c155af9199af9e69b889claireho     * @stable ICU 4.4
140750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     */
140850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    virtual int32_t getWeekendTransition(UCalendarDaysOfWeek dayOfWeek, UErrorCode &status) const;
140950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
141050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    /**
141150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * Returns TRUE if the given UDate is in the weekend in
141250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * this calendar system.
141350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * @param date The UDate in question.
141450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * @param status The error code for the operation.
141550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * @return TRUE if the given UDate is in the weekend in
141650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * this calendar system, FALSE otherwise.
141727f654740f2a26ad62a5c155af9199af9e69b889claireho     * @stable ICU 4.4
141850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     */
141950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    virtual UBool isWeekend(UDate date, UErrorCode &status) const;
142050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
142150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    /**
142250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * Returns TRUE if this Calendar's current date-time is in the weekend in
142350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * this calendar system.
142450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * @return TRUE if this Calendar's current date-time is in the weekend in
142550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * this calendar system, FALSE otherwise.
142627f654740f2a26ad62a5c155af9199af9e69b889claireho     * @stable ICU 4.4
142750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     */
142850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    virtual UBool isWeekend(void) const;
142950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
1430b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruprotected:
1431b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1432b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     /**
1433b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      * Constructs a Calendar with the default time zone as returned by
1434b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      * TimeZone::createInstance(), and the default locale.
1435b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      *
1436b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      * @param success  Indicates the status of Calendar object construction. Returns
1437b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      *                 U_ZERO_ERROR if constructed successfully.
1438b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
1439b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      */
1440b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Calendar(UErrorCode& success);
1441b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1442b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1443b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Copy constructor
1444b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1445b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param source    Calendar object to be copied from
1446b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
1447b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1448b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Calendar(const Calendar& source);
1449b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1450b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1451b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Default assignment operator
1452b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1453b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param right    Calendar object to be copied
1454b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
1455b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1456b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Calendar& operator=(const Calendar& right);
1457b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1458b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1459b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Constructs a Calendar with the given time zone and locale. Clients are no longer
1460b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * responsible for deleting the given time zone object after it's adopted.
1461b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1462b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param zone     The given time zone.
1463b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param aLocale  The given locale.
1464b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param success  Indicates the status of Calendar object construction. Returns
1465b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                 U_ZERO_ERROR if constructed successfully.
1466b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
1467b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1468b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Calendar(TimeZone* zone, const Locale& aLocale, UErrorCode& success);
1469b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1470b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1471b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Constructs a Calendar with the given time zone and locale.
1472b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1473b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param zone     The given time zone.
1474b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param aLocale  The given locale.
1475b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param success  Indicates the status of Calendar object construction. Returns
1476b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                 U_ZERO_ERROR if constructed successfully.
1477b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
1478b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1479b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Calendar(const TimeZone& zone, const Locale& aLocale, UErrorCode& success);
1480b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1481b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1482b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Converts Calendar's time field values to GMT as milliseconds.
1483b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1484b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status  Output param set to success/failure code on exit. If any value
1485b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                previously set in the time field is invalid or restricted by
1486b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                leniency, this will be set to an error status.
1487b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
1488b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1489b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual void computeTime(UErrorCode& status);
1490b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1491b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1492b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Converts GMT as milliseconds to time field values. This allows you to sync up the
1493b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * time field values with a new time that is set for the calendar.  This method
1494b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * does NOT recompute the time first; to recompute the time, then the fields, use
1495b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * the method complete().
1496b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1497b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status  Output param set to success/failure code on exit. If any value
1498b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                previously set in the time field is invalid or restricted by
1499b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                leniency, this will be set to an error status.
1500b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
1501b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1502b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual void computeFields(UErrorCode& status);
1503b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1504b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1505b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Gets this Calendar's current time as a long.
1506b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1507b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status  Output param set to success/failure code on exit. If any value
1508b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                previously set in the time field is invalid or restricted by
1509b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                leniency, this will be set to an error status.
1510b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return the current time as UTC milliseconds from the epoch.
1511b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
1512b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1513b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    double getTimeInMillis(UErrorCode& status) const;
1514b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1515b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1516b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Sets this Calendar's current time from the given long value.
1517b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param millis  the new time in UTC milliseconds from the epoch.
1518b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status  Output param set to success/failure code on exit. If any value
1519b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                previously set in the time field is invalid or restricted by
1520b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                leniency, this will be set to an error status.
1521b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
1522b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1523b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void setTimeInMillis( double millis, UErrorCode& status );
1524b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1525b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1526b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Recomputes the current time from currently set fields, and then fills in any
1527b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * unset fields in the time field list.
1528b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1529b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status  Output param set to success/failure code on exit. If any value
1530b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                previously set in the time field is invalid or restricted by
1531b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                leniency, this will be set to an error status.
1532b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
1533b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1534b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void complete(UErrorCode& status);
1535b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1536103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_HIDE_DEPRECATED_API
1537b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1538b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Gets the value for a given time field. Subclasses can use this function to get
1539b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * field values without forcing recomputation of time.
1540b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1541b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param field  The given time field.
1542b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return       The value for the given time field.
1543b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @deprecated ICU 2.6. Use internalGet(UCalendarDateFields field) instead.
1544b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1545b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    inline int32_t internalGet(EDateFields field) const {return fFields[field];}
1546103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif  /* U_HIDE_DEPRECATED_API */
1547b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1548103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_HIDE_INTERNAL_API
1549b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1550b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Gets the value for a given time field. Subclasses can use this function to get
1551b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * field values without forcing recomputation of time. If the field's stamp is UNSET,
1552b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * the defaultValue is used.
1553b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1554b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param field  The given time field.
1555b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param defaultValue a default value used if the field is unset.
1556b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return       The value for the given time field.
1557b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
1558b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1559b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    inline int32_t internalGet(UCalendarDateFields field, int32_t defaultValue) const {return fStamp[field]>kUnset ? fFields[field] : defaultValue;}
1560b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1561b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1562b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Gets the value for a given time field. Subclasses can use this function to get
1563b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * field values without forcing recomputation of time.
1564b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1565b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param field  The given time field.
1566b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return       The value for the given time field.
1567b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
1568b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1569b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    inline int32_t internalGet(UCalendarDateFields field) const {return fFields[field];}
1570103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif  /* U_HIDE_INTERNAL_API */
1571b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1572103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_HIDE_DEPRECATED_API
1573b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1574b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Sets the value for a given time field.  This is a fast internal method for
1575b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * subclasses.  It does not affect the areFieldsInSync, isTimeSet, or areAllFieldsSet
1576b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * flags.
1577b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1578b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param field    The given time field.
1579b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param value    The value for the given time field.
1580b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @deprecated ICU 2.6. Use internalSet(UCalendarDateFields field, int32_t value) instead.
1581b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1582b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void internalSet(EDateFields field, int32_t value);
1583103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif  /* U_HIDE_DEPRECATED_API */
1584b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1585b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1586b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Sets the value for a given time field.  This is a fast internal method for
1587b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * subclasses.  It does not affect the areFieldsInSync, isTimeSet, or areAllFieldsSet
1588b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * flags.
1589b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1590b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param field    The given time field.
1591b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param value    The value for the given time field.
1592b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.6.
1593b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1594b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    inline void internalSet(UCalendarDateFields field, int32_t value);
1595b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1596b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1597b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Prepare this calendar for computing the actual minimum or maximum.
1598b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * This method modifies this calendar's fields; it is called on a
1599b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * temporary calendar.
1600b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
1601b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1602b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual void prepareGetActual(UCalendarDateFields field, UBool isMinimum, UErrorCode &status);
1603b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1604b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1605b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Limit enums. Not in sync with UCalendarLimitType (refers to internal fields).
1606b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
1607b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1608b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    enum ELimitType {
16098393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius#ifndef U_HIDE_INTERNAL_API
1610b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      UCAL_LIMIT_MINIMUM = 0,
1611b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      UCAL_LIMIT_GREATEST_MINIMUM,
1612b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      UCAL_LIMIT_LEAST_MAXIMUM,
1613b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      UCAL_LIMIT_MAXIMUM,
1614b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      UCAL_LIMIT_COUNT
16158393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius#endif  /* U_HIDE_INTERNAL_API */
1616b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    };
1617b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1618b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1619b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Subclass API for defining limits of different types.
1620b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Subclasses must implement this method to return limits for the
1621b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * following fields:
1622b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1623b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <pre>UCAL_ERA
1624b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * UCAL_YEAR
1625b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * UCAL_MONTH
1626b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * UCAL_WEEK_OF_YEAR
1627b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * UCAL_WEEK_OF_MONTH
1628b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * UCAL_DATE (DAY_OF_MONTH on Java)
1629b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * UCAL_DAY_OF_YEAR
1630b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * UCAL_DAY_OF_WEEK_IN_MONTH
1631b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * UCAL_YEAR_WOY
1632b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * UCAL_EXTENDED_YEAR</pre>
1633b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1634b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param field one of the above field numbers
1635b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param limitType one of <code>MINIMUM</code>, <code>GREATEST_MINIMUM</code>,
1636b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <code>LEAST_MAXIMUM</code>, or <code>MAXIMUM</code>
1637b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
1638b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1639b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const = 0;
1640b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1641b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1642b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Return a limit for a field.
1643b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param field the field, from <code>0..UCAL_MAX_FIELD</code>
1644b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param limitType the type specifier for the limit
1645b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @see #ELimitType
1646b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
1647b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1648b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual int32_t getLimit(UCalendarDateFields field, ELimitType limitType) const;
1649b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1650b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1651b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1652b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Return the Julian day number of day before the first day of the
1653b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * given month in the given extended year.  Subclasses should override
1654b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * this method to implement their calendar system.
1655b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param eyear the extended year
1656b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param month the zero-based month, or 0 if useMonth is false
1657b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param useMonth if false, compute the day before the first day of
1658b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * the given year, otherwise, compute the day before the first day of
1659b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * the given month
1660b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return the Julian day number of the day before the first
1661b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * day of the given month and year
1662b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
1663b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1664b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual int32_t handleComputeMonthStart(int32_t eyear, int32_t month,
1665b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                   UBool useMonth) const  = 0;
1666b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1667b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1668b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Return the number of days in the given month of the given extended
1669b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * year of this calendar system.  Subclasses should override this
1670b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * method if they can provide a more correct or more efficient
1671b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * implementation than the default implementation in Calendar.
1672b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
1673b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1674b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual int32_t handleGetMonthLength(int32_t extendedYear, int32_t month) const ;
1675b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1676b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1677b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Return the number of days in the given extended year of this
1678b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * calendar system.  Subclasses should override this method if they can
1679b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * provide a more correct or more efficient implementation than the
1680b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * default implementation in Calendar.
1681b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
1682b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1683b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual int32_t handleGetYearLength(int32_t eyear) const;
1684b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1685b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1686b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1687b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Return the extended year defined by the current fields.  This will
1688b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * use the UCAL_EXTENDED_YEAR field or the UCAL_YEAR and supra-year fields (such
1689b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * as UCAL_ERA) specific to the calendar system, depending on which set of
1690b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * fields is newer.
1691b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return the extended year
1692b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
1693b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1694b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual int32_t handleGetExtendedYear() = 0;
1695b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1696b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1697b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Subclasses may override this.  This method calls
1698b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * handleGetMonthLength() to obtain the calendar-specific month
1699b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * length.
1700b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param bestField which field to use to calculate the date
1701b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return julian day specified by calendar fields.
1702b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
1703b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1704b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual int32_t handleComputeJulianDay(UCalendarDateFields bestField);
1705b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1706b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1707b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Subclasses must override this to convert from week fields
1708b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * (YEAR_WOY and WEEK_OF_YEAR) to an extended year in the case
1709b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * where YEAR, EXTENDED_YEAR are not set.
1710b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * The Calendar implementation assumes yearWoy is in extended gregorian form
1711b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return the extended year, UCAL_EXTENDED_YEAR
171259d709d503bab6e2b61931737e662dd293b40578ccornelius     * @internal
1713b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1714b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual int32_t handleGetExtendedYearFromWeekFields(int32_t yearWoy, int32_t woy);
1715b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1716fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius    /**
1717fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius     * Validate a single field of this calendar.  Subclasses should
1718fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius     * override this method to validate any calendar-specific fields.
1719fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius     * Generic fields can be handled by
1720fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius     * <code>Calendar::validateField()</code>.
1721fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius     * @see #validateField(int, int, int, int&)
1722fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius     * @internal
1723fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius     */
1724fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius    virtual void validateField(UCalendarDateFields field, UErrorCode &status);
1725fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius
1726103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_HIDE_INTERNAL_API
1727b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1728b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Compute the Julian day from fields.  Will determine whether to use
1729b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * the JULIAN_DAY field directly, or other fields.
1730b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return the julian day
1731b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
1732b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1733b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t computeJulianDay();
1734b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1735b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1736b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Compute the milliseconds in the day from the fields.  This is a
1737b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * value from 0 to 23:59:59.999 inclusive, unless fields are out of
1738b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * range, in which case it can be an arbitrary value.  This value
1739b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * reflects local zone wall time.
1740b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
1741b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1742b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t computeMillisInDay();
1743b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1744b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1745b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * This method can assume EXTENDED_YEAR has been set.
1746b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param millis milliseconds of the date fields
1747b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param millisInDay milliseconds of the time fields; may be out
1748b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * or range.
1749b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param ec Output param set to failure code on function return
1750b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *          when this function fails.
1751b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
1752b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1753b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t computeZoneOffset(double millis, int32_t millisInDay, UErrorCode &ec);
1754b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1755b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1756b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1757b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Determine the best stamp in a range.
1758b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param start first enum to look at
1759b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param end last enum to look at
1760b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param bestSoFar stamp prior to function call
1761b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return the stamp value of the best stamp
1762b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
1763b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1764b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t newestStamp(UCalendarDateFields start, UCalendarDateFields end, int32_t bestSoFar) const;
1765b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1766b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1767b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Values for field resolution tables
1768b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @see #resolveFields
1769b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
1770b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1771b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    enum {
1772b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      /** Marker for end of resolve set (row or group). */
1773b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      kResolveSTOP = -1,
1774b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      /** Value to be bitwised "ORed" against resolve table field values for remapping.  Example: (UCAL_DATE | kResolveRemap) in 1st column will cause 'UCAL_DATE' to be returned, but will not examine the value of UCAL_DATE.  */
1775b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      kResolveRemap = 32
1776b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    };
1777b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1778b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1779b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Precedence table for Dates
1780b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @see #resolveFields
1781b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
1782b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1783b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    static const UFieldResolutionTable kDatePrecedence[];
1784b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1785b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1786b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Precedence table for Year
1787b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @see #resolveFields
1788b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
1789b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1790b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    static const UFieldResolutionTable kYearPrecedence[];
1791b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1792b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1793b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Precedence table for Day of Week
1794b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @see #resolveFields
1795b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
1796b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1797b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    static const UFieldResolutionTable kDOWPrecedence[];
1798b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1799b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1800b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Given a precedence table, return the newest field combination in
1801b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * the table, or UCAL_FIELD_COUNT if none is found.
1802b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1803b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <p>The precedence table is a 3-dimensional array of integers.  It
1804b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * may be thought of as an array of groups.  Each group is an array of
1805b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * lines.  Each line is an array of field numbers.  Within a line, if
1806b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * all fields are set, then the time stamp of the line is taken to be
1807b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * the stamp of the most recently set field.  If any field of a line is
1808b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * unset, then the line fails to match.  Within a group, the line with
1809b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * the newest time stamp is selected.  The first field of the line is
1810b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * returned to indicate which line matched.
1811b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1812b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <p>In some cases, it may be desirable to map a line to field that
1813b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * whose stamp is NOT examined.  For example, if the best field is
1814b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * DAY_OF_WEEK then the DAY_OF_WEEK_IN_MONTH algorithm may be used.  In
1815b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * order to do this, insert the value <code>kResolveRemap | F</code> at
1816b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * the start of the line, where <code>F</code> is the desired return
1817b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * field value.  This field will NOT be examined; it only determines
1818b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * the return value if the other fields in the line are the newest.
1819b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1820b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <p>If all lines of a group contain at least one unset field, then no
1821b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * line will match, and the group as a whole will fail to match.  In
1822b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * that case, the next group will be processed.  If all groups fail to
1823b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * match, then UCAL_FIELD_COUNT is returned.
1824b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
1825b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1826b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UCalendarDateFields resolveFields(const UFieldResolutionTable *precedenceTable);
1827103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif  /* U_HIDE_INTERNAL_API */
1828b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1829b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1830b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1831b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
1832b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1833b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual const UFieldResolutionTable* getFieldResolutionTable() const;
1834b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1835103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_HIDE_INTERNAL_API
1836b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1837b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Return the field that is newer, either defaultField, or
1838b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * alternateField.  If neither is newer or neither is set, return defaultField.
1839b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
1840b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1841b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UCalendarDateFields newerField(UCalendarDateFields defaultField, UCalendarDateFields alternateField) const;
1842103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif  /* U_HIDE_INTERNAL_API */
1843b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1844b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1845b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruprivate:
1846b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1847b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Helper function for calculating limits by trial and error
1848b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param field The field being investigated
1849b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param startValue starting (least max) value of field
1850b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param endValue ending (greatest max) value of field
1851b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status return type
1852b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
1853b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1854b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t getActualHelper(UCalendarDateFields field, int32_t startValue, int32_t endValue, UErrorCode &status) const;
1855b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1856b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1857b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruprotected:
1858b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1859b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * The flag which indicates if the current time is set in the calendar.
1860b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
1861b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1862b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool      fIsTimeSet;
1863b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1864b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1865b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * True if the fields are in sync with the currently set time of this Calendar.
1866b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * If false, then the next attempt to get the value of a field will
1867b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * force a recomputation of all fields from the current value of the time
1868b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * field.
1869b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <P>
1870b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * This should really be named areFieldsInSync, but the old name is retained
1871b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * for backward compatibility.
1872b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
1873b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1874b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool      fAreFieldsSet;
1875b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1876b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1877b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * True if all of the fields have been set.  This is initially false, and set to
1878b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * true by computeFields().
1879b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
1880b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1881b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool      fAreAllFieldsSet;
1882b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1883b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1884b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * True if all fields have been virtually set, but have not yet been
1885b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * computed.  This occurs only in setTimeInMillis().  A calendar set
1886b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * to this state will compute all fields from the time if it becomes
1887b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * necessary, but otherwise will delay such computation.
1888b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 3.0
1889b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1890b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool fAreFieldsVirtuallySet;
1891b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1892b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1893b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Get the current time without recomputing.
1894b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1895b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return     the current time without recomputing.
1896b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
1897b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1898b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UDate        internalGetTime(void) const     { return fTime; }
1899b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1900b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1901b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Set the current time without affecting flags or fields.
1902b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1903b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param time    The time to be set
1904b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return        the current time without recomputing.
1905b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
1906b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1907b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void        internalSetTime(UDate time)     { fTime = time; }
1908b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1909b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1910b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * The time fields containing values into which the millis is computed.
1911b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
1912b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1913b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t     fFields[UCAL_FIELD_COUNT];
1914b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1915b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1916b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * The flags which tell if a specified time field for the calendar is set.
1917b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @deprecated ICU 2.8 use (fStamp[n]!=kUnset)
1918b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1919b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool      fIsSet[UCAL_FIELD_COUNT];
1920b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1921b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /** Special values of stamp[]
1922b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
1923b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1924b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    enum {
1925b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        kUnset                 = 0,
1926b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        kInternallySet,
1927b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        kMinimumUserStamp
1928b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    };
1929b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1930b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1931b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Pseudo-time-stamps which specify when each field was set. There
1932b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * are two special values, UNSET and INTERNALLY_SET. Values from
1933b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * MINIMUM_USER_SET to Integer.MAX_VALUE are legal user set values.
1934b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
1935b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1936b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t        fStamp[UCAL_FIELD_COUNT];
1937b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1938b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1939b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Subclasses may override this method to compute several fields
1940b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * specific to each calendar system.  These are:
1941b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1942b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <ul><li>ERA
1943b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <li>YEAR
1944b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <li>MONTH
1945b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <li>DAY_OF_MONTH
1946b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <li>DAY_OF_YEAR
1947b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <li>EXTENDED_YEAR</ul>
1948b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1949b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Subclasses can refer to the DAY_OF_WEEK and DOW_LOCAL fields, which
1950b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * will be set when this method is called.  Subclasses can also call
1951b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * the getGregorianXxx() methods to obtain Gregorian calendar
1952b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * equivalents for the given Julian day.
1953b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1954b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <p>In addition, subclasses should compute any subclass-specific
1955b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * fields, that is, fields from BASE_FIELD_COUNT to
1956b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * getFieldCount() - 1.
1957b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1958b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <p>The default implementation in <code>Calendar</code> implements
1959b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * a pure proleptic Gregorian calendar.
1960b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
1961b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1962b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual void handleComputeFields(int32_t julianDay, UErrorCode &status);
1963b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1964103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_HIDE_INTERNAL_API
1965b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1966b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Return the extended year on the Gregorian calendar as computed by
1967b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <code>computeGregorianFields()</code>.
1968b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
1969b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1970b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t getGregorianYear() const {
1971b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        return fGregorianYear;
1972b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1973b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1974b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1975b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Return the month (0-based) on the Gregorian calendar as computed by
1976b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <code>computeGregorianFields()</code>.
1977b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
1978b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1979b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t getGregorianMonth() const {
1980b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        return fGregorianMonth;
1981b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1982b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1983b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1984b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Return the day of year (1-based) on the Gregorian calendar as
1985b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * computed by <code>computeGregorianFields()</code>.
1986b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
1987b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1988b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t getGregorianDayOfYear() const {
1989b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        return fGregorianDayOfYear;
1990b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1991b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1992b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1993b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Return the day of month (1-based) on the Gregorian calendar as
1994b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * computed by <code>computeGregorianFields()</code>.
1995b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
1996b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1997b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t getGregorianDayOfMonth() const {
1998b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      return fGregorianDayOfMonth;
1999b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
2000103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif  /* U_HIDE_INTERNAL_API */
2001b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2002b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
2003b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Called by computeJulianDay.  Returns the default month (0-based) for the year,
2004b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * taking year and era into account.  Defaults to 0 for Gregorian, which doesn't care.
2005b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru     * @param eyear The extended year
2006b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
2007b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
2008b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru    virtual int32_t getDefaultMonthInYear(int32_t eyear) ;
2009b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2010b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2011b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
2012b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Called by computeJulianDay.  Returns the default day (1-based) for the month,
2013b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * taking currently-set year and era into account.  Defaults to 1 for Gregorian.
2014b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru     * @param eyear the extended year
2015b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru     * @param month the month in the year
2016b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
2017b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
2018b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru    virtual int32_t getDefaultDayInMonth(int32_t eyear, int32_t month);
2019b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2020b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //-------------------------------------------------------------------------
2021b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // Protected utility methods for use by subclasses.  These are very handy
2022b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // for implementing add, roll, and computeFields.
2023b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //-------------------------------------------------------------------------
2024b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2025b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
2026b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Adjust the specified field so that it is within
2027b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * the allowable range for the date to which this calendar is set.
2028b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * For example, in a Gregorian calendar pinning the {@link #UCalendarDateFields DAY_OF_MONTH}
2029b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * field for a calendar set to April 31 would cause it to be set
2030b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * to April 30.
2031b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <p>
2032b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <b>Subclassing:</b>
2033b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <br>
2034b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * This utility method is intended for use by subclasses that need to implement
2035b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * their own overrides of {@link #roll roll} and {@link #add add}.
2036b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <p>
2037b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <b>Note:</b>
2038b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <code>pinField</code> is implemented in terms of
2039b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * {@link #getActualMinimum getActualMinimum}
2040b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * and {@link #getActualMaximum getActualMaximum}.  If either of those methods uses
2041b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * a slow, iterative algorithm for a particular field, it would be
2042b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * unwise to attempt to call <code>pinField</code> for that field.  If you
2043b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * really do need to do so, you should override this method to do
2044b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * something more efficient for that field.
2045b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <p>
2046b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param field The calendar field whose value should be pinned.
2047b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status Output param set to failure code on function return
2048b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *          when this function fails.
2049b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
2050b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @see #getActualMinimum
2051b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @see #getActualMaximum
2052b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
2053b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
2054b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual void pinField(UCalendarDateFields field, UErrorCode& status);
2055b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2056b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
2057b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Return the week number of a day, within a period. This may be the week number in
2058b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * a year or the week number in a month. Usually this will be a value >= 1, but if
2059b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * some initial days of the period are excluded from week 1, because
2060b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * {@link #getMinimalDaysInFirstWeek getMinimalDaysInFirstWeek} is > 1, then
2061b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * the week number will be zero for those
2062b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * initial days. This method requires the day number and day of week for some
2063b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * known date in the period in order to determine the day of week
2064b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * on the desired day.
2065b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <p>
2066b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <b>Subclassing:</b>
2067b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <br>
2068b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * This method is intended for use by subclasses in implementing their
2069b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * {@link #computeTime computeTime} and/or {@link #computeFields computeFields} methods.
2070b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * It is often useful in {@link #getActualMinimum getActualMinimum} and
2071b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * {@link #getActualMaximum getActualMaximum} as well.
2072b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <p>
2073b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * This variant is handy for computing the week number of some other
2074b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * day of a period (often the first or last day of the period) when its day
2075b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * of the week is not known but the day number and day of week for some other
2076b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * day in the period (e.g. the current date) <em>is</em> known.
2077b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <p>
2078b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param desiredDay    The {@link #UCalendarDateFields DAY_OF_YEAR} or
2079b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *              {@link #UCalendarDateFields DAY_OF_MONTH} whose week number is desired.
2080b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *              Should be 1 for the first day of the period.
2081b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
2082b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param dayOfPeriod   The {@link #UCalendarDateFields DAY_OF_YEAR}
2083b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *              or {@link #UCalendarDateFields DAY_OF_MONTH} for a day in the period whose
2084b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *              {@link #UCalendarDateFields DAY_OF_WEEK} is specified by the
2085b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *              <code>knownDayOfWeek</code> parameter.
2086b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *              Should be 1 for first day of period.
2087b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
2088b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param dayOfWeek  The {@link #UCalendarDateFields DAY_OF_WEEK} for the day
2089b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *              corresponding to the <code>knownDayOfPeriod</code> parameter.
2090b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *              1-based with 1=Sunday.
2091b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
2092b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return      The week number (one-based), or zero if the day falls before
2093b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *              the first week because
2094b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *              {@link #getMinimalDaysInFirstWeek getMinimalDaysInFirstWeek}
2095b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *              is more than one.
2096b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
2097b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.8
2098b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
2099b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t weekNumber(int32_t desiredDay, int32_t dayOfPeriod, int32_t dayOfWeek);
2100b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2101b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2102103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_HIDE_INTERNAL_API
2103b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
2104b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Return the week number of a day, within a period. This may be the week number in
2105b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * a year, or the week number in a month. Usually this will be a value >= 1, but if
2106b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * some initial days of the period are excluded from week 1, because
2107b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * {@link #getMinimalDaysInFirstWeek getMinimalDaysInFirstWeek} is > 1,
2108b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * then the week number will be zero for those
2109b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * initial days. This method requires the day of week for the given date in order to
2110b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * determine the result.
2111b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <p>
2112b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <b>Subclassing:</b>
2113b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <br>
2114b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * This method is intended for use by subclasses in implementing their
2115b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * {@link #computeTime computeTime} and/or {@link #computeFields computeFields} methods.
2116b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * It is often useful in {@link #getActualMinimum getActualMinimum} and
2117b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * {@link #getActualMaximum getActualMaximum} as well.
2118b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <p>
2119b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param dayOfPeriod   The {@link #UCalendarDateFields DAY_OF_YEAR} or
2120b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                      {@link #UCalendarDateFields DAY_OF_MONTH} whose week number is desired.
2121b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                      Should be 1 for the first day of the period.
2122b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
2123b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param dayOfWeek     The {@link #UCalendarDateFields DAY_OF_WEEK} for the day
2124b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                      corresponding to the <code>dayOfPeriod</code> parameter.
2125b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                      1-based with 1=Sunday.
2126b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
2127b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return      The week number (one-based), or zero if the day falls before
2128b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *              the first week because
2129b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *              {@link #getMinimalDaysInFirstWeek getMinimalDaysInFirstWeek}
2130b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *              is more than one.
2131b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
2132b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
2133b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    inline int32_t weekNumber(int32_t dayOfPeriod, int32_t dayOfWeek);
2134b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2135b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
2136b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * returns the local DOW, valid range 0..6
2137b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
2138b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
2139b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t getLocalDOW();
2140103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif  /* U_HIDE_INTERNAL_API */
2141b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2142b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruprivate:
2143b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2144b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
2145b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * The next available value for fStamp[]
2146b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
2147b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t fNextStamp;// = MINIMUM_USER_STAMP;
2148b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2149b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
2150b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * Recalculates the time stamp array (fStamp).
2151b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * Resets fNextStamp to lowest next stamp value.
2152b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     */
2153b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    void recalculateStamp();
2154b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho
2155b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    /**
2156b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * The current time set for the calendar.
2157b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
2158b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UDate        fTime;
2159b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2160b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
2161b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @see   #setLenient
2162b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
2163b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool      fLenient;
2164b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2165b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
2166b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Time zone affects the time calculation done by Calendar. Calendar subclasses use
2167b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * the time zone data to produce the local time.
2168b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
2169b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TimeZone*   fZone;
2170b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2171b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
2172103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * Option for rpeated wall time
2173103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * @see #setRepeatedWallTimeOption
2174103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     */
2175103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius    UCalendarWallTimeOption fRepeatedWallTime;
2176103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius
2177103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius    /**
2178103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * Option for skipped wall time
2179103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * @see #setSkippedWallTimeOption
2180103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     */
2181103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius    UCalendarWallTimeOption fSkippedWallTime;
2182103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius
2183103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius    /**
2184b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Both firstDayOfWeek and minimalDaysInFirstWeek are locale-dependent. They are
2185b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * used to figure out the week count for a specific date for a given locale. These
2186b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * must be set when a Calendar is constructed. For example, in US locale,
2187b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * firstDayOfWeek is SUNDAY; minimalDaysInFirstWeek is 1. They are used to figure
2188b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * out the week count for a specific date for a given locale. These must be set when
2189b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * a Calendar is constructed.
2190b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
2191b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UCalendarDaysOfWeek fFirstDayOfWeek;
2192b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    uint8_t     fMinimalDaysInFirstWeek;
219350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    UCalendarDaysOfWeek fWeekendOnset;
219450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    int32_t fWeekendOnsetMillis;
219550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    UCalendarDaysOfWeek fWeekendCease;
219650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    int32_t fWeekendCeaseMillis;
2197b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2198b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
2199b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Sets firstDayOfWeek and minimalDaysInFirstWeek. Called at Calendar construction
2200b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * time.
2201b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
2202b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param desiredLocale  The given locale.
2203b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param type           The calendar type identifier, e.g: gregorian, buddhist, etc.
2204b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param success        Indicates the status of setting the week count data from
2205b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                       the resource for the given locale. Returns U_ZERO_ERROR if
2206b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                       constructed successfully.
2207b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
220850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    void        setWeekData(const Locale& desiredLocale, const char *type, UErrorCode& success);
2209b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2210b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
2211b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Recompute the time and update the status fields isTimeSet
2212b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * and areFieldsSet.  Callers should check isTimeSet and only
2213b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * call this method if isTimeSet is false.
2214b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
2215b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status  Output param set to success/failure code on exit. If any value
2216b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                previously set in the time field is invalid or restricted by
2217b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                leniency, this will be set to an error status.
2218b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
2219b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void updateTime(UErrorCode& status);
2220b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2221b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
2222b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * The Gregorian year, as computed by computeGregorianFields() and
2223b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * returned by getGregorianYear().
2224b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @see #computeGregorianFields
2225b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
2226b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t fGregorianYear;
2227b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2228b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
2229b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * The Gregorian month, as computed by computeGregorianFields() and
2230b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * returned by getGregorianMonth().
2231b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @see #computeGregorianFields
2232b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
2233b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t fGregorianMonth;
2234b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2235b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
2236b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * The Gregorian day of the year, as computed by
2237b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * computeGregorianFields() and returned by getGregorianDayOfYear().
2238b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @see #computeGregorianFields
2239b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
2240b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t fGregorianDayOfYear;
2241b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2242b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
2243b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * The Gregorian day of the month, as computed by
2244b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * computeGregorianFields() and returned by getGregorianDayOfMonth().
2245b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @see #computeGregorianFields
2246b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
2247b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t fGregorianDayOfMonth;
2248b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2249b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /* calculations */
2250b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2251b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
2252b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Compute the Gregorian calendar year, month, and day of month from
2253b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * the given Julian day.  These values are not stored in fields, but in
2254b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * member variables gregorianXxx.  Also compute the DAY_OF_WEEK and
2255b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * DOW_LOCAL fields.
2256b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
2257b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void computeGregorianAndDOWFields(int32_t julianDay, UErrorCode &ec);
2258b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
225950294ead5e5d23f5bbfed76e00e6b510bd41eee1clairehoprotected:
2260c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru
2261b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
2262b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Compute the Gregorian calendar year, month, and day of month from the
2263b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Julian day.  These values are not stored in fields, but in member
2264b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * variables gregorianXxx.  They are used for time zone computations and by
2265b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * subclasses that are Gregorian derivatives.  Subclasses may call this
2266b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * method to perform a Gregorian calendar millis->fields computation.
2267b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
2268b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void computeGregorianFields(int32_t julianDay, UErrorCode &ec);
2269b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
227050294ead5e5d23f5bbfed76e00e6b510bd41eee1clairehoprivate:
2271c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru
2272b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
2273b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Compute the fields WEEK_OF_YEAR, YEAR_WOY, WEEK_OF_MONTH,
2274b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * DAY_OF_WEEK_IN_MONTH, and DOW_LOCAL from EXTENDED_YEAR, YEAR,
2275b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * DAY_OF_WEEK, and DAY_OF_YEAR.  The latter fields are computed by the
2276b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * subclass based on the calendar system.
2277b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
2278b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <p>The YEAR_WOY field is computed simplistically.  It is equal to YEAR
2279b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * most of the time, but at the year boundary it may be adjusted to YEAR-1
2280b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * or YEAR+1 to reflect the overlap of a week into an adjacent year.  In
2281b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * this case, a simple increment or decrement is performed on YEAR, even
2282b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * though this may yield an invalid YEAR value.  For instance, if the YEAR
2283b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * is part of a calendar system with an N-year cycle field CYCLE, then
2284b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * incrementing the YEAR may involve incrementing CYCLE and setting YEAR
2285b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * back to 0 or 1.  This is not handled by this code, and in fact cannot be
2286b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * simply handled without having subclasses define an entire parallel set of
2287b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * fields for fields larger than or equal to a year.  This additional
2288b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * complexity is not warranted, since the intention of the YEAR_WOY field is
2289b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * to support ISO 8601 notation, so it will typically be used with a
2290b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * proleptic Gregorian calendar, which has no field larger than a year.
2291b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
2292b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void computeWeekFields(UErrorCode &ec);
2293b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2294b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2295b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
2296b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Ensure that each field is within its valid range by calling {@link
2297b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * #validateField(int, int&)} on each field that has been set.  This method
2298b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * should only be called if this calendar is not lenient.
2299b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @see #isLenient
2300b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @see #validateField(int, int&)
2301b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
2302b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
2303b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void validateFields(UErrorCode &status);
2304b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2305b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
2306b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Validate a single field of this calendar given its minimum and
2307b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * maximum allowed value.  If the field is out of range,
2308b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * <code>U_ILLEGAL_ARGUMENT_ERROR</code> will be set.  Subclasses may
2309b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * use this method in their implementation of {@link
2310b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * #validateField(int, int&)}.
2311b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
2312b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
2313b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void validateField(UCalendarDateFields field, int32_t min, int32_t max, UErrorCode& status);
2314b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2315b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru protected:
2316103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_HIDE_INTERNAL_API
2317b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
2318b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Convert a quasi Julian date to the day of the week. The Julian date used here is
2319b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * not a true Julian date, since it is measured from midnight, not noon. Return
2320b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * value is one-based.
2321b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
2322b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param julian  The given Julian date number.
2323b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return   Day number from 1..7 (SUN..SAT).
2324b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
2325b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
2326b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    static uint8_t julianDayToDayOfWeek(double julian);
2327103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif  /* U_HIDE_INTERNAL_API */
2328b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2329b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru private:
2330b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    char validLocale[ULOC_FULLNAME_CAPACITY];
2331b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    char actualLocale[ULOC_FULLNAME_CAPACITY];
2332b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2333b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru public:
2334b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_SERVICE
2335b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
2336b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * INTERNAL FOR 2.6 --  Registration.
2337b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
2338b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2339103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_HIDE_INTERNAL_API
2340b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
2341b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Return a StringEnumeration over the locales available at the time of the call,
2342b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * including registered locales.
2343b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return a StringEnumeration over the locales available at the time of the call
2344b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
2345b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
2346b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    static StringEnumeration* getAvailableLocales(void);
2347b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2348b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
2349b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Register a new Calendar factory.  The factory will be adopted.
2350b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * INTERNAL in 2.6
2351fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius     *
2352fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius     * Because ICU may choose to cache Calendars internally, this must
2353fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius     * be called at application startup, prior to any calls to
2354fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius     * Calendar::createInstance to avoid undefined behavior.
2355fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius     *
2356b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param toAdopt the factory instance to be adopted
2357b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status the in/out status code, no special meanings are assigned
2358b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return a registry key that can be used to unregister this factory
2359b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
2360b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
2361b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    static URegistryKey registerFactory(ICUServiceFactory* toAdopt, UErrorCode& status);
2362b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2363b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
2364b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Unregister a previously-registered CalendarFactory using the key returned from the
2365b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * register call.  Key becomes invalid after a successful call and should not be used again.
2366b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * The CalendarFactory corresponding to the key will be deleted.
2367b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * INTERNAL in 2.6
2368fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius     *
2369fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius     * Because ICU may choose to cache Calendars internally, this should
2370fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius     * be called during application shutdown, after all calls to
2371fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius     * Calendar::createInstance to avoid undefined behavior.
2372fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius     *
2373b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param key the registry key returned by a previous call to registerFactory
2374b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status the in/out status code, no special meanings are assigned
2375b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return TRUE if the factory for the key was successfully unregistered
2376b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
2377b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
2378b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    static UBool unregister(URegistryKey key, UErrorCode& status);
2379103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif  /* U_HIDE_INTERNAL_API */
2380b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2381b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
2382b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Multiple Calendar Implementation
2383b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
2384b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
2385b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    friend class CalendarFactory;
2386b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2387b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
2388b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Multiple Calendar Implementation
2389b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
2390b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
2391b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    friend class CalendarService;
2392b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2393b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
2394b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Multiple Calendar Implementation
2395b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
2396b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
2397b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    friend class DefaultCalendarFactory;
2398b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif /* !UCONFIG_NO_SERVICE */
2399b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2400b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
2401b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return TRUE if this calendar has a default century (i.e. 03 -> 2003)
240259d709d503bab6e2b61931737e662dd293b40578ccornelius     * @internal
2403b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
2404b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual UBool haveDefaultCentury() const = 0;
2405b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2406b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
2407b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return the start of the default century, as a UDate
240859d709d503bab6e2b61931737e662dd293b40578ccornelius     * @internal
2409b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
2410b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual UDate defaultCenturyStart() const = 0;
2411b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
2412b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return the beginning year of the default century, as a year
241359d709d503bab6e2b61931737e662dd293b40578ccornelius     * @internal
2414b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
2415b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual int32_t defaultCenturyStartYear() const = 0;
2416b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2417b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /** Get the locale for this calendar object. You can choose between valid and actual locale.
2418b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *  @param type type of the locale we're looking for (valid or actual)
2419b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *  @param status error code for the operation
2420b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *  @return the locale
2421b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *  @stable ICU 2.8
2422b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
2423b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale getLocale(ULocDataLocaleType type, UErrorCode &status) const;
2424b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2425fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius    /**
2426fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius     * @return      The related Gregorian year; will be obtained by modifying the value
2427fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius     *              obtained by get from UCAL_EXTENDED_YEAR field
2428fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius     * @internal
2429fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius     */
2430fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius    virtual int32_t getRelatedYear(UErrorCode &status) const;
2431fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius
2432fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius    /**
2433fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius     * @param year  The related Gregorian year to set; will be modified as necessary then
2434fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius     *              set in UCAL_EXTENDED_YEAR field
2435fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius     * @internal
2436fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius     */
2437fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius    virtual void setRelatedYear(int32_t year);
2438fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius
2439103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_HIDE_INTERNAL_API
2440b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /** Get the locale for this calendar object. You can choose between valid and actual locale.
2441b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *  @param type type of the locale we're looking for (valid or actual)
2442b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *  @param status error code for the operation
2443b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *  @return the locale
2444b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *  @internal
2445b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
2446b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    const char* getLocaleID(ULocDataLocaleType type, UErrorCode &status) const;
2447103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif  /* U_HIDE_INTERNAL_API */
2448b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2449103e9ffba2cba345d0078eb8b8db33249f81840aCraig Corneliusprivate:
2450103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius    /**
2451103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * Cast TimeZone used by this object to BasicTimeZone, or NULL if the TimeZone
2452103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * is not an instance of BasicTimeZone.
2453103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     */
2454103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius    BasicTimeZone* getBasicTimeZone() const;
2455fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius
2456fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius    /**
2457fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius     * Find the previous zone transtion near the given time.
2458fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius     * @param base The base time, inclusive
2459fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius     * @param transitionTime Receives the result time
2460fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius     * @param status The error status
2461fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius     * @return TRUE if a transition is found.
2462fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius     */
2463fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius    UBool getImmediatePreviousZoneTransition(UDate base, UDate *transitionTime, UErrorCode& status) const;
2464b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru};
2465b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2466b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// -------------------------------------
2467b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2468b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline Calendar*
2469b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruCalendar::createInstance(TimeZone* zone, UErrorCode& errorCode)
2470b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
2471b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // since the Locale isn't specified, use the default locale
2472b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return createInstance(zone, Locale::getDefault(), errorCode);
2473b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
2474b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2475b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// -------------------------------------
2476b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2477b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline void
2478b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruCalendar::roll(UCalendarDateFields field, UBool up, UErrorCode& status)
2479b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
2480b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    roll(field, (int32_t)(up ? +1 : -1), status);
2481b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
2482b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2483103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_HIDE_DEPRECATED_API
2484b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline void
2485b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruCalendar::roll(EDateFields field, UBool up, UErrorCode& status)
2486b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
2487b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    roll((UCalendarDateFields) field, up, status);
2488b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
2489103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif
2490b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2491b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2492b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// -------------------------------------
2493b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2494b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
2495b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Fast method for subclasses.  The caller must maintain fUserSetDSTOffset and
2496b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * fUserSetZoneOffset, as well as the isSet[] array.
2497b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
2498b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2499b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline void
2500b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruCalendar::internalSet(UCalendarDateFields field, int32_t value)
2501b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
2502b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    fFields[field] = value;
2503b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    fStamp[field] = kInternallySet;
2504b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    fIsSet[field]     = TRUE; // Remove later
2505b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
2506b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2507103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius
2508103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_HIDE_INTERNAL_API
2509b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int32_t  Calendar::weekNumber(int32_t dayOfPeriod, int32_t dayOfWeek)
2510b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
2511b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  return weekNumber(dayOfPeriod, dayOfPeriod, dayOfWeek);
2512b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
2513103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif
2514b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2515b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_NAMESPACE_END
2516b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2517b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif /* #if !UCONFIG_NO_FORMATTING */
2518b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2519b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif // _CALENDAR
2520