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