12e5b6d6dSopenharmony_ci// © 2016 and later: Unicode, Inc. and others.
22e5b6d6dSopenharmony_ci// License & terms of use: http://www.unicode.org/copyright.html
32e5b6d6dSopenharmony_ci/*
42e5b6d6dSopenharmony_ci ********************************************************************************
52e5b6d6dSopenharmony_ci * Copyright (C) 2003-2013, International Business Machines Corporation
62e5b6d6dSopenharmony_ci * and others. All Rights Reserved.
72e5b6d6dSopenharmony_ci ********************************************************************************
82e5b6d6dSopenharmony_ci *
92e5b6d6dSopenharmony_ci * File BUDDHCAL.H
102e5b6d6dSopenharmony_ci *
112e5b6d6dSopenharmony_ci * Modification History:
122e5b6d6dSopenharmony_ci *
132e5b6d6dSopenharmony_ci *   Date        Name        Description
142e5b6d6dSopenharmony_ci *   05/13/2003  srl          copied from gregocal.h
152e5b6d6dSopenharmony_ci ********************************************************************************
162e5b6d6dSopenharmony_ci */
172e5b6d6dSopenharmony_ci
182e5b6d6dSopenharmony_ci#ifndef BUDDHCAL_H
192e5b6d6dSopenharmony_ci#define BUDDHCAL_H
202e5b6d6dSopenharmony_ci
212e5b6d6dSopenharmony_ci#include "unicode/utypes.h"
222e5b6d6dSopenharmony_ci
232e5b6d6dSopenharmony_ci#if !UCONFIG_NO_FORMATTING
242e5b6d6dSopenharmony_ci
252e5b6d6dSopenharmony_ci#include "unicode/calendar.h"
262e5b6d6dSopenharmony_ci#include "unicode/gregocal.h"
272e5b6d6dSopenharmony_ci
282e5b6d6dSopenharmony_ciU_NAMESPACE_BEGIN
292e5b6d6dSopenharmony_ci
302e5b6d6dSopenharmony_ci/**
312e5b6d6dSopenharmony_ci * Concrete class which provides the Buddhist calendar.
322e5b6d6dSopenharmony_ci * <P>
332e5b6d6dSopenharmony_ci * <code>BuddhistCalendar</code> is a subclass of <code>GregorianCalendar</code>
342e5b6d6dSopenharmony_ci * that numbers years since the birth of the Buddha.  This is the civil calendar
352e5b6d6dSopenharmony_ci * in some predominantly Buddhist countries such as Thailand, and it is used for
362e5b6d6dSopenharmony_ci * religious purposes elsewhere.
372e5b6d6dSopenharmony_ci * <p>
382e5b6d6dSopenharmony_ci * The Buddhist calendar is identical to the Gregorian calendar in all respects
392e5b6d6dSopenharmony_ci * except for the year and era.  Years are numbered since the birth of the
402e5b6d6dSopenharmony_ci * Buddha in 543 BC (Gregorian), so that 1 AD (Gregorian) is equivalent to 544
412e5b6d6dSopenharmony_ci * BE (Buddhist Era) and 1998 AD is 2541 BE.
422e5b6d6dSopenharmony_ci * <p>
432e5b6d6dSopenharmony_ci * The Buddhist Calendar has only one allowable era: <code>BE</code>.  If the
442e5b6d6dSopenharmony_ci * calendar is not in lenient mode (see <code>setLenient</code>), dates before
452e5b6d6dSopenharmony_ci * 1/1/1 BE are rejected as an illegal argument.
462e5b6d6dSopenharmony_ci * <p>
472e5b6d6dSopenharmony_ci * @internal
482e5b6d6dSopenharmony_ci */
492e5b6d6dSopenharmony_ciclass BuddhistCalendar : public GregorianCalendar {
502e5b6d6dSopenharmony_cipublic:
512e5b6d6dSopenharmony_ci
522e5b6d6dSopenharmony_ci    /**
532e5b6d6dSopenharmony_ci     * Useful constants for BuddhistCalendar.  Only one Era.
542e5b6d6dSopenharmony_ci     * @internal
552e5b6d6dSopenharmony_ci     */
562e5b6d6dSopenharmony_ci    enum EEras {
572e5b6d6dSopenharmony_ci       BE
582e5b6d6dSopenharmony_ci    };
592e5b6d6dSopenharmony_ci
602e5b6d6dSopenharmony_ci    /**
612e5b6d6dSopenharmony_ci     * Constructs a BuddhistCalendar based on the current time in the default time zone
622e5b6d6dSopenharmony_ci     * with the given locale.
632e5b6d6dSopenharmony_ci     *
642e5b6d6dSopenharmony_ci     * @param aLocale  The given locale.
652e5b6d6dSopenharmony_ci     * @param success  Indicates the status of BuddhistCalendar object construction.
662e5b6d6dSopenharmony_ci     *                 Returns U_ZERO_ERROR if constructed successfully.
672e5b6d6dSopenharmony_ci     * @internal
682e5b6d6dSopenharmony_ci     */
692e5b6d6dSopenharmony_ci    BuddhistCalendar(const Locale& aLocale, UErrorCode& success);
702e5b6d6dSopenharmony_ci
712e5b6d6dSopenharmony_ci
722e5b6d6dSopenharmony_ci    /**
732e5b6d6dSopenharmony_ci     * Destructor
742e5b6d6dSopenharmony_ci     * @internal
752e5b6d6dSopenharmony_ci     */
762e5b6d6dSopenharmony_ci    virtual ~BuddhistCalendar();
772e5b6d6dSopenharmony_ci
782e5b6d6dSopenharmony_ci    /**
792e5b6d6dSopenharmony_ci     * Copy constructor
802e5b6d6dSopenharmony_ci     * @param source    the object to be copied.
812e5b6d6dSopenharmony_ci     * @internal
822e5b6d6dSopenharmony_ci     */
832e5b6d6dSopenharmony_ci    BuddhistCalendar(const BuddhistCalendar& source);
842e5b6d6dSopenharmony_ci
852e5b6d6dSopenharmony_ci    /**
862e5b6d6dSopenharmony_ci     * Default assignment operator
872e5b6d6dSopenharmony_ci     * @param right    the object to be copied.
882e5b6d6dSopenharmony_ci     * @internal
892e5b6d6dSopenharmony_ci     */
902e5b6d6dSopenharmony_ci    BuddhistCalendar& operator=(const BuddhistCalendar& right);
912e5b6d6dSopenharmony_ci
922e5b6d6dSopenharmony_ci    /**
932e5b6d6dSopenharmony_ci     * Create and return a polymorphic copy of this calendar.
942e5b6d6dSopenharmony_ci     * @return    return a polymorphic copy of this calendar.
952e5b6d6dSopenharmony_ci     * @internal
962e5b6d6dSopenharmony_ci     */
972e5b6d6dSopenharmony_ci    virtual BuddhistCalendar* clone() const override;
982e5b6d6dSopenharmony_ci
992e5b6d6dSopenharmony_cipublic:
1002e5b6d6dSopenharmony_ci    /**
1012e5b6d6dSopenharmony_ci     * Override Calendar Returns a unique class ID POLYMORPHICALLY. Pure virtual
1022e5b6d6dSopenharmony_ci     * override. This method is to implement a simple version of RTTI, since not all C++
1032e5b6d6dSopenharmony_ci     * compilers support genuine RTTI. Polymorphic operator==() and clone() methods call
1042e5b6d6dSopenharmony_ci     * this method.
1052e5b6d6dSopenharmony_ci     *
1062e5b6d6dSopenharmony_ci     * @return   The class ID for this object. All objects of a given class have the
1072e5b6d6dSopenharmony_ci     *           same class ID. Objects of other classes have different class IDs.
1082e5b6d6dSopenharmony_ci     * @internal
1092e5b6d6dSopenharmony_ci     */
1102e5b6d6dSopenharmony_ci    virtual UClassID getDynamicClassID(void) const override;
1112e5b6d6dSopenharmony_ci
1122e5b6d6dSopenharmony_ci    /**
1132e5b6d6dSopenharmony_ci     * Return the class ID for this class. This is useful only for comparing to a return
1142e5b6d6dSopenharmony_ci     * value from getDynamicClassID(). For example:
1152e5b6d6dSopenharmony_ci     *
1162e5b6d6dSopenharmony_ci     *      Base* polymorphic_pointer = createPolymorphicObject();
1172e5b6d6dSopenharmony_ci     *      if (polymorphic_pointer->getDynamicClassID() ==
1182e5b6d6dSopenharmony_ci     *          Derived::getStaticClassID()) ...
1192e5b6d6dSopenharmony_ci     *
1202e5b6d6dSopenharmony_ci     * @return   The class ID for all objects of this class.
1212e5b6d6dSopenharmony_ci     * @internal
1222e5b6d6dSopenharmony_ci     */
1232e5b6d6dSopenharmony_ci    U_I18N_API static UClassID U_EXPORT2 getStaticClassID(void);
1242e5b6d6dSopenharmony_ci
1252e5b6d6dSopenharmony_ci    /**
1262e5b6d6dSopenharmony_ci     * return the calendar type, "buddhist".
1272e5b6d6dSopenharmony_ci     *
1282e5b6d6dSopenharmony_ci     * @return calendar type
1292e5b6d6dSopenharmony_ci     * @internal
1302e5b6d6dSopenharmony_ci     */
1312e5b6d6dSopenharmony_ci    virtual const char * getType() const override;
1322e5b6d6dSopenharmony_ci
1332e5b6d6dSopenharmony_ciprivate:
1342e5b6d6dSopenharmony_ci    BuddhistCalendar(); // default constructor not implemented
1352e5b6d6dSopenharmony_ci
1362e5b6d6dSopenharmony_ci protected:
1372e5b6d6dSopenharmony_ci    /**
1382e5b6d6dSopenharmony_ci     * Return the extended year defined by the current fields.  This will
1392e5b6d6dSopenharmony_ci     * use the UCAL_EXTENDED_YEAR field or the UCAL_YEAR and supra-year fields (such
1402e5b6d6dSopenharmony_ci     * as UCAL_ERA) specific to the calendar system, depending on which set of
1412e5b6d6dSopenharmony_ci     * fields is newer.
1422e5b6d6dSopenharmony_ci     * @return the extended year
1432e5b6d6dSopenharmony_ci     * @internal
1442e5b6d6dSopenharmony_ci     */
1452e5b6d6dSopenharmony_ci    virtual int32_t handleGetExtendedYear() override;
1462e5b6d6dSopenharmony_ci    /**
1472e5b6d6dSopenharmony_ci     * Subclasses may override this method to compute several fields
1482e5b6d6dSopenharmony_ci     * specific to each calendar system.
1492e5b6d6dSopenharmony_ci     * @internal
1502e5b6d6dSopenharmony_ci     */
1512e5b6d6dSopenharmony_ci    virtual void handleComputeFields(int32_t julianDay, UErrorCode& status) override;
1522e5b6d6dSopenharmony_ci    /**
1532e5b6d6dSopenharmony_ci     * Subclass API for defining limits of different types.
1542e5b6d6dSopenharmony_ci     * @param field one of the field numbers
1552e5b6d6dSopenharmony_ci     * @param limitType one of <code>MINIMUM</code>, <code>GREATEST_MINIMUM</code>,
1562e5b6d6dSopenharmony_ci     * <code>LEAST_MAXIMUM</code>, or <code>MAXIMUM</code>
1572e5b6d6dSopenharmony_ci     * @internal
1582e5b6d6dSopenharmony_ci     */
1592e5b6d6dSopenharmony_ci    virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const override;
1602e5b6d6dSopenharmony_ci        /**
1612e5b6d6dSopenharmony_ci     * Return the Julian day number of day before the first day of the
1622e5b6d6dSopenharmony_ci     * given month in the given extended year.  Subclasses should override
1632e5b6d6dSopenharmony_ci     * this method to implement their calendar system.
1642e5b6d6dSopenharmony_ci     * @param eyear the extended year
1652e5b6d6dSopenharmony_ci     * @param month the zero-based month, or 0 if useMonth is false
1662e5b6d6dSopenharmony_ci     * @param useMonth if false, compute the day before the first day of
1672e5b6d6dSopenharmony_ci     * the given year, otherwise, compute the day before the first day of
1682e5b6d6dSopenharmony_ci     * the given month
1692e5b6d6dSopenharmony_ci     * @param return the Julian day number of the day before the first
1702e5b6d6dSopenharmony_ci     * day of the given month and year
1712e5b6d6dSopenharmony_ci     * @internal
1722e5b6d6dSopenharmony_ci     */
1732e5b6d6dSopenharmony_ci    virtual int32_t handleComputeMonthStart(int32_t eyear, int32_t month,
1742e5b6d6dSopenharmony_ci                                            UBool useMonth) const override;
1752e5b6d6dSopenharmony_ci
1762e5b6d6dSopenharmony_ci    /**
1772e5b6d6dSopenharmony_ci     * Returns true because the Buddhist Calendar does have a default century
1782e5b6d6dSopenharmony_ci     * @internal
1792e5b6d6dSopenharmony_ci     */
1802e5b6d6dSopenharmony_ci    virtual UBool haveDefaultCentury() const override;
1812e5b6d6dSopenharmony_ci
1822e5b6d6dSopenharmony_ci    /**
1832e5b6d6dSopenharmony_ci     * Returns the date of the start of the default century
1842e5b6d6dSopenharmony_ci     * @return start of century - in milliseconds since epoch, 1970
1852e5b6d6dSopenharmony_ci     * @internal
1862e5b6d6dSopenharmony_ci     */
1872e5b6d6dSopenharmony_ci    virtual UDate defaultCenturyStart() const override;
1882e5b6d6dSopenharmony_ci
1892e5b6d6dSopenharmony_ci    /**
1902e5b6d6dSopenharmony_ci     * Returns the year in which the default century begins
1912e5b6d6dSopenharmony_ci     * @internal
1922e5b6d6dSopenharmony_ci     */
1932e5b6d6dSopenharmony_ci    virtual int32_t defaultCenturyStartYear() const override;
1942e5b6d6dSopenharmony_ci};
1952e5b6d6dSopenharmony_ci
1962e5b6d6dSopenharmony_ciU_NAMESPACE_END
1972e5b6d6dSopenharmony_ci
1982e5b6d6dSopenharmony_ci#endif /* #if !UCONFIG_NO_FORMATTING */
1992e5b6d6dSopenharmony_ci
2002e5b6d6dSopenharmony_ci#endif // _GREGOCAL
2012e5b6d6dSopenharmony_ci//eof
2022e5b6d6dSopenharmony_ci
203