tztrans.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. // Copyright (C) 2016 and later: Unicode, Inc. and others.
  2. // License & terms of use: http://www.unicode.org/copyright.html
  3. /*
  4. *******************************************************************************
  5. * Copyright (C) 2007-2008, International Business Machines Corporation and *
  6. * others. All Rights Reserved. *
  7. *******************************************************************************
  8. */
  9. #ifndef TZTRANS_H
  10. #define TZTRANS_H
  11. /**
  12. * \file
  13. * \brief C++ API: Time zone transition
  14. */
  15. #include "unicode/utypes.h"
  16. #if !UCONFIG_NO_FORMATTING
  17. #include "unicode/uobject.h"
  18. U_NAMESPACE_BEGIN
  19. // Forward declaration
  20. class TimeZoneRule;
  21. /**
  22. * <code>TimeZoneTransition</code> is a class representing a time zone transition.
  23. * An instance has a time of transition and rules for both before and after the transition.
  24. * @stable ICU 3.8
  25. */
  26. class U_I18N_API TimeZoneTransition : public UObject {
  27. public:
  28. /**
  29. * Constructs a <code>TimeZoneTransition</code> with the time and the rules before/after
  30. * the transition.
  31. *
  32. * @param time The time of transition in milliseconds since the base time.
  33. * @param from The time zone rule used before the transition.
  34. * @param to The time zone rule used after the transition.
  35. * @stable ICU 3.8
  36. */
  37. TimeZoneTransition(UDate time, const TimeZoneRule& from, const TimeZoneRule& to);
  38. /**
  39. * Constructs an empty <code>TimeZoneTransition</code>
  40. * @stable ICU 3.8
  41. */
  42. TimeZoneTransition();
  43. /**
  44. * Copy constructor.
  45. * @param source The TimeZoneTransition object to be copied.
  46. * @stable ICU 3.8
  47. */
  48. TimeZoneTransition(const TimeZoneTransition& source);
  49. /**
  50. * Destructor.
  51. * @stable ICU 3.8
  52. */
  53. ~TimeZoneTransition();
  54. /**
  55. * Clone this TimeZoneTransition object polymorphically. The caller owns the result and
  56. * should delete it when done.
  57. * @return A copy of the object.
  58. * @stable ICU 3.8
  59. */
  60. TimeZoneTransition* clone(void) const;
  61. /**
  62. * Assignment operator.
  63. * @param right The object to be copied.
  64. * @stable ICU 3.8
  65. */
  66. TimeZoneTransition& operator=(const TimeZoneTransition& right);
  67. /**
  68. * Return true if the given TimeZoneTransition objects are semantically equal. Objects
  69. * of different subclasses are considered unequal.
  70. * @param that The object to be compared with.
  71. * @return true if the given TimeZoneTransition objects are semantically equal.
  72. * @stable ICU 3.8
  73. */
  74. UBool operator==(const TimeZoneTransition& that) const;
  75. /**
  76. * Return true if the given TimeZoneTransition objects are semantically unequal. Objects
  77. * of different subclasses are considered unequal.
  78. * @param that The object to be compared with.
  79. * @return true if the given TimeZoneTransition objects are semantically unequal.
  80. * @stable ICU 3.8
  81. */
  82. UBool operator!=(const TimeZoneTransition& that) const;
  83. /**
  84. * Returns the time of transition in milliseconds.
  85. * @return The time of the transition in milliseconds since the 1970 Jan 1 epoch time.
  86. * @stable ICU 3.8
  87. */
  88. UDate getTime(void) const;
  89. /**
  90. * Sets the time of transition in milliseconds.
  91. * @param time The time of the transition in milliseconds since the 1970 Jan 1 epoch time.
  92. * @stable ICU 3.8
  93. */
  94. void setTime(UDate time);
  95. /**
  96. * Returns the rule used before the transition.
  97. * @return The time zone rule used after the transition.
  98. * @stable ICU 3.8
  99. */
  100. const TimeZoneRule* getFrom(void) const;
  101. /**
  102. * Sets the rule used before the transition. The caller remains
  103. * responsible for deleting the <code>TimeZoneRule</code> object.
  104. * @param from The time zone rule used before the transition.
  105. * @stable ICU 3.8
  106. */
  107. void setFrom(const TimeZoneRule& from);
  108. /**
  109. * Adopts the rule used before the transition. The caller must
  110. * not delete the <code>TimeZoneRule</code> object passed in.
  111. * @param from The time zone rule used before the transition.
  112. * @stable ICU 3.8
  113. */
  114. void adoptFrom(TimeZoneRule* from);
  115. /**
  116. * Sets the rule used after the transition. The caller remains
  117. * responsible for deleting the <code>TimeZoneRule</code> object.
  118. * @param to The time zone rule used after the transition.
  119. * @stable ICU 3.8
  120. */
  121. void setTo(const TimeZoneRule& to);
  122. /**
  123. * Adopts the rule used after the transition. The caller must
  124. * not delete the <code>TimeZoneRule</code> object passed in.
  125. * @param to The time zone rule used after the transition.
  126. * @stable ICU 3.8
  127. */
  128. void adoptTo(TimeZoneRule* to);
  129. /**
  130. * Returns the rule used after the transition.
  131. * @return The time zone rule used after the transition.
  132. * @stable ICU 3.8
  133. */
  134. const TimeZoneRule* getTo(void) const;
  135. private:
  136. UDate fTime;
  137. TimeZoneRule* fFrom;
  138. TimeZoneRule* fTo;
  139. public:
  140. /**
  141. * Return the class ID for this class. This is useful only for comparing to
  142. * a return value from getDynamicClassID(). For example:
  143. * <pre>
  144. * . Base* polymorphic_pointer = createPolymorphicObject();
  145. * . if (polymorphic_pointer->getDynamicClassID() ==
  146. * . erived::getStaticClassID()) ...
  147. * </pre>
  148. * @return The class ID for all objects of this class.
  149. * @stable ICU 3.8
  150. */
  151. static UClassID U_EXPORT2 getStaticClassID(void);
  152. /**
  153. * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
  154. * method is to implement a simple version of RTTI, since not all C++
  155. * compilers support genuine RTTI. Polymorphic operator==() and clone()
  156. * methods call this method.
  157. *
  158. * @return The class ID for this object. All objects of a
  159. * given class have the same class ID. Objects of
  160. * other classes have different class IDs.
  161. * @stable ICU 3.8
  162. */
  163. virtual UClassID getDynamicClassID(void) const;
  164. };
  165. U_NAMESPACE_END
  166. #endif /* #if !UCONFIG_NO_FORMATTING */
  167. #endif // TZTRANS_H
  168. //eof