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