12e5b6d6dSopenharmony_ci// © 2016 and later: Unicode, Inc. and others. 22e5b6d6dSopenharmony_ci// License & terms of use: http://www.unicode.org/copyright.html 32e5b6d6dSopenharmony_ci/* 42e5b6d6dSopenharmony_ci******************************************************************************* 52e5b6d6dSopenharmony_ci* Copyright (C) 2007-2008, International Business Machines Corporation and * 62e5b6d6dSopenharmony_ci* others. All Rights Reserved. * 72e5b6d6dSopenharmony_ci******************************************************************************* 82e5b6d6dSopenharmony_ci*/ 92e5b6d6dSopenharmony_ci#ifndef TZTRANS_H 102e5b6d6dSopenharmony_ci#define TZTRANS_H 112e5b6d6dSopenharmony_ci 122e5b6d6dSopenharmony_ci/** 132e5b6d6dSopenharmony_ci * \file 142e5b6d6dSopenharmony_ci * \brief C++ API: Time zone transition 152e5b6d6dSopenharmony_ci */ 162e5b6d6dSopenharmony_ci 172e5b6d6dSopenharmony_ci#include "unicode/utypes.h" 182e5b6d6dSopenharmony_ci 192e5b6d6dSopenharmony_ci#if U_SHOW_CPLUSPLUS_API 202e5b6d6dSopenharmony_ci 212e5b6d6dSopenharmony_ci#if !UCONFIG_NO_FORMATTING 222e5b6d6dSopenharmony_ci 232e5b6d6dSopenharmony_ci#include "unicode/uobject.h" 242e5b6d6dSopenharmony_ci 252e5b6d6dSopenharmony_ciU_NAMESPACE_BEGIN 262e5b6d6dSopenharmony_ci 272e5b6d6dSopenharmony_ci// Forward declaration 282e5b6d6dSopenharmony_ciclass TimeZoneRule; 292e5b6d6dSopenharmony_ci 302e5b6d6dSopenharmony_ci/** 312e5b6d6dSopenharmony_ci * <code>TimeZoneTransition</code> is a class representing a time zone transition. 322e5b6d6dSopenharmony_ci * An instance has a time of transition and rules for both before and after the transition. 332e5b6d6dSopenharmony_ci * @stable ICU 3.8 342e5b6d6dSopenharmony_ci */ 352e5b6d6dSopenharmony_ciclass U_I18N_API TimeZoneTransition : public UObject { 362e5b6d6dSopenharmony_cipublic: 372e5b6d6dSopenharmony_ci /** 382e5b6d6dSopenharmony_ci * Constructs a <code>TimeZoneTransition</code> with the time and the rules before/after 392e5b6d6dSopenharmony_ci * the transition. 402e5b6d6dSopenharmony_ci * 412e5b6d6dSopenharmony_ci * @param time The time of transition in milliseconds since the base time. 422e5b6d6dSopenharmony_ci * @param from The time zone rule used before the transition. 432e5b6d6dSopenharmony_ci * @param to The time zone rule used after the transition. 442e5b6d6dSopenharmony_ci * @stable ICU 3.8 452e5b6d6dSopenharmony_ci */ 462e5b6d6dSopenharmony_ci TimeZoneTransition(UDate time, const TimeZoneRule& from, const TimeZoneRule& to); 472e5b6d6dSopenharmony_ci 482e5b6d6dSopenharmony_ci /** 492e5b6d6dSopenharmony_ci * Constructs an empty <code>TimeZoneTransition</code> 502e5b6d6dSopenharmony_ci * @stable ICU 3.8 512e5b6d6dSopenharmony_ci */ 522e5b6d6dSopenharmony_ci TimeZoneTransition(); 532e5b6d6dSopenharmony_ci 542e5b6d6dSopenharmony_ci /** 552e5b6d6dSopenharmony_ci * Copy constructor. 562e5b6d6dSopenharmony_ci * @param source The TimeZoneTransition object to be copied. 572e5b6d6dSopenharmony_ci * @stable ICU 3.8 582e5b6d6dSopenharmony_ci */ 592e5b6d6dSopenharmony_ci TimeZoneTransition(const TimeZoneTransition& source); 602e5b6d6dSopenharmony_ci 612e5b6d6dSopenharmony_ci /** 622e5b6d6dSopenharmony_ci * Destructor. 632e5b6d6dSopenharmony_ci * @stable ICU 3.8 642e5b6d6dSopenharmony_ci */ 652e5b6d6dSopenharmony_ci ~TimeZoneTransition(); 662e5b6d6dSopenharmony_ci 672e5b6d6dSopenharmony_ci /** 682e5b6d6dSopenharmony_ci * Clone this TimeZoneTransition object polymorphically. The caller owns the result and 692e5b6d6dSopenharmony_ci * should delete it when done. 702e5b6d6dSopenharmony_ci * @return A copy of the object. 712e5b6d6dSopenharmony_ci * @stable ICU 3.8 722e5b6d6dSopenharmony_ci */ 732e5b6d6dSopenharmony_ci TimeZoneTransition* clone() const; 742e5b6d6dSopenharmony_ci 752e5b6d6dSopenharmony_ci /** 762e5b6d6dSopenharmony_ci * Assignment operator. 772e5b6d6dSopenharmony_ci * @param right The object to be copied. 782e5b6d6dSopenharmony_ci * @stable ICU 3.8 792e5b6d6dSopenharmony_ci */ 802e5b6d6dSopenharmony_ci TimeZoneTransition& operator=(const TimeZoneTransition& right); 812e5b6d6dSopenharmony_ci 822e5b6d6dSopenharmony_ci /** 832e5b6d6dSopenharmony_ci * Return true if the given TimeZoneTransition objects are semantically equal. Objects 842e5b6d6dSopenharmony_ci * of different subclasses are considered unequal. 852e5b6d6dSopenharmony_ci * @param that The object to be compared with. 862e5b6d6dSopenharmony_ci * @return true if the given TimeZoneTransition objects are semantically equal. 872e5b6d6dSopenharmony_ci * @stable ICU 3.8 882e5b6d6dSopenharmony_ci */ 892e5b6d6dSopenharmony_ci bool operator==(const TimeZoneTransition& that) const; 902e5b6d6dSopenharmony_ci 912e5b6d6dSopenharmony_ci /** 922e5b6d6dSopenharmony_ci * Return true if the given TimeZoneTransition objects are semantically unequal. Objects 932e5b6d6dSopenharmony_ci * of different subclasses are considered unequal. 942e5b6d6dSopenharmony_ci * @param that The object to be compared with. 952e5b6d6dSopenharmony_ci * @return true if the given TimeZoneTransition objects are semantically unequal. 962e5b6d6dSopenharmony_ci * @stable ICU 3.8 972e5b6d6dSopenharmony_ci */ 982e5b6d6dSopenharmony_ci bool operator!=(const TimeZoneTransition& that) const; 992e5b6d6dSopenharmony_ci 1002e5b6d6dSopenharmony_ci /** 1012e5b6d6dSopenharmony_ci * Returns the time of transition in milliseconds. 1022e5b6d6dSopenharmony_ci * @return The time of the transition in milliseconds since the 1970 Jan 1 epoch time. 1032e5b6d6dSopenharmony_ci * @stable ICU 3.8 1042e5b6d6dSopenharmony_ci */ 1052e5b6d6dSopenharmony_ci UDate getTime(void) const; 1062e5b6d6dSopenharmony_ci 1072e5b6d6dSopenharmony_ci /** 1082e5b6d6dSopenharmony_ci * Sets the time of transition in milliseconds. 1092e5b6d6dSopenharmony_ci * @param time The time of the transition in milliseconds since the 1970 Jan 1 epoch time. 1102e5b6d6dSopenharmony_ci * @stable ICU 3.8 1112e5b6d6dSopenharmony_ci */ 1122e5b6d6dSopenharmony_ci void setTime(UDate time); 1132e5b6d6dSopenharmony_ci 1142e5b6d6dSopenharmony_ci /** 1152e5b6d6dSopenharmony_ci * Returns the rule used before the transition. 1162e5b6d6dSopenharmony_ci * @return The time zone rule used after the transition. 1172e5b6d6dSopenharmony_ci * @stable ICU 3.8 1182e5b6d6dSopenharmony_ci */ 1192e5b6d6dSopenharmony_ci const TimeZoneRule* getFrom(void) const; 1202e5b6d6dSopenharmony_ci 1212e5b6d6dSopenharmony_ci /** 1222e5b6d6dSopenharmony_ci * Sets the rule used before the transition. The caller remains 1232e5b6d6dSopenharmony_ci * responsible for deleting the <code>TimeZoneRule</code> object. 1242e5b6d6dSopenharmony_ci * @param from The time zone rule used before the transition. 1252e5b6d6dSopenharmony_ci * @stable ICU 3.8 1262e5b6d6dSopenharmony_ci */ 1272e5b6d6dSopenharmony_ci void setFrom(const TimeZoneRule& from); 1282e5b6d6dSopenharmony_ci 1292e5b6d6dSopenharmony_ci /** 1302e5b6d6dSopenharmony_ci * Adopts the rule used before the transition. The caller must 1312e5b6d6dSopenharmony_ci * not delete the <code>TimeZoneRule</code> object passed in. 1322e5b6d6dSopenharmony_ci * @param from The time zone rule used before the transition. 1332e5b6d6dSopenharmony_ci * @stable ICU 3.8 1342e5b6d6dSopenharmony_ci */ 1352e5b6d6dSopenharmony_ci void adoptFrom(TimeZoneRule* from); 1362e5b6d6dSopenharmony_ci 1372e5b6d6dSopenharmony_ci /** 1382e5b6d6dSopenharmony_ci * Sets the rule used after the transition. The caller remains 1392e5b6d6dSopenharmony_ci * responsible for deleting the <code>TimeZoneRule</code> object. 1402e5b6d6dSopenharmony_ci * @param to The time zone rule used after the transition. 1412e5b6d6dSopenharmony_ci * @stable ICU 3.8 1422e5b6d6dSopenharmony_ci */ 1432e5b6d6dSopenharmony_ci void setTo(const TimeZoneRule& to); 1442e5b6d6dSopenharmony_ci 1452e5b6d6dSopenharmony_ci /** 1462e5b6d6dSopenharmony_ci * Adopts the rule used after the transition. The caller must 1472e5b6d6dSopenharmony_ci * not delete the <code>TimeZoneRule</code> object passed in. 1482e5b6d6dSopenharmony_ci * @param to The time zone rule used after the transition. 1492e5b6d6dSopenharmony_ci * @stable ICU 3.8 1502e5b6d6dSopenharmony_ci */ 1512e5b6d6dSopenharmony_ci void adoptTo(TimeZoneRule* to); 1522e5b6d6dSopenharmony_ci 1532e5b6d6dSopenharmony_ci /** 1542e5b6d6dSopenharmony_ci * Returns the rule used after the transition. 1552e5b6d6dSopenharmony_ci * @return The time zone rule used after the transition. 1562e5b6d6dSopenharmony_ci * @stable ICU 3.8 1572e5b6d6dSopenharmony_ci */ 1582e5b6d6dSopenharmony_ci const TimeZoneRule* getTo(void) const; 1592e5b6d6dSopenharmony_ci 1602e5b6d6dSopenharmony_ciprivate: 1612e5b6d6dSopenharmony_ci UDate fTime; 1622e5b6d6dSopenharmony_ci TimeZoneRule* fFrom; 1632e5b6d6dSopenharmony_ci TimeZoneRule* fTo; 1642e5b6d6dSopenharmony_ci 1652e5b6d6dSopenharmony_cipublic: 1662e5b6d6dSopenharmony_ci /** 1672e5b6d6dSopenharmony_ci * Return the class ID for this class. This is useful only for comparing to 1682e5b6d6dSopenharmony_ci * a return value from getDynamicClassID(). For example: 1692e5b6d6dSopenharmony_ci * <pre> 1702e5b6d6dSopenharmony_ci * . Base* polymorphic_pointer = createPolymorphicObject(); 1712e5b6d6dSopenharmony_ci * . if (polymorphic_pointer->getDynamicClassID() == 1722e5b6d6dSopenharmony_ci * . erived::getStaticClassID()) ... 1732e5b6d6dSopenharmony_ci * </pre> 1742e5b6d6dSopenharmony_ci * @return The class ID for all objects of this class. 1752e5b6d6dSopenharmony_ci * @stable ICU 3.8 1762e5b6d6dSopenharmony_ci */ 1772e5b6d6dSopenharmony_ci static UClassID U_EXPORT2 getStaticClassID(void); 1782e5b6d6dSopenharmony_ci 1792e5b6d6dSopenharmony_ci /** 1802e5b6d6dSopenharmony_ci * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This 1812e5b6d6dSopenharmony_ci * method is to implement a simple version of RTTI, since not all C++ 1822e5b6d6dSopenharmony_ci * compilers support genuine RTTI. Polymorphic operator==() and clone() 1832e5b6d6dSopenharmony_ci * methods call this method. 1842e5b6d6dSopenharmony_ci * 1852e5b6d6dSopenharmony_ci * @return The class ID for this object. All objects of a 1862e5b6d6dSopenharmony_ci * given class have the same class ID. Objects of 1872e5b6d6dSopenharmony_ci * other classes have different class IDs. 1882e5b6d6dSopenharmony_ci * @stable ICU 3.8 1892e5b6d6dSopenharmony_ci */ 1902e5b6d6dSopenharmony_ci virtual UClassID getDynamicClassID(void) const override; 1912e5b6d6dSopenharmony_ci}; 1922e5b6d6dSopenharmony_ci 1932e5b6d6dSopenharmony_ciU_NAMESPACE_END 1942e5b6d6dSopenharmony_ci 1952e5b6d6dSopenharmony_ci#endif /* #if !UCONFIG_NO_FORMATTING */ 1962e5b6d6dSopenharmony_ci 1972e5b6d6dSopenharmony_ci#endif /* U_SHOW_CPLUSPLUS_API */ 1982e5b6d6dSopenharmony_ci 1992e5b6d6dSopenharmony_ci#endif // TZTRANS_H 2002e5b6d6dSopenharmony_ci 2012e5b6d6dSopenharmony_ci//eof 202