cecal.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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 - 2008, International Business Machines Corporation and *
  6. * others. All Rights Reserved. *
  7. *******************************************************************************
  8. */
  9. #ifndef CECAL_H
  10. #define CECAL_H
  11. #include "unicode/utypes.h"
  12. #if !UCONFIG_NO_FORMATTING
  13. #include "unicode/calendar.h"
  14. U_NAMESPACE_BEGIN
  15. /**
  16. * Base class for EthiopicCalendar and CopticCalendar.
  17. * @internal
  18. */
  19. class U_I18N_API CECalendar : public Calendar {
  20. public:
  21. /**
  22. * Gets The Temporal monthCode value corresponding to the month for the date.
  23. * The value is a string identifier that starts with the literal grapheme
  24. * "M" followed by two graphemes representing the zero-padded month number
  25. * of the current month in a normal (non-leap) year. For the short thirteen
  26. * month in each year in the CECalendar, the value is "M13".
  27. *
  28. * @param status ICU Error Code
  29. * @return One of 13 possible strings in {"M01".. "M12", "M13"}.
  30. * @draft ICU 73
  31. */
  32. virtual const char* getTemporalMonthCode(UErrorCode& status) const override;
  33. /**
  34. * Sets The Temporal monthCode which is a string identifier that starts
  35. * with the literal grapheme "M" followed by two graphemes representing
  36. * the zero-padded month number of the current month in a normal
  37. * (non-leap) year. For CECalendar calendar, the values
  38. * are "M01" .. "M13" while the "M13" is represent the short thirteen month
  39. * in each year.
  40. *
  41. * @param temporalMonth The value to be set for temporal monthCode.
  42. * @param status ICU Error Code
  43. *
  44. * @draft ICU 73
  45. */
  46. virtual void setTemporalMonthCode(const char* code, UErrorCode& status) override;
  47. protected:
  48. //-------------------------------------------------------------------------
  49. // Constructors...
  50. //-------------------------------------------------------------------------
  51. /**
  52. * Constructs a CECalendar based on the current time in the default time zone
  53. * with the given locale with the Julian epoch offiset
  54. *
  55. * @param aLocale The given locale.
  56. * @param success Indicates the status of CECalendar object construction.
  57. * Returns U_ZERO_ERROR if constructed successfully.
  58. * @internal
  59. */
  60. CECalendar(const Locale& aLocale, UErrorCode& success);
  61. /**
  62. * Copy Constructor
  63. * @internal
  64. */
  65. CECalendar (const CECalendar& other);
  66. /**
  67. * Destructor.
  68. * @internal
  69. */
  70. virtual ~CECalendar();
  71. /**
  72. * Default assignment operator
  73. * @param right Calendar object to be copied
  74. * @internal
  75. */
  76. CECalendar& operator=(const CECalendar& right);
  77. protected:
  78. //-------------------------------------------------------------------------
  79. // Calendar framework
  80. //-------------------------------------------------------------------------
  81. /**
  82. * Return JD of start of given month/extended year
  83. * @internal
  84. */
  85. virtual int32_t handleComputeMonthStart(int32_t eyear, int32_t month, UBool useMonth) const override;
  86. /**
  87. * Calculate the limit for a specified type of limit and field
  88. * @internal
  89. */
  90. virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const override;
  91. /**
  92. * Returns true because Coptic/Ethiopic Calendar does have a default century
  93. * @internal
  94. */
  95. virtual UBool haveDefaultCentury() const override;
  96. protected:
  97. /**
  98. * The Coptic and Ethiopic calendars differ only in their epochs.
  99. * This method must be implemented by CECalendar subclasses to
  100. * return the date offset from Julian
  101. * @internal
  102. */
  103. virtual int32_t getJDEpochOffset() const = 0;
  104. /**
  105. * Convert an Coptic/Ethiopic year, month, and day to a Julian day.
  106. *
  107. * @param year the extended year
  108. * @param month the month
  109. * @param day the day
  110. * @param jdEpochOffset the epoch offset from Julian epoch
  111. * @return Julian day
  112. * @internal
  113. */
  114. static int32_t ceToJD(int32_t year, int32_t month, int32_t date,
  115. int32_t jdEpochOffset);
  116. /**
  117. * Convert a Julian day to an Coptic/Ethiopic year, month and day
  118. *
  119. * @param julianDay the Julian day
  120. * @param jdEpochOffset the epoch offset from Julian epoch
  121. * @param year receives the extended year
  122. * @param month receives the month
  123. * @param date receives the day
  124. * @internal
  125. */
  126. static void jdToCE(int32_t julianDay, int32_t jdEpochOffset,
  127. int32_t& year, int32_t& month, int32_t& day);
  128. };
  129. U_NAMESPACE_END
  130. #endif /* #if !UCONFIG_NO_FORMATTING */
  131. #endif
  132. //eof