1 // © 2016 and later: Unicode, Inc. and others. 2 // License & terms of use: http://www.unicode.org/copyright.html 3 /* 4 ******************************************************************************** 5 * Copyright (C) 2003-2013, International Business Machines Corporation 6 * and others. All Rights Reserved. 7 ******************************************************************************** 8 * 9 * File BUDDHCAL.H 10 * 11 * Modification History: 12 * 13 * Date Name Description 14 * 05/13/2003 srl copied from gregocal.h 15 ******************************************************************************** 16 */ 17 18 #ifndef BUDDHCAL_H 19 #define BUDDHCAL_H 20 21 #include "unicode/utypes.h" 22 23 #if !UCONFIG_NO_FORMATTING 24 25 #include "unicode/calendar.h" 26 #include "unicode/gregocal.h" 27 28 U_NAMESPACE_BEGIN 29 30 /** 31 * Concrete class which provides the Buddhist calendar. 32 * <P> 33 * <code>BuddhistCalendar</code> is a subclass of <code>GregorianCalendar</code> 34 * that numbers years since the birth of the Buddha. This is the civil calendar 35 * in some predominantly Buddhist countries such as Thailand, and it is used for 36 * religious purposes elsewhere. 37 * <p> 38 * The Buddhist calendar is identical to the Gregorian calendar in all respects 39 * except for the year and era. Years are numbered since the birth of the 40 * Buddha in 543 BC (Gregorian), so that 1 AD (Gregorian) is equivalent to 544 41 * BE (Buddhist Era) and 1998 AD is 2541 BE. 42 * <p> 43 * The Buddhist Calendar has only one allowable era: <code>BE</code>. If the 44 * calendar is not in lenient mode (see <code>setLenient</code>), dates before 45 * 1/1/1 BE are rejected as an illegal argument. 46 * <p> 47 * @internal 48 */ 49 class BuddhistCalendar : public GregorianCalendar { 50 public: 51 52 /** 53 * Useful constants for BuddhistCalendar. Only one Era. 54 * @internal 55 */ 56 enum EEras { 57 BE 58 }; 59 60 /** 61 * Constructs a BuddhistCalendar based on the current time in the default time zone 62 * with the given locale. 63 * 64 * @param aLocale The given locale. 65 * @param success Indicates the status of BuddhistCalendar object construction. 66 * Returns U_ZERO_ERROR if constructed successfully. 67 * @internal 68 */ 69 BuddhistCalendar(const Locale& aLocale, UErrorCode& success); 70 71 72 /** 73 * Destructor 74 * @internal 75 */ 76 virtual ~BuddhistCalendar(); 77 78 /** 79 * Copy constructor 80 * @param source the object to be copied. 81 * @internal 82 */ 83 BuddhistCalendar(const BuddhistCalendar& source); 84 85 /** 86 * Default assignment operator 87 * @param right the object to be copied. 88 * @internal 89 */ 90 BuddhistCalendar& operator=(const BuddhistCalendar& right); 91 92 /** 93 * Create and return a polymorphic copy of this calendar. 94 * @return return a polymorphic copy of this calendar. 95 * @internal 96 */ 97 virtual BuddhistCalendar* clone() const override; 98 99 public: 100 /** 101 * Override Calendar Returns a unique class ID POLYMORPHICALLY. Pure virtual 102 * override. This method is to implement a simple version of RTTI, since not all C++ 103 * compilers support genuine RTTI. Polymorphic operator==() and clone() methods call 104 * this method. 105 * 106 * @return The class ID for this object. All objects of a given class have the 107 * same class ID. Objects of other classes have different class IDs. 108 * @internal 109 */ 110 virtual UClassID getDynamicClassID(void) const override; 111 112 /** 113 * Return the class ID for this class. This is useful only for comparing to a return 114 * value from getDynamicClassID(). For example: 115 * 116 * Base* polymorphic_pointer = createPolymorphicObject(); 117 * if (polymorphic_pointer->getDynamicClassID() == 118 * Derived::getStaticClassID()) ... 119 * 120 * @return The class ID for all objects of this class. 121 * @internal 122 */ 123 U_I18N_API static UClassID U_EXPORT2 getStaticClassID(void); 124 125 /** 126 * return the calendar type, "buddhist". 127 * 128 * @return calendar type 129 * @internal 130 */ 131 virtual const char * getType() const override; 132 133 private: 134 BuddhistCalendar(); // default constructor not implemented 135 136 protected: 137 /** 138 * Return the extended year defined by the current fields. This will 139 * use the UCAL_EXTENDED_YEAR field or the UCAL_YEAR and supra-year fields (such 140 * as UCAL_ERA) specific to the calendar system, depending on which set of 141 * fields is newer. 142 * @return the extended year 143 * @internal 144 */ 145 virtual int32_t handleGetExtendedYear() override; 146 /** 147 * Subclasses may override this method to compute several fields 148 * specific to each calendar system. 149 * @internal 150 */ 151 virtual void handleComputeFields(int32_t julianDay, UErrorCode& status) override; 152 /** 153 * Subclass API for defining limits of different types. 154 * @param field one of the field numbers 155 * @param limitType one of <code>MINIMUM</code>, <code>GREATEST_MINIMUM</code>, 156 * <code>LEAST_MAXIMUM</code>, or <code>MAXIMUM</code> 157 * @internal 158 */ 159 virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const override; 160 /** 161 * Return the Julian day number of day before the first day of the 162 * given month in the given extended year. Subclasses should override 163 * this method to implement their calendar system. 164 * @param eyear the extended year 165 * @param month the zero-based month, or 0 if useMonth is false 166 * @param useMonth if false, compute the day before the first day of 167 * the given year, otherwise, compute the day before the first day of 168 * the given month 169 * @param return the Julian day number of the day before the first 170 * day of the given month and year 171 * @internal 172 */ 173 virtual int32_t handleComputeMonthStart(int32_t eyear, int32_t month, 174 UBool useMonth) const override; 175 176 /** 177 * Returns true because the Buddhist Calendar does have a default century 178 * @internal 179 */ 180 virtual UBool haveDefaultCentury() const override; 181 182 /** 183 * Returns the date of the start of the default century 184 * @return start of century - in milliseconds since epoch, 1970 185 * @internal 186 */ 187 virtual UDate defaultCenturyStart() const override; 188 189 /** 190 * Returns the year in which the default century begins 191 * @internal 192 */ 193 virtual int32_t defaultCenturyStartYear() const override; 194 }; 195 196 U_NAMESPACE_END 197 198 #endif /* #if !UCONFIG_NO_FORMATTING */ 199 200 #endif // _GREGOCAL 201 //eof 202 203