]> git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/japancal.h
ICU-6.2.14.tar.gz
[apple/icu.git] / icuSources / i18n / japancal.h
1 /*
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 */
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
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();
109
110 public:
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 */
134 static UClassID U_EXPORT2 getStaticClassID(void);
135
136 /**
137 * return the calendar type, "japanese".
138 *
139 * @return calendar type
140 * @internal
141 */
142 virtual const char * getType() const;
143
144 /**
145 * @return FALSE - no default century in Japanese
146 * @internal
147 */
148 virtual UBool haveDefaultCentury() const;
149
150 /**
151 * Not used - no default century.
152 * @internal
153 */
154 virtual UDate defaultCenturyStart() const;
155 /**
156 * Not used - no default century.
157 * @internal
158 */
159 virtual int32_t defaultCenturyStartYear() const;
160
161 private:
162 JapaneseCalendar(); // default constructor not implemented
163
164 protected:
165 /**
166 * Calculate the era for internal computation
167 * @internal
168 */
169 virtual int32_t internalGetEra() const;
170
171 /**
172 * Compute fields from the JD
173 * @internal
174 */
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;
182
183 /***
184 * Called by computeJulianDay. Returns the default month (0-based) for the year,
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
188 */
189 virtual int32_t getDefaultMonthInYear();
190
191 /***
192 * Called by computeJulianDay. Returns the default day (1-based) for the month,
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
196 */
197 virtual int32_t getDefaultDayInMonth(int32_t month);
198 };
199
200 U_NAMESPACE_END
201
202 #endif /* #if !UCONFIG_NO_FORMATTING */
203
204 #endif
205 //eof
206