michael@0: /* michael@0: ******************************************************************************** michael@0: * Copyright (C) 2003-2008, International Business Machines Corporation michael@0: * and others. All Rights Reserved. michael@0: ******************************************************************************** michael@0: * michael@0: * File JAPANCAL.H michael@0: * michael@0: * Modification History: michael@0: * michael@0: * Date Name Description michael@0: * 05/13/2003 srl copied from gregocal.h michael@0: ******************************************************************************** michael@0: */ michael@0: michael@0: #ifndef JAPANCAL_H michael@0: #define JAPANCAL_H michael@0: michael@0: #include "unicode/utypes.h" michael@0: michael@0: #if !UCONFIG_NO_FORMATTING michael@0: michael@0: #include "unicode/calendar.h" michael@0: #include "unicode/gregocal.h" michael@0: michael@0: U_NAMESPACE_BEGIN michael@0: michael@0: /** michael@0: * Concrete class which provides the Japanese calendar. michael@0: *
michael@0: * JapaneseCalendar
is a subclass of GregorianCalendar
michael@0: * that numbers years and eras based on the reigns of the Japanese emperors.
michael@0: * The Japanese calendar is identical to the Gregorian calendar in all respects
michael@0: * except for the year and era. The ascension of each emperor to the throne
michael@0: * begins a new era, and the years of that era are numbered starting with the
michael@0: * year of ascension as year 1.
michael@0: *
michael@0: * Note that in the year of an imperial ascension, there are two possible sets michael@0: * of year and era values: that for the old era and for the new. For example, a michael@0: * new era began on January 7, 1989 AD. Strictly speaking, the first six days michael@0: * of that year were in the Showa era, e.g. "January 6, 64 Showa", while the rest michael@0: * of the year was in the Heisei era, e.g. "January 7, 1 Heisei". This class michael@0: * handles this distinction correctly when computing dates. However, in lenient michael@0: * mode either form of date is acceptable as input. michael@0: *
michael@0: * In modern times, eras have started on January 8, 1868 AD, Gregorian (Meiji),
michael@0: * July 30, 1912 (Taisho), December 25, 1926 (Showa), and January 7, 1989 (Heisei). Constants
michael@0: * for these eras, suitable for use in the UCAL_ERA
field, are provided
michael@0: * in this class. Note that the number used for each era is more or
michael@0: * less arbitrary. Currently, the era starting in 1053 AD is era #0; however this
michael@0: * may change in the future as we add more historical data. Use the predefined
michael@0: * constants rather than using actual, absolute numbers.
michael@0: *
michael@0: * @internal michael@0: */ michael@0: class JapaneseCalendar : public GregorianCalendar { michael@0: public: michael@0: michael@0: /** michael@0: * Useful constants for JapaneseCalendar. michael@0: * @internal michael@0: */ michael@0: U_I18N_API static uint32_t U_EXPORT2 getCurrentEra(void); // the current era michael@0: michael@0: /** michael@0: * Constructs a JapaneseCalendar based on the current time in the default time zone michael@0: * with the given locale. michael@0: * michael@0: * @param aLocale The given locale. michael@0: * @param success Indicates the status of JapaneseCalendar object construction. michael@0: * Returns U_ZERO_ERROR if constructed successfully. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: JapaneseCalendar(const Locale& aLocale, UErrorCode& success); michael@0: michael@0: michael@0: /** michael@0: * Destructor michael@0: * @internal michael@0: */ michael@0: virtual ~JapaneseCalendar(); michael@0: michael@0: /** michael@0: * Copy constructor michael@0: * @param source the object to be copied. michael@0: * @internal michael@0: */ michael@0: JapaneseCalendar(const JapaneseCalendar& source); michael@0: michael@0: /** michael@0: * Default assignment operator michael@0: * @param right the object to be copied. michael@0: * @internal michael@0: */ michael@0: JapaneseCalendar& operator=(const JapaneseCalendar& right); michael@0: michael@0: /** michael@0: * Create and return a polymorphic copy of this calendar. michael@0: * @return return a polymorphic copy of this calendar. michael@0: * @internal michael@0: */ michael@0: virtual Calendar* clone(void) const; michael@0: michael@0: /** michael@0: * Return the extended year defined by the current fields. In the michael@0: * Japanese calendar case, this is equal to the equivalent extended Gregorian year. michael@0: * @internal michael@0: */ michael@0: virtual int32_t handleGetExtendedYear(); michael@0: michael@0: /** michael@0: * Return the maximum value that this field could have, given the current date. michael@0: * @internal michael@0: */ michael@0: virtual int32_t getActualMaximum(UCalendarDateFields field, UErrorCode& status) const; michael@0: michael@0: michael@0: public: michael@0: /** michael@0: * Override Calendar Returns a unique class ID POLYMORPHICALLY. Pure virtual michael@0: * override. This method is to implement a simple version of RTTI, since not all C++ michael@0: * compilers support genuine RTTI. Polymorphic operator==() and clone() methods call michael@0: * this method. michael@0: * michael@0: * @return The class ID for this object. All objects of a given class have the michael@0: * same class ID. Objects of other classes have different class IDs. michael@0: * @internal michael@0: */ michael@0: virtual UClassID getDynamicClassID(void) const; michael@0: michael@0: /** michael@0: * Return the class ID for this class. This is useful only for comparing to a return michael@0: * value from getDynamicClassID(). For example: michael@0: * michael@0: * Base* polymorphic_pointer = createPolymorphicObject(); michael@0: * if (polymorphic_pointer->getDynamicClassID() == michael@0: * Derived::getStaticClassID()) ... michael@0: * michael@0: * @return The class ID for all objects of this class. michael@0: * @internal michael@0: */ michael@0: U_I18N_API static UClassID U_EXPORT2 getStaticClassID(void); michael@0: michael@0: /** michael@0: * return the calendar type, "japanese". michael@0: * michael@0: * @return calendar type michael@0: * @internal michael@0: */ michael@0: virtual const char * getType() const; michael@0: michael@0: /** michael@0: * @return FALSE - no default century in Japanese michael@0: * @internal michael@0: */ michael@0: virtual UBool haveDefaultCentury() const; michael@0: michael@0: /** michael@0: * Not used - no default century. michael@0: * @internal michael@0: */ michael@0: virtual UDate defaultCenturyStart() const; michael@0: /** michael@0: * Not used - no default century. michael@0: * @internal michael@0: */ michael@0: virtual int32_t defaultCenturyStartYear() const; michael@0: michael@0: private: michael@0: JapaneseCalendar(); // default constructor not implemented michael@0: michael@0: protected: michael@0: /** michael@0: * Calculate the era for internal computation michael@0: * @internal michael@0: */ michael@0: virtual int32_t internalGetEra() const; michael@0: michael@0: /** michael@0: * Compute fields from the JD michael@0: * @internal michael@0: */ michael@0: virtual void handleComputeFields(int32_t julianDay, UErrorCode& status); michael@0: michael@0: /** michael@0: * Calculate the limit for a specified type of limit and field michael@0: * @internal michael@0: */ michael@0: virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const; michael@0: michael@0: /*** michael@0: * Called by computeJulianDay. Returns the default month (0-based) for the year, michael@0: * taking year and era into account. Will return the first month of the given era, if michael@0: * the current year is an ascension year. michael@0: * @param eyear the extended year michael@0: * @internal michael@0: */ michael@0: virtual int32_t getDefaultMonthInYear(int32_t eyear); michael@0: michael@0: /*** michael@0: * Called by computeJulianDay. Returns the default day (1-based) for the month, michael@0: * taking currently-set year and era into account. Will return the first day of the given michael@0: * era, if the current month is an ascension year and month. michael@0: * @param eyear the extended year michael@0: * @param mon the month in the year michael@0: * @internal michael@0: */ michael@0: virtual int32_t getDefaultDayInMonth(int32_t eyear, int32_t month); michael@0: }; michael@0: michael@0: U_NAMESPACE_END michael@0: michael@0: #endif /* #if !UCONFIG_NO_FORMATTING */ michael@0: michael@0: #endif michael@0: //eof michael@0: