2 ********************************************************************************
3 * Copyright (C) 2003-2008, International Business Machines Corporation
4 * and others. All Rights Reserved.
5 ********************************************************************************
9 * Modification History:
11 * Date Name Description
12 * 05/13/2003 srl copied from gregocal.h
13 ********************************************************************************
19 #include "unicode/utypes.h"
21 #if !UCONFIG_NO_FORMATTING
23 #include "unicode/calendar.h"
24 #include "unicode/gregocal.h"
29 * Concrete class which provides the Japanese calendar.
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.
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.
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.
56 class JapaneseCalendar
: public GregorianCalendar
{
60 * Useful constants for JapaneseCalendar.
63 U_I18N_API
static uint32_t U_EXPORT2
getCurrentEra(void); // the current era
66 * Constructs a JapaneseCalendar based on the current time in the default time zone
67 * with the given locale.
69 * @param aLocale The given locale.
70 * @param success Indicates the status of JapaneseCalendar object construction.
71 * Returns U_ZERO_ERROR if constructed successfully.
74 JapaneseCalendar(const Locale
& aLocale
, UErrorCode
& success
);
81 virtual ~JapaneseCalendar();
85 * @param source the object to be copied.
88 JapaneseCalendar(const JapaneseCalendar
& source
);
91 * Default assignment operator
92 * @param right the object to be copied.
95 JapaneseCalendar
& operator=(const JapaneseCalendar
& right
);
98 * Create and return a polymorphic copy of this calendar.
99 * @return return a polymorphic copy of this calendar.
102 virtual Calendar
* clone(void) const;
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.
109 virtual int32_t handleGetExtendedYear();
112 * Return the maximum value that this field could have, given the current date.
115 virtual int32_t getActualMaximum(UCalendarDateFields field
, UErrorCode
& status
) const;
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
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.
129 virtual UClassID
getDynamicClassID(void) const;
132 * Return the class ID for this class. This is useful only for comparing to a return
133 * value from getDynamicClassID(). For example:
135 * Base* polymorphic_pointer = createPolymorphicObject();
136 * if (polymorphic_pointer->getDynamicClassID() ==
137 * Derived::getStaticClassID()) ...
139 * @return The class ID for all objects of this class.
142 U_I18N_API
static UClassID U_EXPORT2
getStaticClassID(void);
145 * return the calendar type, "japanese".
147 * @return calendar type
150 virtual const char * getType() const;
153 * @return FALSE - no default century in Japanese
156 virtual UBool
haveDefaultCentury() const;
159 * Not used - no default century.
162 virtual UDate
defaultCenturyStart() const;
164 * Not used - no default century.
167 virtual int32_t defaultCenturyStartYear() const;
170 JapaneseCalendar(); // default constructor not implemented
174 * Calculate the era for internal computation
177 virtual int32_t internalGetEra() const;
180 * Compute fields from the JD
183 virtual void handleComputeFields(int32_t julianDay
, UErrorCode
& status
);
186 * Calculate the limit for a specified type of limit and field
189 virtual int32_t handleGetLimit(UCalendarDateFields field
, ELimitType limitType
) const;
192 * Called by computeJulianDay. Returns the default month (0-based) for the year,
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.
195 * @param eyear the extended year
198 virtual int32_t getDefaultMonthInYear(int32_t eyear
);
201 * Called by computeJulianDay. Returns the default day (1-based) for the month,
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.
204 * @param eyear the extended year
205 * @param mon the month in the year
208 virtual int32_t getDefaultDayInMonth(int32_t eyear
, int32_t month
);
213 #endif /* #if !UCONFIG_NO_FORMATTING */