tztrans.h 6.0 KB

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