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