2 ********************************************************************************
3 * Copyright (C) 2003-2013, International Business Machines Corporation
4 * and others. All Rights Reserved.
5 ********************************************************************************
9 * Modification History:
11 * Date Name Description
12 * 05/13/2003 srl copied from gregocal.h
13 ********************************************************************************
19 #include "unicode/utypes.h"
21 #if !UCONFIG_NO_FORMATTING
23 #include "unicode/calendar.h"
24 #include "unicode/gregocal.h"
29 * Concrete class which provides the Buddhist calendar.
31 * <code>BuddhistCalendar</code> is a subclass of <code>GregorianCalendar</code>
32 * that numbers years since the birth of the Buddha. This is the civil calendar
33 * in some predominantly Buddhist countries such as Thailand, and it is used for
34 * religious purposes elsewhere.
36 * The Buddhist calendar is identical to the Gregorian calendar in all respects
37 * except for the year and era. Years are numbered since the birth of the
38 * Buddha in 543 BC (Gregorian), so that 1 AD (Gregorian) is equivalent to 544
39 * BE (Buddhist Era) and 1998 AD is 2541 BE.
41 * The Buddhist Calendar has only one allowable era: <code>BE</code>. If the
42 * calendar is not in lenient mode (see <code>setLenient</code>), dates before
43 * 1/1/1 BE are rejected as an illegal argument.
47 class BuddhistCalendar
: public GregorianCalendar
{
51 * Useful constants for BuddhistCalendar. Only one Era.
59 * Constructs a BuddhistCalendar based on the current time in the default time zone
60 * with the given locale.
62 * @param aLocale The given locale.
63 * @param success Indicates the status of BuddhistCalendar object construction.
64 * Returns U_ZERO_ERROR if constructed successfully.
67 BuddhistCalendar(const Locale
& aLocale
, UErrorCode
& success
);
74 virtual ~BuddhistCalendar();
78 * @param source the object to be copied.
81 BuddhistCalendar(const BuddhistCalendar
& source
);
84 * Default assignment operator
85 * @param right the object to be copied.
88 BuddhistCalendar
& operator=(const BuddhistCalendar
& right
);
91 * Create and return a polymorphic copy of this calendar.
92 * @return return a polymorphic copy of this calendar.
95 virtual Calendar
* clone(void) const;
99 * Override Calendar Returns a unique class ID POLYMORPHICALLY. Pure virtual
100 * override. This method is to implement a simple version of RTTI, since not all C++
101 * compilers support genuine RTTI. Polymorphic operator==() and clone() methods call
104 * @return The class ID for this object. All objects of a given class have the
105 * same class ID. Objects of other classes have different class IDs.
108 virtual UClassID
getDynamicClassID(void) const;
111 * Return the class ID for this class. This is useful only for comparing to a return
112 * value from getDynamicClassID(). For example:
114 * Base* polymorphic_pointer = createPolymorphicObject();
115 * if (polymorphic_pointer->getDynamicClassID() ==
116 * Derived::getStaticClassID()) ...
118 * @return The class ID for all objects of this class.
121 U_I18N_API
static UClassID U_EXPORT2
getStaticClassID(void);
124 * return the calendar type, "buddhist".
126 * @return calendar type
129 virtual const char * getType() const;
132 BuddhistCalendar(); // default constructor not implemented
136 * Return the extended year defined by the current fields. This will
137 * use the UCAL_EXTENDED_YEAR field or the UCAL_YEAR and supra-year fields (such
138 * as UCAL_ERA) specific to the calendar system, depending on which set of
140 * @return the extended year
143 virtual int32_t handleGetExtendedYear();
145 * Subclasses may override this method to compute several fields
146 * specific to each calendar system.
149 virtual void handleComputeFields(int32_t julianDay
, UErrorCode
& status
);
151 * Subclass API for defining limits of different types.
152 * @param field one of the field numbers
153 * @param limitType one of <code>MINIMUM</code>, <code>GREATEST_MINIMUM</code>,
154 * <code>LEAST_MAXIMUM</code>, or <code>MAXIMUM</code>
157 virtual int32_t handleGetLimit(UCalendarDateFields field
, ELimitType limitType
) const;
159 * Return the Julian day number of day before the first day of the
160 * given month in the given extended year. Subclasses should override
161 * this method to implement their calendar system.
162 * @param eyear the extended year
163 * @param month the zero-based month, or 0 if useMonth is false
164 * @param useMonth if false, compute the day before the first day of
165 * the given year, otherwise, compute the day before the first day of
167 * @param return the Julian day number of the day before the first
168 * day of the given month and year
171 virtual int32_t handleComputeMonthStart(int32_t eyear
, int32_t month
,
172 UBool useMonth
) const;
175 * Returns TRUE because the Buddhist Calendar does have a default century
178 virtual UBool
haveDefaultCentury() const;
181 * Returns the date of the start of the default century
182 * @return start of century - in milliseconds since epoch, 1970
185 virtual UDate
defaultCenturyStart() const;
188 * Returns the year in which the default century begins
191 virtual int32_t defaultCenturyStartYear() const;
196 #endif /* #if !UCONFIG_NO_FORMATTING */