michael@0: /* michael@0: ******************************************************************************** michael@0: * Copyright (C) 2003-2013, International Business Machines Corporation michael@0: * and others. All Rights Reserved. michael@0: ******************************************************************************** michael@0: * michael@0: * File BUDDHCAL.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 BUDDHCAL_H michael@0: #define BUDDHCAL_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 Buddhist calendar. michael@0: *
michael@0: * BuddhistCalendar
is a subclass of GregorianCalendar
michael@0: * that numbers years since the birth of the Buddha. This is the civil calendar
michael@0: * in some predominantly Buddhist countries such as Thailand, and it is used for
michael@0: * religious purposes elsewhere.
michael@0: *
michael@0: * The Buddhist calendar is identical to the Gregorian calendar in all respects michael@0: * except for the year and era. Years are numbered since the birth of the michael@0: * Buddha in 543 BC (Gregorian), so that 1 AD (Gregorian) is equivalent to 544 michael@0: * BE (Buddhist Era) and 1998 AD is 2541 BE. michael@0: *
michael@0: * The Buddhist Calendar has only one allowable era: BE
. If the
michael@0: * calendar is not in lenient mode (see setLenient
), dates before
michael@0: * 1/1/1 BE are rejected as an illegal argument.
michael@0: *
michael@0: * @internal
michael@0: */
michael@0: class BuddhistCalendar : public GregorianCalendar {
michael@0: public:
michael@0:
michael@0: /**
michael@0: * Useful constants for BuddhistCalendar. Only one Era.
michael@0: * @internal
michael@0: */
michael@0: enum EEras {
michael@0: BE
michael@0: };
michael@0:
michael@0: /**
michael@0: * Constructs a BuddhistCalendar 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 BuddhistCalendar object construction.
michael@0: * Returns U_ZERO_ERROR if constructed successfully.
michael@0: * @internal
michael@0: */
michael@0: BuddhistCalendar(const Locale& aLocale, UErrorCode& success);
michael@0:
michael@0:
michael@0: /**
michael@0: * Destructor
michael@0: * @internal
michael@0: */
michael@0: virtual ~BuddhistCalendar();
michael@0:
michael@0: /**
michael@0: * Copy constructor
michael@0: * @param source the object to be copied.
michael@0: * @internal
michael@0: */
michael@0: BuddhistCalendar(const BuddhistCalendar& 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: BuddhistCalendar& operator=(const BuddhistCalendar& 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: 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, "buddhist".
michael@0: *
michael@0: * @return calendar type
michael@0: * @internal
michael@0: */
michael@0: virtual const char * getType() const;
michael@0:
michael@0: private:
michael@0: BuddhistCalendar(); // default constructor not implemented
michael@0:
michael@0: protected:
michael@0: /**
michael@0: * Return the extended year defined by the current fields. This will
michael@0: * use the UCAL_EXTENDED_YEAR field or the UCAL_YEAR and supra-year fields (such
michael@0: * as UCAL_ERA) specific to the calendar system, depending on which set of
michael@0: * fields is newer.
michael@0: * @return the extended year
michael@0: * @internal
michael@0: */
michael@0: virtual int32_t handleGetExtendedYear();
michael@0: /**
michael@0: * Subclasses may override this method to compute several fields
michael@0: * specific to each calendar system.
michael@0: * @internal
michael@0: */
michael@0: virtual void handleComputeFields(int32_t julianDay, UErrorCode& status);
michael@0: /**
michael@0: * Subclass API for defining limits of different types.
michael@0: * @param field one of the field numbers
michael@0: * @param limitType one of MINIMUM
, GREATEST_MINIMUM
,
michael@0: * LEAST_MAXIMUM
, or MAXIMUM
michael@0: * @internal
michael@0: */
michael@0: virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const;
michael@0: /**
michael@0: * Return the Julian day number of day before the first day of the
michael@0: * given month in the given extended year. Subclasses should override
michael@0: * this method to implement their calendar system.
michael@0: * @param eyear the extended year
michael@0: * @param month the zero-based month, or 0 if useMonth is false
michael@0: * @param useMonth if false, compute the day before the first day of
michael@0: * the given year, otherwise, compute the day before the first day of
michael@0: * the given month
michael@0: * @param return the Julian day number of the day before the first
michael@0: * day of the given month and year
michael@0: * @internal
michael@0: */
michael@0: virtual int32_t handleComputeMonthStart(int32_t eyear, int32_t month,
michael@0: UBool useMonth) const;
michael@0:
michael@0: /**
michael@0: * Returns TRUE because the Buddhist Calendar does have a default century
michael@0: * @internal
michael@0: */
michael@0: virtual UBool haveDefaultCentury() const;
michael@0:
michael@0: /**
michael@0: * Returns the date of the start of the default century
michael@0: * @return start of century - in milliseconds since epoch, 1970
michael@0: * @internal
michael@0: */
michael@0: virtual UDate defaultCenturyStart() const;
michael@0:
michael@0: /**
michael@0: * Returns the year in which the default century begins
michael@0: * @internal
michael@0: */
michael@0: virtual int32_t defaultCenturyStartYear() const;
michael@0: };
michael@0:
michael@0: U_NAMESPACE_END
michael@0:
michael@0: #endif /* #if !UCONFIG_NO_FORMATTING */
michael@0:
michael@0: #endif // _GREGOCAL
michael@0: //eof
michael@0: