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