2 * Copyright (C) 2003-2004, International Business Machines Corporation
3 * and others. All Rights Reserved.
4 ********************************************************************************
8 * Modification History:
10 * Date Name Description
11 * 05/13/2003 srl copied from gregocal.h
12 ********************************************************************************
18 #include "unicode/utypes.h"
20 #if !UCONFIG_NO_FORMATTING
22 #include "unicode/calendar.h"
23 #include "unicode/gregocal.h"
28 * Concrete class which provides the Japanese calendar.
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.
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.
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.
55 class U_I18N_API JapaneseCalendar
: public GregorianCalendar
{
59 * Useful constants for JapaneseCalendar.
62 static const uint32_t kCurrentEra
; // the current era
65 * Constructs a JapaneseCalendar based on the current time in the default time zone
66 * with the given locale.
68 * @param aLocale The given locale.
69 * @param success Indicates the status of JapaneseCalendar object construction.
70 * Returns U_ZERO_ERROR if constructed successfully.
73 JapaneseCalendar(const Locale
& aLocale
, UErrorCode
& success
);
80 virtual ~JapaneseCalendar();
84 * @param source the object to be copied.
87 JapaneseCalendar(const JapaneseCalendar
& source
);
90 * Default assignment operator
91 * @param right the object to be copied.
94 JapaneseCalendar
& operator=(const JapaneseCalendar
& right
);
97 * Create and return a polymorphic copy of this calendar.
98 * @return return a polymorphic copy of this calendar.
101 virtual Calendar
* clone(void) const;
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.
108 virtual int32_t handleGetExtendedYear();
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
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.
121 virtual UClassID
getDynamicClassID(void) const;
124 * Return the class ID for this class. This is useful only for comparing to a return
125 * value from getDynamicClassID(). For example:
127 * Base* polymorphic_pointer = createPolymorphicObject();
128 * if (polymorphic_pointer->getDynamicClassID() ==
129 * Derived::getStaticClassID()) ...
131 * @return The class ID for all objects of this class.
134 static UClassID U_EXPORT2
getStaticClassID(void);
137 * return the calendar type, "japanese".
139 * @return calendar type
142 virtual const char * getType() const;
145 * @return FALSE - no default century in Japanese
148 virtual UBool
haveDefaultCentury() const;
151 * Not used - no default century.
154 virtual UDate
defaultCenturyStart() const;
156 * Not used - no default century.
159 virtual int32_t defaultCenturyStartYear() const;
162 JapaneseCalendar(); // default constructor not implemented
166 * Calculate the era for internal computation
169 virtual int32_t internalGetEra() const;
172 * Compute fields from the JD
175 virtual void handleComputeFields(int32_t julianDay
, UErrorCode
& status
);
178 * Calculate the limit for a specified type of limit and field
181 virtual int32_t handleGetLimit(UCalendarDateFields field
, ELimitType limitType
) const;
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.
189 virtual int32_t getDefaultMonthInYear();
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.
197 virtual int32_t getDefaultDayInMonth(int32_t month
);
202 #endif /* #if !UCONFIG_NO_FORMATTING */