11cb0ef41Sopenharmony_ci// © 2016 and later: Unicode, Inc. and others. 21cb0ef41Sopenharmony_ci// License & terms of use: http://www.unicode.org/copyright.html 31cb0ef41Sopenharmony_ci/* 41cb0ef41Sopenharmony_ci ******************************************************************************** 51cb0ef41Sopenharmony_ci * Copyright (C) 2003-2013, International Business Machines Corporation 61cb0ef41Sopenharmony_ci * and others. All Rights Reserved. 71cb0ef41Sopenharmony_ci ******************************************************************************** 81cb0ef41Sopenharmony_ci * 91cb0ef41Sopenharmony_ci * File BUDDHCAL.H 101cb0ef41Sopenharmony_ci * 111cb0ef41Sopenharmony_ci * Modification History: 121cb0ef41Sopenharmony_ci * 131cb0ef41Sopenharmony_ci * Date Name Description 141cb0ef41Sopenharmony_ci * 05/13/2003 srl copied from gregocal.h 151cb0ef41Sopenharmony_ci ******************************************************************************** 161cb0ef41Sopenharmony_ci */ 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_ci#ifndef BUDDHCAL_H 191cb0ef41Sopenharmony_ci#define BUDDHCAL_H 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ci#include "unicode/utypes.h" 221cb0ef41Sopenharmony_ci 231cb0ef41Sopenharmony_ci#if !UCONFIG_NO_FORMATTING 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_ci#include "unicode/calendar.h" 261cb0ef41Sopenharmony_ci#include "unicode/gregocal.h" 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_ciU_NAMESPACE_BEGIN 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_ci/** 311cb0ef41Sopenharmony_ci * Concrete class which provides the Buddhist calendar. 321cb0ef41Sopenharmony_ci * <P> 331cb0ef41Sopenharmony_ci * <code>BuddhistCalendar</code> is a subclass of <code>GregorianCalendar</code> 341cb0ef41Sopenharmony_ci * that numbers years since the birth of the Buddha. This is the civil calendar 351cb0ef41Sopenharmony_ci * in some predominantly Buddhist countries such as Thailand, and it is used for 361cb0ef41Sopenharmony_ci * religious purposes elsewhere. 371cb0ef41Sopenharmony_ci * <p> 381cb0ef41Sopenharmony_ci * The Buddhist calendar is identical to the Gregorian calendar in all respects 391cb0ef41Sopenharmony_ci * except for the year and era. Years are numbered since the birth of the 401cb0ef41Sopenharmony_ci * Buddha in 543 BC (Gregorian), so that 1 AD (Gregorian) is equivalent to 544 411cb0ef41Sopenharmony_ci * BE (Buddhist Era) and 1998 AD is 2541 BE. 421cb0ef41Sopenharmony_ci * <p> 431cb0ef41Sopenharmony_ci * The Buddhist Calendar has only one allowable era: <code>BE</code>. If the 441cb0ef41Sopenharmony_ci * calendar is not in lenient mode (see <code>setLenient</code>), dates before 451cb0ef41Sopenharmony_ci * 1/1/1 BE are rejected as an illegal argument. 461cb0ef41Sopenharmony_ci * <p> 471cb0ef41Sopenharmony_ci * @internal 481cb0ef41Sopenharmony_ci */ 491cb0ef41Sopenharmony_ciclass BuddhistCalendar : public GregorianCalendar { 501cb0ef41Sopenharmony_cipublic: 511cb0ef41Sopenharmony_ci 521cb0ef41Sopenharmony_ci /** 531cb0ef41Sopenharmony_ci * Useful constants for BuddhistCalendar. Only one Era. 541cb0ef41Sopenharmony_ci * @internal 551cb0ef41Sopenharmony_ci */ 561cb0ef41Sopenharmony_ci enum EEras { 571cb0ef41Sopenharmony_ci BE 581cb0ef41Sopenharmony_ci }; 591cb0ef41Sopenharmony_ci 601cb0ef41Sopenharmony_ci /** 611cb0ef41Sopenharmony_ci * Constructs a BuddhistCalendar based on the current time in the default time zone 621cb0ef41Sopenharmony_ci * with the given locale. 631cb0ef41Sopenharmony_ci * 641cb0ef41Sopenharmony_ci * @param aLocale The given locale. 651cb0ef41Sopenharmony_ci * @param success Indicates the status of BuddhistCalendar object construction. 661cb0ef41Sopenharmony_ci * Returns U_ZERO_ERROR if constructed successfully. 671cb0ef41Sopenharmony_ci * @internal 681cb0ef41Sopenharmony_ci */ 691cb0ef41Sopenharmony_ci BuddhistCalendar(const Locale& aLocale, UErrorCode& success); 701cb0ef41Sopenharmony_ci 711cb0ef41Sopenharmony_ci 721cb0ef41Sopenharmony_ci /** 731cb0ef41Sopenharmony_ci * Destructor 741cb0ef41Sopenharmony_ci * @internal 751cb0ef41Sopenharmony_ci */ 761cb0ef41Sopenharmony_ci virtual ~BuddhistCalendar(); 771cb0ef41Sopenharmony_ci 781cb0ef41Sopenharmony_ci /** 791cb0ef41Sopenharmony_ci * Copy constructor 801cb0ef41Sopenharmony_ci * @param source the object to be copied. 811cb0ef41Sopenharmony_ci * @internal 821cb0ef41Sopenharmony_ci */ 831cb0ef41Sopenharmony_ci BuddhistCalendar(const BuddhistCalendar& source); 841cb0ef41Sopenharmony_ci 851cb0ef41Sopenharmony_ci /** 861cb0ef41Sopenharmony_ci * Default assignment operator 871cb0ef41Sopenharmony_ci * @param right the object to be copied. 881cb0ef41Sopenharmony_ci * @internal 891cb0ef41Sopenharmony_ci */ 901cb0ef41Sopenharmony_ci BuddhistCalendar& operator=(const BuddhistCalendar& right); 911cb0ef41Sopenharmony_ci 921cb0ef41Sopenharmony_ci /** 931cb0ef41Sopenharmony_ci * Create and return a polymorphic copy of this calendar. 941cb0ef41Sopenharmony_ci * @return return a polymorphic copy of this calendar. 951cb0ef41Sopenharmony_ci * @internal 961cb0ef41Sopenharmony_ci */ 971cb0ef41Sopenharmony_ci virtual BuddhistCalendar* clone() const override; 981cb0ef41Sopenharmony_ci 991cb0ef41Sopenharmony_cipublic: 1001cb0ef41Sopenharmony_ci /** 1011cb0ef41Sopenharmony_ci * Override Calendar Returns a unique class ID POLYMORPHICALLY. Pure virtual 1021cb0ef41Sopenharmony_ci * override. This method is to implement a simple version of RTTI, since not all C++ 1031cb0ef41Sopenharmony_ci * compilers support genuine RTTI. Polymorphic operator==() and clone() methods call 1041cb0ef41Sopenharmony_ci * this method. 1051cb0ef41Sopenharmony_ci * 1061cb0ef41Sopenharmony_ci * @return The class ID for this object. All objects of a given class have the 1071cb0ef41Sopenharmony_ci * same class ID. Objects of other classes have different class IDs. 1081cb0ef41Sopenharmony_ci * @internal 1091cb0ef41Sopenharmony_ci */ 1101cb0ef41Sopenharmony_ci virtual UClassID getDynamicClassID() const override; 1111cb0ef41Sopenharmony_ci 1121cb0ef41Sopenharmony_ci /** 1131cb0ef41Sopenharmony_ci * Return the class ID for this class. This is useful only for comparing to a return 1141cb0ef41Sopenharmony_ci * value from getDynamicClassID(). For example: 1151cb0ef41Sopenharmony_ci * 1161cb0ef41Sopenharmony_ci * Base* polymorphic_pointer = createPolymorphicObject(); 1171cb0ef41Sopenharmony_ci * if (polymorphic_pointer->getDynamicClassID() == 1181cb0ef41Sopenharmony_ci * Derived::getStaticClassID()) ... 1191cb0ef41Sopenharmony_ci * 1201cb0ef41Sopenharmony_ci * @return The class ID for all objects of this class. 1211cb0ef41Sopenharmony_ci * @internal 1221cb0ef41Sopenharmony_ci */ 1231cb0ef41Sopenharmony_ci U_I18N_API static UClassID U_EXPORT2 getStaticClassID(); 1241cb0ef41Sopenharmony_ci 1251cb0ef41Sopenharmony_ci /** 1261cb0ef41Sopenharmony_ci * return the calendar type, "buddhist". 1271cb0ef41Sopenharmony_ci * 1281cb0ef41Sopenharmony_ci * @return calendar type 1291cb0ef41Sopenharmony_ci * @internal 1301cb0ef41Sopenharmony_ci */ 1311cb0ef41Sopenharmony_ci virtual const char * getType() const override; 1321cb0ef41Sopenharmony_ci 1331cb0ef41Sopenharmony_ciprivate: 1341cb0ef41Sopenharmony_ci BuddhistCalendar(); // default constructor not implemented 1351cb0ef41Sopenharmony_ci 1361cb0ef41Sopenharmony_ci protected: 1371cb0ef41Sopenharmony_ci /** 1381cb0ef41Sopenharmony_ci * Return the extended year defined by the current fields. This will 1391cb0ef41Sopenharmony_ci * use the UCAL_EXTENDED_YEAR field or the UCAL_YEAR and supra-year fields (such 1401cb0ef41Sopenharmony_ci * as UCAL_ERA) specific to the calendar system, depending on which set of 1411cb0ef41Sopenharmony_ci * fields is newer. 1421cb0ef41Sopenharmony_ci * @return the extended year 1431cb0ef41Sopenharmony_ci * @internal 1441cb0ef41Sopenharmony_ci */ 1451cb0ef41Sopenharmony_ci virtual int32_t handleGetExtendedYear() override; 1461cb0ef41Sopenharmony_ci /** 1471cb0ef41Sopenharmony_ci * Subclasses may override this method to compute several fields 1481cb0ef41Sopenharmony_ci * specific to each calendar system. 1491cb0ef41Sopenharmony_ci * @internal 1501cb0ef41Sopenharmony_ci */ 1511cb0ef41Sopenharmony_ci virtual void handleComputeFields(int32_t julianDay, UErrorCode& status) override; 1521cb0ef41Sopenharmony_ci /** 1531cb0ef41Sopenharmony_ci * Subclass API for defining limits of different types. 1541cb0ef41Sopenharmony_ci * @param field one of the field numbers 1551cb0ef41Sopenharmony_ci * @param limitType one of <code>MINIMUM</code>, <code>GREATEST_MINIMUM</code>, 1561cb0ef41Sopenharmony_ci * <code>LEAST_MAXIMUM</code>, or <code>MAXIMUM</code> 1571cb0ef41Sopenharmony_ci * @internal 1581cb0ef41Sopenharmony_ci */ 1591cb0ef41Sopenharmony_ci virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const override; 1601cb0ef41Sopenharmony_ci 1611cb0ef41Sopenharmony_ci /** 1621cb0ef41Sopenharmony_ci * Returns true because the Buddhist Calendar does have a default century 1631cb0ef41Sopenharmony_ci * @internal 1641cb0ef41Sopenharmony_ci */ 1651cb0ef41Sopenharmony_ci virtual UBool haveDefaultCentury() const override; 1661cb0ef41Sopenharmony_ci 1671cb0ef41Sopenharmony_ci /** 1681cb0ef41Sopenharmony_ci * Returns the date of the start of the default century 1691cb0ef41Sopenharmony_ci * @return start of century - in milliseconds since epoch, 1970 1701cb0ef41Sopenharmony_ci * @internal 1711cb0ef41Sopenharmony_ci */ 1721cb0ef41Sopenharmony_ci virtual UDate defaultCenturyStart() const override; 1731cb0ef41Sopenharmony_ci 1741cb0ef41Sopenharmony_ci /** 1751cb0ef41Sopenharmony_ci * Returns the year in which the default century begins 1761cb0ef41Sopenharmony_ci * @internal 1771cb0ef41Sopenharmony_ci */ 1781cb0ef41Sopenharmony_ci virtual int32_t defaultCenturyStartYear() const override; 1791cb0ef41Sopenharmony_ci}; 1801cb0ef41Sopenharmony_ci 1811cb0ef41Sopenharmony_ciU_NAMESPACE_END 1821cb0ef41Sopenharmony_ci 1831cb0ef41Sopenharmony_ci#endif /* #if !UCONFIG_NO_FORMATTING */ 1841cb0ef41Sopenharmony_ci 1851cb0ef41Sopenharmony_ci#endif // _GREGOCAL 1861cb0ef41Sopenharmony_ci//eof 1871cb0ef41Sopenharmony_ci 188