]> git.saurik.com Git - apple/icu.git/blame - icuSources/i18n/japancal.h
ICU-62123.0.1.tar.gz
[apple/icu.git] / icuSources / i18n / japancal.h
CommitLineData
f3c0d7a5
A
1// © 2016 and later: Unicode, Inc. and others.
2// License & terms of use: http://www.unicode.org/copyright.html
b75a7d8f 3/*
46f4442e
A
4 ********************************************************************************
5 * Copyright (C) 2003-2008, International Business Machines Corporation
374ca955
A
6 * and others. All Rights Reserved.
7 ********************************************************************************
8 *
9 * File JAPANCAL.H
10 *
11 * Modification History:
12 *
13 * Date Name Description
14 * 05/13/2003 srl copied from gregocal.h
15 ********************************************************************************
16 */
b75a7d8f
A
17
18#ifndef JAPANCAL_H
19#define JAPANCAL_H
20
21#include "unicode/utypes.h"
22
23#if !UCONFIG_NO_FORMATTING
24
25#include "unicode/calendar.h"
26#include "unicode/gregocal.h"
27
28U_NAMESPACE_BEGIN
29
30/**
31 * Concrete class which provides the Japanese calendar.
32 * <P>
33 * <code>JapaneseCalendar</code> is a subclass of <code>GregorianCalendar</code>
34 * that numbers years and eras based on the reigns of the Japanese emperors.
35 * The Japanese calendar is identical to the Gregorian calendar in all respects
36 * except for the year and era. The ascension of each emperor to the throne
37 * begins a new era, and the years of that era are numbered starting with the
38 * year of ascension as year 1.
39 * <p>
40 * Note that in the year of an imperial ascension, there are two possible sets
41 * of year and era values: that for the old era and for the new. For example, a
42 * new era began on January 7, 1989 AD. Strictly speaking, the first six days
43 * of that year were in the Showa era, e.g. "January 6, 64 Showa", while the rest
44 * of the year was in the Heisei era, e.g. "January 7, 1 Heisei". This class
45 * handles this distinction correctly when computing dates. However, in lenient
46 * mode either form of date is acceptable as input.
47 * <p>
48 * In modern times, eras have started on January 8, 1868 AD, Gregorian (Meiji),
49 * July 30, 1912 (Taisho), December 25, 1926 (Showa), and January 7, 1989 (Heisei). Constants
50 * for these eras, suitable for use in the <code>UCAL_ERA</code> field, are provided
51 * in this class. Note that the <em>number</em> used for each era is more or
52 * less arbitrary. Currently, the era starting in 1053 AD is era #0; however this
53 * may change in the future as we add more historical data. Use the predefined
54 * constants rather than using actual, absolute numbers.
55 * <p>
56 * @internal
57 */
46f4442e 58class JapaneseCalendar : public GregorianCalendar {
b75a7d8f
A
59public:
60
61 /**
62 * Useful constants for JapaneseCalendar.
63 * @internal
64 */
46f4442e 65 U_I18N_API static uint32_t U_EXPORT2 getCurrentEra(void); // the current era
b75a7d8f
A
66
67 /**
68 * Constructs a JapaneseCalendar based on the current time in the default time zone
69 * with the given locale.
70 *
71 * @param aLocale The given locale.
72 * @param success Indicates the status of JapaneseCalendar object construction.
73 * Returns U_ZERO_ERROR if constructed successfully.
74 * @stable ICU 2.0
75 */
76 JapaneseCalendar(const Locale& aLocale, UErrorCode& success);
77
78
79 /**
80 * Destructor
81 * @internal
82 */
83 virtual ~JapaneseCalendar();
84
85 /**
86 * Copy constructor
87 * @param source the object to be copied.
88 * @internal
89 */
90 JapaneseCalendar(const JapaneseCalendar& source);
91
92 /**
93 * Default assignment operator
94 * @param right the object to be copied.
95 * @internal
96 */
97 JapaneseCalendar& operator=(const JapaneseCalendar& right);
98
99 /**
100 * Create and return a polymorphic copy of this calendar.
101 * @return return a polymorphic copy of this calendar.
102 * @internal
103 */
104 virtual Calendar* clone(void) const;
105
374ca955
A
106 /**
107 * Return the extended year defined by the current fields. In the
108 * Japanese calendar case, this is equal to the equivalent extended Gregorian year.
109 * @internal
110 */
111 virtual int32_t handleGetExtendedYear();
b75a7d8f 112
46f4442e
A
113 /**
114 * Return the maximum value that this field could have, given the current date.
115 * @internal
116 */
117 virtual int32_t getActualMaximum(UCalendarDateFields field, UErrorCode& status) const;
118
119
b75a7d8f 120public:
b75a7d8f
A
121 /**
122 * Override Calendar Returns a unique class ID POLYMORPHICALLY. Pure virtual
123 * override. This method is to implement a simple version of RTTI, since not all C++
124 * compilers support genuine RTTI. Polymorphic operator==() and clone() methods call
125 * this method.
126 *
127 * @return The class ID for this object. All objects of a given class have the
128 * same class ID. Objects of other classes have different class IDs.
129 * @internal
130 */
131 virtual UClassID getDynamicClassID(void) const;
132
133 /**
134 * Return the class ID for this class. This is useful only for comparing to a return
135 * value from getDynamicClassID(). For example:
136 *
137 * Base* polymorphic_pointer = createPolymorphicObject();
138 * if (polymorphic_pointer->getDynamicClassID() ==
139 * Derived::getStaticClassID()) ...
140 *
141 * @return The class ID for all objects of this class.
142 * @internal
143 */
46f4442e 144 U_I18N_API static UClassID U_EXPORT2 getStaticClassID(void);
b75a7d8f
A
145
146 /**
147 * return the calendar type, "japanese".
148 *
149 * @return calendar type
150 * @internal
151 */
152 virtual const char * getType() const;
153
154 /**
374ca955 155 * @return FALSE - no default century in Japanese
b75a7d8f 156 * @internal
b75a7d8f
A
157 */
158 virtual UBool haveDefaultCentury() const;
b75a7d8f 159
374ca955
A
160 /**
161 * Not used - no default century.
162 * @internal
163 */
164 virtual UDate defaultCenturyStart() const;
165 /**
166 * Not used - no default century.
b75a7d8f 167 * @internal
b75a7d8f 168 */
374ca955 169 virtual int32_t defaultCenturyStartYear() const;
b75a7d8f
A
170
171private:
172 JapaneseCalendar(); // default constructor not implemented
173
b75a7d8f 174protected:
374ca955
A
175 /**
176 * Calculate the era for internal computation
177 * @internal
178 */
b75a7d8f 179 virtual int32_t internalGetEra() const;
b75a7d8f
A
180
181 /**
374ca955
A
182 * Compute fields from the JD
183 * @internal
b75a7d8f 184 */
374ca955
A
185 virtual void handleComputeFields(int32_t julianDay, UErrorCode& status);
186
187 /**
188 * Calculate the limit for a specified type of limit and field
189 * @internal
190 */
191 virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const;
b75a7d8f
A
192
193 /***
194 * Called by computeJulianDay. Returns the default month (0-based) for the year,
374ca955
A
195 * taking year and era into account. Will return the first month of the given era, if
196 * the current year is an ascension year.
729e4ab9 197 * @param eyear the extended year
374ca955 198 * @internal
b75a7d8f 199 */
729e4ab9 200 virtual int32_t getDefaultMonthInYear(int32_t eyear);
b75a7d8f
A
201
202 /***
203 * Called by computeJulianDay. Returns the default day (1-based) for the month,
374ca955
A
204 * taking currently-set year and era into account. Will return the first day of the given
205 * era, if the current month is an ascension year and month.
729e4ab9
A
206 * @param eyear the extended year
207 * @param mon the month in the year
374ca955 208 * @internal
b75a7d8f 209 */
729e4ab9 210 virtual int32_t getDefaultDayInMonth(int32_t eyear, int32_t month);
b75a7d8f
A
211};
212
b75a7d8f
A
213U_NAMESPACE_END
214
215#endif /* #if !UCONFIG_NO_FORMATTING */
216
374ca955 217#endif
b75a7d8f
A
218//eof
219