taiwncal.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. * 06/29/2007 srl copied from buddhcal.h
  16. ********************************************************************************
  17. */
  18. #ifndef TAIWNCAL_H
  19. #define TAIWNCAL_H
  20. #include "unicode/utypes.h"
  21. #if !UCONFIG_NO_FORMATTING
  22. #include "unicode/calendar.h"
  23. #include "unicode/gregocal.h"
  24. U_NAMESPACE_BEGIN
  25. /**
  26. * Concrete class which provides the Taiwan calendar.
  27. * <P>
  28. * <code>TaiwanCalendar</code> is a subclass of <code>GregorianCalendar</code>
  29. * that numbers years since 1912
  30. * <p>
  31. * The Taiwan calendar is identical to the Gregorian calendar in all respects
  32. * except for the year and era. Years are numbered since 1912 AD (Gregorian),
  33. * so that 1912 AD (Gregorian) is equivalent to 1 MINGUO (Minguo Era) and 1998 AD is 87 MINGUO.
  34. * <p>
  35. * The Taiwan Calendar has two eras: <code>BEFORE_MINGUO</code> and <code>MINGUO</code>.
  36. * <p>
  37. * @internal
  38. */
  39. class TaiwanCalendar : public GregorianCalendar {
  40. public:
  41. /**
  42. * Useful constants for TaiwanCalendar. Only one Era.
  43. * @internal
  44. */
  45. enum EEras {
  46. BEFORE_MINGUO = 0,
  47. MINGUO = 1
  48. };
  49. /**
  50. * Constructs a TaiwanCalendar based on the current time in the default time zone
  51. * with the given locale.
  52. *
  53. * @param aLocale The given locale.
  54. * @param success Indicates the status of TaiwanCalendar object construction.
  55. * Returns U_ZERO_ERROR if constructed successfully.
  56. * @internal
  57. */
  58. TaiwanCalendar(const Locale& aLocale, UErrorCode& success);
  59. /**
  60. * Destructor
  61. * @internal
  62. */
  63. virtual ~TaiwanCalendar();
  64. /**
  65. * Copy constructor
  66. * @param source the object to be copied.
  67. * @internal
  68. */
  69. TaiwanCalendar(const TaiwanCalendar& source);
  70. /**
  71. * Default assignment operator
  72. * @param right the object to be copied.
  73. * @internal
  74. */
  75. TaiwanCalendar& operator=(const TaiwanCalendar& right);
  76. /**
  77. * Create and return a polymorphic copy of this calendar.
  78. * @return return a polymorphic copy of this calendar.
  79. * @internal
  80. */
  81. virtual TaiwanCalendar* clone() const;
  82. public:
  83. /**
  84. * Override Calendar Returns a unique class ID POLYMORPHICALLY. Pure virtual
  85. * override. This method is to implement a simple version of RTTI, since not all C++
  86. * compilers support genuine RTTI. Polymorphic operator==() and clone() methods call
  87. * this method.
  88. *
  89. * @return The class ID for this object. All objects of a given class have the
  90. * same class ID. Objects of other classes have different class IDs.
  91. * @internal
  92. */
  93. virtual UClassID getDynamicClassID(void) const;
  94. /**
  95. * Return the class ID for this class. This is useful only for comparing to a return
  96. * value from getDynamicClassID(). For example:
  97. *
  98. * Base* polymorphic_pointer = createPolymorphicObject();
  99. * if (polymorphic_pointer->getDynamicClassID() ==
  100. * Derived::getStaticClassID()) ...
  101. *
  102. * @return The class ID for all objects of this class.
  103. * @internal
  104. */
  105. U_I18N_API static UClassID U_EXPORT2 getStaticClassID(void);
  106. /**
  107. * return the calendar type, "Taiwan".
  108. *
  109. * @return calendar type
  110. * @internal
  111. */
  112. virtual const char * getType() const;
  113. private:
  114. TaiwanCalendar(); // default constructor not implemented
  115. protected:
  116. /**
  117. * Return the extended year defined by the current fields. This will
  118. * use the UCAL_EXTENDED_YEAR field or the UCAL_YEAR and supra-year fields (such
  119. * as UCAL_ERA) specific to the calendar system, depending on which set of
  120. * fields is newer.
  121. * @return the extended year
  122. * @internal
  123. */
  124. virtual int32_t handleGetExtendedYear();
  125. /**
  126. * Subclasses may override this method to compute several fields
  127. * specific to each calendar system.
  128. * @internal
  129. */
  130. virtual void handleComputeFields(int32_t julianDay, UErrorCode& status);
  131. /**
  132. * Subclass API for defining limits of different types.
  133. * @param field one of the field numbers
  134. * @param limitType one of <code>MINIMUM</code>, <code>GREATEST_MINIMUM</code>,
  135. * <code>LEAST_MAXIMUM</code>, or <code>MAXIMUM</code>
  136. * @internal
  137. */
  138. virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const;
  139. /**
  140. * Returns TRUE because the Taiwan Calendar does have a default century
  141. * @internal
  142. */
  143. virtual UBool haveDefaultCentury() const;
  144. /**
  145. * Returns the date of the start of the default century
  146. * @return start of century - in milliseconds since epoch, 1970
  147. * @internal
  148. */
  149. virtual UDate defaultCenturyStart() const;
  150. /**
  151. * Returns the year in which the default century begins
  152. * @internal
  153. */
  154. virtual int32_t defaultCenturyStartYear() const;
  155. };
  156. U_NAMESPACE_END
  157. #endif /* #if !UCONFIG_NO_FORMATTING */
  158. #endif // _TAIWNCAL
  159. //eof