| 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 |
* Create and return a polymorphic copy of this calendar. |
| 87 |
* @return return a polymorphic copy of this calendar. |
| 88 |
* @internal |
| 89 |
*/ |
| 90 |
virtual BuddhistCalendar* clone() const override; |
| 91 |
|
| 92 |
public: |
| 93 |
/** |
| 94 |
* Override Calendar Returns a unique class ID POLYMORPHICALLY. Pure virtual |
| 95 |
* override. This method is to implement a simple version of RTTI, since not all C++ |
| 96 |
* compilers support genuine RTTI. Polymorphic operator==() and clone() methods call |
| 97 |
* this method. |
| 98 |
* |
| 99 |
* @return The class ID for this object. All objects of a given class have the |
| 100 |
* same class ID. Objects of other classes have different class IDs. |
| 101 |
* @internal |
| 102 |
*/ |
| 103 |
virtual UClassID getDynamicClassID() const override; |
| 104 |
|
| 105 |
/** |
| 106 |
* Return the class ID for this class. This is useful only for comparing to a return |
| 107 |
* value from getDynamicClassID(). For example: |
| 108 |
* |
| 109 |
* Base* polymorphic_pointer = createPolymorphicObject(); |
| 110 |
* if (polymorphic_pointer->getDynamicClassID() == |
| 111 |
* Derived::getStaticClassID()) ... |
| 112 |
* |
| 113 |
* @return The class ID for all objects of this class. |
| 114 |
* @internal |
| 115 |
*/ |
| 116 |
U_I18N_API static UClassID U_EXPORT2 getStaticClassID(); |
| 117 |
|
| 118 |
/** |
| 119 |
* return the calendar type, "buddhist". |
| 120 |
* |
| 121 |
* @return calendar type |
| 122 |
* @internal |
| 123 |
*/ |
| 124 |
virtual const char * getType() const override; |
| 125 |
|
| 126 |
private: |
| 127 |
BuddhistCalendar(); // default constructor not implemented |
| 128 |
|
| 129 |
protected: |
| 130 |
/** |
| 131 |
* Return the extended year defined by the current fields. This will |
| 132 |
* use the UCAL_EXTENDED_YEAR field or the UCAL_YEAR and supra-year fields (such |
| 133 |
* as UCAL_ERA) specific to the calendar system, depending on which set of |
| 134 |
* fields is newer. |
| 135 |
* @param status |
| 136 |
* @return the extended year |
| 137 |
* @internal |
| 138 |
*/ |
| 139 |
virtual int32_t handleGetExtendedYear(UErrorCode& status) override; |
| 140 |
/** |
| 141 |
* Subclasses may override this method to compute several fields |
| 142 |
* specific to each calendar system. |
| 143 |
* @internal |
| 144 |
*/ |
| 145 |
virtual void handleComputeFields(int32_t julianDay, UErrorCode& status) override; |
| 146 |
/** |
| 147 |
* Subclass API for defining limits of different types. |
| 148 |
* @param field one of the field numbers |
| 149 |
* @param limitType one of <code>MINIMUM</code>, <code>GREATEST_MINIMUM</code>, |
| 150 |
* <code>LEAST_MAXIMUM</code>, or <code>MAXIMUM</code> |
| 151 |
* @internal |
| 152 |
*/ |
| 153 |
virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const override; |
| 154 |
|
| 155 |
virtual bool isEra0CountingBackward() const override { return false; } |
| 156 |
|
| 157 |
DECLARE_OVERRIDE_SYSTEM_DEFAULT_CENTURY |
| 158 |
}; |
| 159 |
|
| 160 |
U_NAMESPACE_END |
| 161 |
|
| 162 |
#endif /* #if !UCONFIG_NO_FORMATTING */ |
| 163 |
|
| 164 |
#endif // _GREGOCAL |
| 165 |
//eof |
| 166 |
|