1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 ********************************************************************************
5 * Copyright (C) 2003-2013, International Business Machines Corporation
6 * and others. All Rights Reserved.
7 ********************************************************************************
11 * Modification History:
13 * Date Name Description
14 * 05/13/2003 srl copied from gregocal.h
15 ********************************************************************************
21 #include "unicode/utypes.h"
23 #if !UCONFIG_NO_FORMATTING
25 #include "unicode/calendar.h"
26 #include "unicode/gregocal.h"
31 * Concrete class which provides the Buddhist calendar.
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.
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.
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.
49 class BuddhistCalendar
: public GregorianCalendar
{
53 * Useful constants for BuddhistCalendar. Only one Era.
61 * Constructs a BuddhistCalendar based on the current time in the default time zone
62 * with the given locale.
64 * @param aLocale The given locale.
65 * @param success Indicates the status of BuddhistCalendar object construction.
66 * Returns U_ZERO_ERROR if constructed successfully.
69 BuddhistCalendar(const Locale
& aLocale
, UErrorCode
& success
);
76 virtual ~BuddhistCalendar();
80 * @param source the object to be copied.
83 BuddhistCalendar(const BuddhistCalendar
& source
);
86 * Default assignment operator
87 * @param right the object to be copied.
90 BuddhistCalendar
& operator=(const BuddhistCalendar
& right
);
93 * Create and return a polymorphic copy of this calendar.
94 * @return return a polymorphic copy of this calendar.
97 virtual BuddhistCalendar
* clone() const;
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
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.
110 virtual UClassID
getDynamicClassID(void) const;
113 * Return the class ID for this class. This is useful only for comparing to a return
114 * value from getDynamicClassID(). For example:
116 * Base* polymorphic_pointer = createPolymorphicObject();
117 * if (polymorphic_pointer->getDynamicClassID() ==
118 * Derived::getStaticClassID()) ...
120 * @return The class ID for all objects of this class.
123 U_I18N_API
static UClassID U_EXPORT2
getStaticClassID(void);
126 * return the calendar type, "buddhist".
128 * @return calendar type
131 virtual const char * getType() const;
134 BuddhistCalendar(); // default constructor not implemented
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
142 * @return the extended year
145 virtual int32_t handleGetExtendedYear();
147 * Subclasses may override this method to compute several fields
148 * specific to each calendar system.
151 virtual void handleComputeFields(int32_t julianDay
, UErrorCode
& status
);
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>
159 virtual int32_t handleGetLimit(UCalendarDateFields field
, ELimitType limitType
) const;
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
169 * @param return the Julian day number of the day before the first
170 * day of the given month and year
173 virtual int32_t handleComputeMonthStart(int32_t eyear
, int32_t month
,
174 UBool useMonth
) const;
177 * Returns TRUE because the Buddhist Calendar does have a default century
180 virtual UBool
haveDefaultCentury() const;
183 * Returns the date of the start of the default century
184 * @return start of century - in milliseconds since epoch, 1970
187 virtual UDate
defaultCenturyStart() const;
190 * Returns the year in which the default century begins
193 virtual int32_t defaultCenturyStartYear() const;
198 #endif /* #if !UCONFIG_NO_FORMATTING */