buddhcal.h 5.7 KB

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