1ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/*
2ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ******************************************************************************
385bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * Copyright (C) 2003-2008, International Business Machines Corporation
4ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * and others. All Rights Reserved.
5ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ******************************************************************************
6ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
7ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * File PERSNCAL.H
8ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
9ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Modification History:
10ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
11ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *   Date        Name        Description
12ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *   9/23/2003 mehran        posted to icu-design
13ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *****************************************************************************
14ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
15ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
16ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#ifndef PERSNCAL_H
17ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define PERSNCAL_H
18ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
19ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/utypes.h"
20ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
21ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#if !UCONFIG_NO_FORMATTING
22ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
23ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/calendar.h"
24ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
25ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_NAMESPACE_BEGIN
26ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
27ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/**
28ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>PersianCalendar</code> is a subclass of <code>Calendar</code>
29ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * that implements the Persian calendar.  It is used as the official
30ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * calendar in Iran.  This calendar is also known as the "Hijri Shamsi"
31ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * calendar, since it starts at the time of Mohammed's emigration (or
32ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * "hijra") to Medinah on Thursday, July 15, 622 AD (Julian) and is a
33ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * solar calendar system (or "shamsi").
34ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>
35ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * The Persian calendar is strictly solar, and thus a Persian year has twelve
36ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * solar months. A Persian year is about 365 days long, except in leap years
37ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * which is 366 days long.
38ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>
39ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * The six first months of Persian Calendar are 31 days long. The next five
40ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * months are 30 days long. The last month is 29 days long in normal years,
41ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * and 30 days long in leap years.
42ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
43ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see GregorianCalendar
44ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
45ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @author Mehran Mehr
46ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @internal
47ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
48ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass PersianCalendar : public Calendar {
49ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru public:
50ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  //-------------------------------------------------------------------------
51ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  // Constants...
52ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  //-------------------------------------------------------------------------
53ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
54ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Constants for the months
55ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @internal
56ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
57ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  enum EMonths {
58ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
59ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Constant for Farvardin, the 1st month of the Persian year.
60ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @internal
61ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
62ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    FARVARDIN = 0,
63ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
64ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
65ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Constant for Ordibehesht, the 2nd month of the Persian year.
66ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @internal
67ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
68ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    ORDIBEHESHT = 1,
69ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
70ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
71ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Constant for Khordad, the 3rd month of the Persian year.
72ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @internal
73ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
74ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    KHORDAD = 2,
75ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
76ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
77ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Constant for Tir, the 4th month of the Persian year.
78ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @internal
79ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
80ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    TIR = 3,
81ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
82ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
83ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Constant for Mordad, the 5th month of the Persian year.
84ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @internal
85ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
86ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    MORDAD = 4,
87ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
88ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
89ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Constant for Shahrivar, the 6th month of the Persian year.
90ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @internal
91ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
92ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    SHAHRIVAR = 5,
93ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
94ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
95ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Constant for Mehr, the 7th month of the Persian year.
96ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @internal
97ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
98ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    MEHR = 6,
99ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
100ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
101ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Constant for Aban, the 8th month of the Persian year.
102ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @internal
103ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
104ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    ABAN = 7,
105ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
106ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
107ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Constant for Azar, the 9th month of the Persian year.
108ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @internal
109ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
110ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    AZAR = 8,
111ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
112ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
113ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Constant for Dei, the 10th month of the Persian year.
114ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @internal
115ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
116ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    DEI = 9,
117ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
118ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
119ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Constant for Bahman, the 11th month of the Persian year.
120ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @internal
121ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
122ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    BAHMAN = 10,
123ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
124ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
125ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Constant for Esfand, the 12th month of the Persian year.
126ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @internal
127ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
128ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    ESFAND = 11,
129ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
130ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    PERSIAN_MONTH_MAX
131ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  };
132ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
133ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
134ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
135ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  //-------------------------------------------------------------------------
136ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  // Constructors...
137ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  //-------------------------------------------------------------------------
138ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
139ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
140ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Constructs a PersianCalendar based on the current time in the default time zone
141ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * with the given locale.
142ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   *
143ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @param aLocale  The given locale.
144ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @param success  Indicates the status of PersianCalendar object construction.
145ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   *                 Returns U_ZERO_ERROR if constructed successfully.
146ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @internal
147ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
148ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  PersianCalendar(const Locale& aLocale, UErrorCode &success);
149ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
150ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
151ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Copy Constructor
152ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @internal
153ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
154ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  PersianCalendar(const PersianCalendar& other);
155ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
156ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
157ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Destructor.
158ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @internal
159ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
160ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual ~PersianCalendar();
161ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
162ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  // TODO: copy c'tor, etc
163ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
164ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  // clone
165ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual Calendar* clone() const;
166ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
167ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru private:
168ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
169ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Determine whether a year is a leap year in the Persian calendar
170ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
171ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  static UBool isLeapYear(int32_t year);
172ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
173ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
174ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Return the day # on which the given year starts.  Days are counted
175ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * from the Hijri epoch, origin 0.
176ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
177ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  int32_t yearStart(int32_t year);
178ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
179ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
180ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Return the day # on which the given month starts.  Days are counted
181ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * from the Hijri epoch, origin 0.
182ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   *
183ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @param year  The hijri shamsi year
184ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @param year  The hijri shamsi month, 0-based
185ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
186ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  int32_t monthStart(int32_t year, int32_t month) const;
187ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
188ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  //----------------------------------------------------------------------
189ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  // Calendar framework
190ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  //----------------------------------------------------------------------
191ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru protected:
192ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
193ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @internal
194ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
195ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const;
196ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
197ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
198ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Return the length (in days) of the given month.
199ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   *
200ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @param year  The hijri shamsi year
201ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @param year  The hijri shamsi month, 0-based
202ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @internal
203ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
204ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual int32_t handleGetMonthLength(int32_t extendedYear, int32_t month) const;
205ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
206ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
207ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Return the number of days in the given Persian year
208ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @internal
209ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
210ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual int32_t handleGetYearLength(int32_t extendedYear) const;
211ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
212ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  //-------------------------------------------------------------------------
213ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  // Functions for converting from field values to milliseconds....
214ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  //-------------------------------------------------------------------------
215ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
216ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  // Return JD of start of given month/year
217ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
218ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @internal
219ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
220ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual int32_t handleComputeMonthStart(int32_t eyear, int32_t month, UBool useMonth) const;
221ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
222ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  //-------------------------------------------------------------------------
223ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  // Functions for converting from milliseconds to field values
224ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  //-------------------------------------------------------------------------
225ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
226ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
227ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @internal
228ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
229ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual int32_t handleGetExtendedYear();
230ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
231ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
232ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Override Calendar to compute several fields specific to the Persian
233ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * calendar system.  These are:
234ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   *
235ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * <ul><li>ERA
236ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * <li>YEAR
237ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * <li>MONTH
238ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * <li>DAY_OF_MONTH
239ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * <li>DAY_OF_YEAR
240ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * <li>EXTENDED_YEAR</ul>
241ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   *
242ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * The DAY_OF_WEEK and DOW_LOCAL fields are already set when this
243ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * method is called. The getGregorianXxx() methods return Gregorian
244ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * calendar equivalents for the given Julian day.
245ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @internal
246ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
247ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual void handleComputeFields(int32_t julianDay, UErrorCode &status);
248ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
249ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  // UObject stuff
250ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru public:
251ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
252ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @return   The class ID for this object. All objects of a given class have the
253ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   *           same class ID. Objects of other classes have different class IDs.
254ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @internal
255ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
256ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual UClassID getDynamicClassID(void) const;
257ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
258ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
259ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Return the class ID for this class. This is useful only for comparing to a return
260ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * value from getDynamicClassID(). For example:
261ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   *
262ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   *      Base* polymorphic_pointer = createPolymorphicObject();
263ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   *      if (polymorphic_pointer->getDynamicClassID() ==
264ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   *          Derived::getStaticClassID()) ...
265ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   *
266ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @return   The class ID for all objects of this class.
267ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @internal
268ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
269ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  U_I18N_API static UClassID U_EXPORT2 getStaticClassID(void);
270ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
271ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
272ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * return the calendar type, "persian".
273ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   *
274ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @return calendar type
275ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @internal
276ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
277ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual const char * getType() const;
278ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
279ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru private:
280ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  PersianCalendar(); // default constructor not implemented
281ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
282ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru protected:
283ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
284ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
285ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * (Overrides Calendar) Return true if the current date for this Calendar is in
286ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * Daylight Savings Time. Recognizes DST_OFFSET, if it is set.
287ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   *
288ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @param status Fill-in parameter which receives the status of this operation.
289ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @return   True if the current date for this Calendar is in Daylight Savings Time,
290ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   *           false, otherwise.
291ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @internal
292ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
293ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual UBool inDaylightTime(UErrorCode& status) const;
294ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
295ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
29685bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho   * Returns TRUE because the Persian Calendar does have a default century
297ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @internal
298ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
299ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual UBool haveDefaultCentury() const;
300ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
301ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
30285bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho   * Returns the date of the start of the default century
30385bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho   * @return start of century - in milliseconds since epoch, 1970
304ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @internal
305ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
306ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual UDate defaultCenturyStart() const;
307ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
308ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  /**
30985bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho   * Returns the year in which the default century begins
310ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   * @internal
311ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   */
312ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  virtual int32_t defaultCenturyStartYear() const;
313ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
31485bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho private: // default century stuff.
31585bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho  /**
31685bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho   * The system maintains a static default century start date.  This is initialized
31785bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho   * the first time it is used.  Before then, it is set to SYSTEM_DEFAULT_CENTURY to
31885bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho   * indicate an uninitialized state.  Once the system default century date and year
31985bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho   * are set, they do not change.
32085bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho   */
32185bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho  static UDate         fgSystemDefaultCenturyStart;
32285bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho
32385bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho  /**
32485bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho   * See documentation for systemDefaultCenturyStart.
32585bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho   */
32685bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho  static int32_t          fgSystemDefaultCenturyStartYear;
32785bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho
32885bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho  /**
32985bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho   * Default value that indicates the defaultCenturyStartYear is unitialized
33085bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho   */
33185bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho  static const int32_t    fgSystemDefaultCenturyYear;
33285bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho
33385bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho  /**
33485bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho   * start of default century, as a date
33585bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho   */
33685bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho  static const UDate        fgSystemDefaultCentury;
33785bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho
33885bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho  /**
33985bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho   * Returns the beginning date of the 100-year window that dates
34085bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho   * with 2-digit years are considered to fall within.
34185bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho   */
34285bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho  UDate         internalGetDefaultCenturyStart(void) const;
34385bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho
34485bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho  /**
34585bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho   * Returns the first year of the 100-year window that dates with
34685bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho   * 2-digit years are considered to fall within.
34785bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho   */
34885bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho  int32_t          internalGetDefaultCenturyStartYear(void) const;
34985bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho
35085bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho  /**
35185bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho   * Initializes the 100-year window that dates with 2-digit years
35285bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho   * are considered to fall within so that its start date is 80 years
35385bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho   * before the current time.
35485bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho   */
35585bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho  static void  initializeSystemDefaultCentury(void);
356ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru};
357ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
358ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_NAMESPACE_END
359ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
360ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif
361ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif
362ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
363ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
364ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
365