intl/icu/source/i18n/buddhcal.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /*
     2  ********************************************************************************
     3  * Copyright (C) 2003-2013, International Business Machines Corporation
     4  * and others. All Rights Reserved.
     5  ********************************************************************************
     6  *
     7  * File BUDDHCAL.H
     8  *
     9  * Modification History:
    10  *
    11  *   Date        Name        Description
    12  *   05/13/2003  srl          copied from gregocal.h
    13  ********************************************************************************
    14  */
    16 #ifndef BUDDHCAL_H
    17 #define BUDDHCAL_H
    19 #include "unicode/utypes.h"
    21 #if !UCONFIG_NO_FORMATTING
    23 #include "unicode/calendar.h"
    24 #include "unicode/gregocal.h"
    26 U_NAMESPACE_BEGIN
    28 /**
    29  * Concrete class which provides the Buddhist calendar.
    30  * <P>
    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.
    35  * <p>
    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.
    40  * <p>
    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.
    44  * <p>
    45  * @internal
    46  */
    47 class BuddhistCalendar : public GregorianCalendar {
    48 public:
    50     /**
    51      * Useful constants for BuddhistCalendar.  Only one Era.
    52      * @internal
    53      */
    54     enum EEras {
    55        BE
    56     };
    58     /**
    59      * Constructs a BuddhistCalendar based on the current time in the default time zone
    60      * with the given locale.
    61      *
    62      * @param aLocale  The given locale.
    63      * @param success  Indicates the status of BuddhistCalendar object construction.
    64      *                 Returns U_ZERO_ERROR if constructed successfully.
    65      * @internal
    66      */
    67     BuddhistCalendar(const Locale& aLocale, UErrorCode& success);
    70     /**
    71      * Destructor
    72      * @internal
    73      */
    74     virtual ~BuddhistCalendar();
    76     /**
    77      * Copy constructor
    78      * @param source    the object to be copied.
    79      * @internal
    80      */
    81     BuddhistCalendar(const BuddhistCalendar& source);
    83     /**
    84      * Default assignment operator
    85      * @param right    the object to be copied.
    86      * @internal
    87      */
    88     BuddhistCalendar& operator=(const BuddhistCalendar& right);
    90     /**
    91      * Create and return a polymorphic copy of this calendar.
    92      * @return    return a polymorphic copy of this calendar.
    93      * @internal
    94      */
    95     virtual Calendar* clone(void) const;
    97 public:
    98     /**
    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
   102      * this method.
   103      *
   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.
   106      * @internal
   107      */
   108     virtual UClassID getDynamicClassID(void) const;
   110     /**
   111      * Return the class ID for this class. This is useful only for comparing to a return
   112      * value from getDynamicClassID(). For example:
   113      *
   114      *      Base* polymorphic_pointer = createPolymorphicObject();
   115      *      if (polymorphic_pointer->getDynamicClassID() ==
   116      *          Derived::getStaticClassID()) ...
   117      *
   118      * @return   The class ID for all objects of this class.
   119      * @internal
   120      */
   121     U_I18N_API static UClassID U_EXPORT2 getStaticClassID(void);
   123     /**
   124      * return the calendar type, "buddhist".
   125      *
   126      * @return calendar type
   127      * @internal
   128      */
   129     virtual const char * getType() const;
   131 private:
   132     BuddhistCalendar(); // default constructor not implemented
   134  protected:
   135     /**
   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
   139      * fields is newer.
   140      * @return the extended year
   141      * @internal
   142      */
   143     virtual int32_t handleGetExtendedYear();
   144     /**
   145      * Subclasses may override this method to compute several fields
   146      * specific to each calendar system.  
   147      * @internal
   148      */
   149     virtual void handleComputeFields(int32_t julianDay, UErrorCode& status);
   150     /**
   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>
   155      * @internal
   156      */
   157     virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const;
   158         /**
   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
   166      * the given month
   167      * @param return the Julian day number of the day before the first
   168      * day of the given month and year
   169      * @internal
   170      */
   171     virtual int32_t handleComputeMonthStart(int32_t eyear, int32_t month,
   172                                             UBool useMonth) const;
   174     /**
   175      * Returns TRUE because the Buddhist Calendar does have a default century
   176      * @internal
   177      */
   178     virtual UBool haveDefaultCentury() const;
   180     /**
   181      * Returns the date of the start of the default century
   182      * @return start of century - in milliseconds since epoch, 1970
   183      * @internal
   184      */
   185     virtual UDate defaultCenturyStart() const;
   187     /**
   188      * Returns the year in which the default century begins
   189      * @internal
   190      */
   191     virtual int32_t defaultCenturyStartYear() const;
   192 };
   194 U_NAMESPACE_END
   196 #endif /* #if !UCONFIG_NO_FORMATTING */
   198 #endif // _GREGOCAL
   199 //eof

mercurial