tztrans.h 6.1 KB

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