1/* GENERATED SOURCE. DO NOT MODIFY. */
2/*
3 *******************************************************************************
4 * Copyright (C) 2005-2016, International Business Machines Corporation and    *
5 * others. All Rights Reserved.                                                *
6 *******************************************************************************
7 */
8
9package android.icu.util;
10
11import java.util.Date;
12import java.util.Locale;
13
14/**
15 * Implement the Coptic calendar system.
16 * <p>
17 * CopticCalendar usually should be instantiated using
18 * {@link android.icu.util.Calendar#getInstance(ULocale)} passing in a <code>ULocale</code>
19 * with the tag <code>"@calendar=coptic"</code>.</p>
20 *
21 * @see android.icu.util.Calendar
22 */
23public final class CopticCalendar extends CECalendar
24{
25    // jdk1.4.2 serialver
26    private static final long serialVersionUID = 5903818751846742911L;
27
28    /**
29     * Constant for ωογτ / تﻮﺗ,
30     * the 1st month of the Coptic year.
31     */
32    public static final int TOUT = 0;
33
34    /**
35     * Constant for Παοπι / ﻪﺑﺎﺑ,
36     * the 2nd month of the Coptic year.
37     */
38    public static final int BABA = 1;
39
40    /**
41     * Constant for Αθορ / رﻮﺗﺎﻫ,
42     * the 3rd month of the Coptic year.
43     */
44    public static final int HATOR = 2;
45
46    /**
47     * Constant for Χοιακ / ﻚﻬﻴﻛ;,
48     * the 4th month of the Coptic year.
49     */
50    public static final int KIAHK = 3;
51
52    /**
53     * Constant for Τωβι / طﻮﺒﻫ,
54     * the 5th month of the Coptic year.
55     */
56    public static final int TOBA = 4;
57
58    /**
59     * Constant for Μεϣιρ / ﺮﻴﺸﻣأ,
60     * the 6th month of the Coptic year.
61     */
62    public static final int AMSHIR = 5;
63
64    /**
65     * Constant for Παρεμϩατ / تﺎﻬﻣﺮﺑ,
66     * the 7th month of the Coptic year.
67     */
68    public static final int BARAMHAT = 6;
69
70    /**
71     * Constant for Φαρμοθι / هدﻮﻣﺮﺑ,
72     * the 8th month of the Coptic year.
73     */
74    public static final int BARAMOUDA = 7;
75
76    /**
77     * Constant for Παϣαν / ﺲﻨﺸﺑ;,
78     * the 9th month of the Coptic year.
79     */
80    public static final int BASHANS = 8;
81
82    /**
83     * Constant for Παωνι / ﻪﻧؤﻮﺑ,
84     * the 10th month of the Coptic year.
85     */
86    public static final int PAONA = 9;
87
88    /**
89     * Constant for Επηπ / ﺐﻴﺑأ,
90     * the 11th month of the Coptic year.
91     */
92    public static final int EPEP = 10;
93
94    /**
95     * Constant for Μεϲωρη / ىﺮﺴﻣ,
96     * the 12th month of the Coptic year.
97     */
98    public static final int MESRA = 11;
99
100    /**
101     * Constant for Πικογϫι μαβοτ / ﺮﻴﻐﺼﻟاﺮﻬﺸﻟا,
102     * the 13th month of the Coptic year.
103     */
104    public static final int NASIE = 12;
105
106    private static final int JD_EPOCH_OFFSET  = 1824665;
107
108    // Eras
109    private static final int BCE = 0;
110    private static final int CE = 1;
111
112    /**
113     * Constructs a default <code>CopticCalendar</code> using the current time
114     * in the default time zone with the default locale.
115     */
116    public CopticCalendar() {
117        super();
118    }
119
120    /**
121     * Constructs a <code>CopticCalendar</code> based on the current time
122     * in the given time zone with the default locale.
123     *
124     * @param zone The time zone for the new calendar.
125     */
126    public CopticCalendar(TimeZone zone) {
127        super(zone);
128    }
129
130    /**
131     * Constructs a <code>CopticCalendar</code> based on the current time
132     * in the default time zone with the given locale.
133     *
134     * @param aLocale The locale for the new calendar.
135     */
136    public CopticCalendar(Locale aLocale) {
137        super(aLocale);
138    }
139
140    /**
141     * Constructs a <code>CopticCalendar</code> based on the current time
142     * in the default time zone with the given locale.
143     *
144     * @param locale The icu locale for the new calendar.
145     */
146    public CopticCalendar(ULocale locale) {
147        super(locale);
148    }
149
150    /**
151     * Constructs a <code>CopticCalendar</code> based on the current time
152     * in the given time zone with the given locale.
153     *
154     * @param zone The time zone for the new calendar.
155     * @param aLocale The locale for the new calendar.
156     */
157    public CopticCalendar(TimeZone zone, Locale aLocale) {
158        super(zone, aLocale);
159    }
160
161    /**
162     * Constructs a <code>CopticCalendar</code> based on the current time
163     * in the given time zone with the given locale.
164     *
165     * @param zone The time zone for the new calendar.
166     * @param locale The icu locale for the new calendar.
167     */
168    public CopticCalendar(TimeZone zone, ULocale locale) {
169        super(zone, locale);
170    }
171
172    /**
173     * Constructs a <code>CopticCalendar</code> with the given date set
174     * in the default time zone with the default locale.
175     *
176     * @param year      The value used to set the calendar's {@link #YEAR YEAR} time field.
177     * @param month     The value used to set the calendar's {@link #MONTH MONTH} time field.
178     *                  The value is 0-based. e.g., 0 for Tout.
179     * @param date      The value used to set the calendar's {@link #DATE DATE} time field.
180     */
181    public CopticCalendar(int year, int month, int date) {
182        super(year, month, date);
183    }
184
185    /**
186     * Constructs a <code>CopticCalendar</code> with the given date set
187     * in the default time zone with the default locale.
188     *
189     * @param date      The date to which the new calendar is set.
190     */
191    public CopticCalendar(Date date) {
192        super(date);
193    }
194
195    /**
196     * Constructs a <code>CopticCalendar</code> with the given date
197     * and time set for the default time zone with the default locale.
198     *
199     * @param year      The value used to set the calendar's {@link #YEAR YEAR} time field.
200     * @param month     The value used to set the calendar's {@link #MONTH MONTH} time field.
201     *                  The value is 0-based. e.g., 0 for Tout.
202     * @param date      The value used to set the calendar's {@link #DATE DATE} time field.
203     * @param hour      The value used to set the calendar's {@link #HOUR_OF_DAY HOUR_OF_DAY} time field.
204     * @param minute    The value used to set the calendar's {@link #MINUTE MINUTE} time field.
205     * @param second    The value used to set the calendar's {@link #SECOND SECOND} time field.
206     */
207    public CopticCalendar(int year, int month, int date, int hour,
208                          int minute, int second) {
209        super(year, month, date, hour, minute, second);
210    }
211
212    /**
213     * {@inheritDoc}
214     */
215    public String getType() {
216        return "coptic";
217    }
218
219    /**
220     * {@inheritDoc}
221     * @deprecated This API is ICU internal only.
222     * @hide original deprecated declaration
223     * @hide draft / provisional / internal are hidden on Android
224     */
225    @Deprecated
226    protected int handleGetExtendedYear() {
227        int eyear;
228        if (newerField(EXTENDED_YEAR, YEAR) == EXTENDED_YEAR) {
229            eyear = internalGet(EXTENDED_YEAR, 1); // Default to year 1
230        } else {
231            // The year defaults to the epoch start, the era to AD
232            int era = internalGet(ERA, CE);
233            if (era == BCE) {
234                eyear = 1 - internalGet(YEAR, 1); // Convert to extended year
235            } else {
236                eyear = internalGet(YEAR, 1); // Default to year 1
237            }
238        }
239        return eyear;
240    }
241
242    /**
243     * {@inheritDoc}
244     * @deprecated This API is ICU internal only.
245     * @hide original deprecated declaration
246     * @hide draft / provisional / internal are hidden on Android
247     */
248    @Deprecated
249    protected void handleComputeFields(int julianDay) {
250        int era, year;
251        int[] fields = new int[3];
252        jdToCE(julianDay, getJDEpochOffset(), fields);
253
254        // fields[0] eyear
255        // fields[1] month
256        // fields[2] day
257
258        if (fields[0] <= 0) {
259            era = BCE;
260            year = 1 - fields[0];
261        } else {
262            era = CE;
263            year = fields[0];
264        }
265
266        internalSet(EXTENDED_YEAR, fields[0]);
267        internalSet(ERA, era);
268        internalSet(YEAR, year);
269        internalSet(MONTH, fields[1]);
270        internalSet(DAY_OF_MONTH, fields[2]);
271        internalSet(DAY_OF_YEAR, (30 * fields[1]) + fields[2]);
272    }
273
274    /**
275     * {@inheritDoc}
276     * @deprecated This API is ICU internal only.
277     * @hide original deprecated declaration
278     * @hide draft / provisional / internal are hidden on Android
279     */
280    @Deprecated
281    protected int getJDEpochOffset() {
282        return JD_EPOCH_OFFSET;
283    }
284
285    /**
286     * Convert an Coptic year, month, and day to a Julian day.
287     *
288     * @param year the year
289     * @param month the month
290     * @param date the day
291     * @hide draft / provisional / internal are hidden on Android
292     */
293    // The equivalent operation can be done by public Calendar API.
294    // This API was accidentally marked as @draft, but we have no good
295    // reason to keep this.  For now, we leave it as is, but may be
296    // removed in future.  2008-03-21 yoshito
297    public static int copticToJD(long year, int month, int date) {
298        return ceToJD(year, month, date, JD_EPOCH_OFFSET);
299    }
300}
301
302