1*0e209d39SAndroid Build Coastguard Worker // © 2016 and later: Unicode, Inc. and others. 2*0e209d39SAndroid Build Coastguard Worker // License & terms of use: http://www.unicode.org/copyright.html 3*0e209d39SAndroid Build Coastguard Worker /* 4*0e209d39SAndroid Build Coastguard Worker ******************************************************************************* 5*0e209d39SAndroid Build Coastguard Worker * Copyright (C) 2007-2013, International Business Machines Corporation and 6*0e209d39SAndroid Build Coastguard Worker * others. All Rights Reserved. 7*0e209d39SAndroid Build Coastguard Worker ******************************************************************************* 8*0e209d39SAndroid Build Coastguard Worker */ 9*0e209d39SAndroid Build Coastguard Worker #ifndef VTZONE_H 10*0e209d39SAndroid Build Coastguard Worker #define VTZONE_H 11*0e209d39SAndroid Build Coastguard Worker 12*0e209d39SAndroid Build Coastguard Worker #include "unicode/utypes.h" 13*0e209d39SAndroid Build Coastguard Worker 14*0e209d39SAndroid Build Coastguard Worker #if U_SHOW_CPLUSPLUS_API 15*0e209d39SAndroid Build Coastguard Worker 16*0e209d39SAndroid Build Coastguard Worker /** 17*0e209d39SAndroid Build Coastguard Worker * \file 18*0e209d39SAndroid Build Coastguard Worker * \brief C++ API: RFC2445 VTIMEZONE support 19*0e209d39SAndroid Build Coastguard Worker */ 20*0e209d39SAndroid Build Coastguard Worker 21*0e209d39SAndroid Build Coastguard Worker #if !UCONFIG_NO_FORMATTING 22*0e209d39SAndroid Build Coastguard Worker 23*0e209d39SAndroid Build Coastguard Worker #include "unicode/basictz.h" 24*0e209d39SAndroid Build Coastguard Worker 25*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_BEGIN 26*0e209d39SAndroid Build Coastguard Worker 27*0e209d39SAndroid Build Coastguard Worker class VTZWriter; 28*0e209d39SAndroid Build Coastguard Worker class VTZReader; 29*0e209d39SAndroid Build Coastguard Worker class UVector; 30*0e209d39SAndroid Build Coastguard Worker 31*0e209d39SAndroid Build Coastguard Worker /** 32*0e209d39SAndroid Build Coastguard Worker * <code>VTimeZone</code> is a class implementing RFC2445 VTIMEZONE. You can create a 33*0e209d39SAndroid Build Coastguard Worker * <code>VTimeZone</code> instance from a time zone ID supported by <code>TimeZone</code>. 34*0e209d39SAndroid Build Coastguard Worker * With the <code>VTimeZone</code> instance created from the ID, you can write out the rule 35*0e209d39SAndroid Build Coastguard Worker * in RFC2445 VTIMEZONE format. Also, you can create a <code>VTimeZone</code> instance 36*0e209d39SAndroid Build Coastguard Worker * from RFC2445 VTIMEZONE data stream, which allows you to calculate time 37*0e209d39SAndroid Build Coastguard Worker * zone offset by the rules defined by the data. Or, you can create a 38*0e209d39SAndroid Build Coastguard Worker * <code>VTimeZone</code> from any other ICU <code>BasicTimeZone</code>. 39*0e209d39SAndroid Build Coastguard Worker * <br><br> 40*0e209d39SAndroid Build Coastguard Worker * Note: The consumer of this class reading or writing VTIMEZONE data is responsible to 41*0e209d39SAndroid Build Coastguard Worker * decode or encode Non-ASCII text. Methods reading/writing VTIMEZONE data in this class 42*0e209d39SAndroid Build Coastguard Worker * do nothing with MIME encoding. 43*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 44*0e209d39SAndroid Build Coastguard Worker */ 45*0e209d39SAndroid Build Coastguard Worker class U_I18N_API VTimeZone : public BasicTimeZone { 46*0e209d39SAndroid Build Coastguard Worker public: 47*0e209d39SAndroid Build Coastguard Worker /** 48*0e209d39SAndroid Build Coastguard Worker * Copy constructor. 49*0e209d39SAndroid Build Coastguard Worker * @param source The <code>VTimeZone</code> object to be copied. 50*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 51*0e209d39SAndroid Build Coastguard Worker */ 52*0e209d39SAndroid Build Coastguard Worker VTimeZone(const VTimeZone& source); 53*0e209d39SAndroid Build Coastguard Worker 54*0e209d39SAndroid Build Coastguard Worker /** 55*0e209d39SAndroid Build Coastguard Worker * Destructor. 56*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 57*0e209d39SAndroid Build Coastguard Worker */ 58*0e209d39SAndroid Build Coastguard Worker virtual ~VTimeZone(); 59*0e209d39SAndroid Build Coastguard Worker 60*0e209d39SAndroid Build Coastguard Worker /** 61*0e209d39SAndroid Build Coastguard Worker * Assignment operator. 62*0e209d39SAndroid Build Coastguard Worker * @param right The object to be copied. 63*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 64*0e209d39SAndroid Build Coastguard Worker */ 65*0e209d39SAndroid Build Coastguard Worker VTimeZone& operator=(const VTimeZone& right); 66*0e209d39SAndroid Build Coastguard Worker 67*0e209d39SAndroid Build Coastguard Worker /** 68*0e209d39SAndroid Build Coastguard Worker * Return true if the given <code>TimeZone</code> objects are 69*0e209d39SAndroid Build Coastguard Worker * semantically equal. Objects of different subclasses are considered unequal. 70*0e209d39SAndroid Build Coastguard Worker * @param that The object to be compared with. 71*0e209d39SAndroid Build Coastguard Worker * @return true if the given <code>TimeZone</code> objects are 72*0e209d39SAndroid Build Coastguard Worker *semantically equal. 73*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 74*0e209d39SAndroid Build Coastguard Worker */ 75*0e209d39SAndroid Build Coastguard Worker virtual bool operator==(const TimeZone& that) const override; 76*0e209d39SAndroid Build Coastguard Worker 77*0e209d39SAndroid Build Coastguard Worker /** 78*0e209d39SAndroid Build Coastguard Worker * Return true if the given <code>TimeZone</code> objects are 79*0e209d39SAndroid Build Coastguard Worker * semantically unequal. Objects of different subclasses are considered unequal. 80*0e209d39SAndroid Build Coastguard Worker * @param that The object to be compared with. 81*0e209d39SAndroid Build Coastguard Worker * @return true if the given <code>TimeZone</code> objects are 82*0e209d39SAndroid Build Coastguard Worker * semantically unequal. 83*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 84*0e209d39SAndroid Build Coastguard Worker */ 85*0e209d39SAndroid Build Coastguard Worker virtual bool operator!=(const TimeZone& that) const; 86*0e209d39SAndroid Build Coastguard Worker 87*0e209d39SAndroid Build Coastguard Worker /** 88*0e209d39SAndroid Build Coastguard Worker * Create a <code>VTimeZone</code> instance by the time zone ID. 89*0e209d39SAndroid Build Coastguard Worker * @param ID The time zone ID, such as America/New_York 90*0e209d39SAndroid Build Coastguard Worker * @return A <code>VTimeZone</code> object initialized by the time zone ID, 91*0e209d39SAndroid Build Coastguard Worker * or nullptr when the ID is unknown. 92*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 93*0e209d39SAndroid Build Coastguard Worker */ 94*0e209d39SAndroid Build Coastguard Worker static VTimeZone* createVTimeZoneByID(const UnicodeString& ID); 95*0e209d39SAndroid Build Coastguard Worker 96*0e209d39SAndroid Build Coastguard Worker /** 97*0e209d39SAndroid Build Coastguard Worker * Create a <code>VTimeZone</code> instance using a basic time zone. 98*0e209d39SAndroid Build Coastguard Worker * @param basicTZ The basic time zone instance 99*0e209d39SAndroid Build Coastguard Worker * @param status Output param to filled in with a success or an error. 100*0e209d39SAndroid Build Coastguard Worker * @return A <code>VTimeZone</code> object initialized by the basic time zone. 101*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 102*0e209d39SAndroid Build Coastguard Worker */ 103*0e209d39SAndroid Build Coastguard Worker static VTimeZone* createVTimeZoneFromBasicTimeZone(const BasicTimeZone& basicTZ, 104*0e209d39SAndroid Build Coastguard Worker UErrorCode &status); 105*0e209d39SAndroid Build Coastguard Worker 106*0e209d39SAndroid Build Coastguard Worker /** 107*0e209d39SAndroid Build Coastguard Worker * Create a <code>VTimeZone</code> instance by RFC2445 VTIMEZONE data 108*0e209d39SAndroid Build Coastguard Worker * 109*0e209d39SAndroid Build Coastguard Worker * @param vtzdata The string including VTIMEZONE data block 110*0e209d39SAndroid Build Coastguard Worker * @param status Output param to filled in with a success or an error. 111*0e209d39SAndroid Build Coastguard Worker * @return A <code>VTimeZone</code> initialized by the VTIMEZONE data or 112*0e209d39SAndroid Build Coastguard Worker * nullptr if failed to load the rule from the VTIMEZONE data. 113*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 114*0e209d39SAndroid Build Coastguard Worker */ 115*0e209d39SAndroid Build Coastguard Worker static VTimeZone* createVTimeZone(const UnicodeString& vtzdata, UErrorCode& status); 116*0e209d39SAndroid Build Coastguard Worker 117*0e209d39SAndroid Build Coastguard Worker /** 118*0e209d39SAndroid Build Coastguard Worker * Gets the RFC2445 TZURL property value. When a <code>VTimeZone</code> instance was 119*0e209d39SAndroid Build Coastguard Worker * created from VTIMEZONE data, the initial value is set by the TZURL property value 120*0e209d39SAndroid Build Coastguard Worker * in the data. Otherwise, the initial value is not set. 121*0e209d39SAndroid Build Coastguard Worker * @param url Receives the RFC2445 TZURL property value. 122*0e209d39SAndroid Build Coastguard Worker * @return true if TZURL attribute is available and value is set. 123*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 124*0e209d39SAndroid Build Coastguard Worker */ 125*0e209d39SAndroid Build Coastguard Worker UBool getTZURL(UnicodeString& url) const; 126*0e209d39SAndroid Build Coastguard Worker 127*0e209d39SAndroid Build Coastguard Worker /** 128*0e209d39SAndroid Build Coastguard Worker * Sets the RFC2445 TZURL property value. 129*0e209d39SAndroid Build Coastguard Worker * @param url The TZURL property value. 130*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 131*0e209d39SAndroid Build Coastguard Worker */ 132*0e209d39SAndroid Build Coastguard Worker void setTZURL(const UnicodeString& url); 133*0e209d39SAndroid Build Coastguard Worker 134*0e209d39SAndroid Build Coastguard Worker /** 135*0e209d39SAndroid Build Coastguard Worker * Gets the RFC2445 LAST-MODIFIED property value. When a <code>VTimeZone</code> instance 136*0e209d39SAndroid Build Coastguard Worker * was created from VTIMEZONE data, the initial value is set by the LAST-MODIFIED property 137*0e209d39SAndroid Build Coastguard Worker * value in the data. Otherwise, the initial value is not set. 138*0e209d39SAndroid Build Coastguard Worker * @param lastModified Receives the last modified date. 139*0e209d39SAndroid Build Coastguard Worker * @return true if lastModified attribute is available and value is set. 140*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 141*0e209d39SAndroid Build Coastguard Worker */ 142*0e209d39SAndroid Build Coastguard Worker UBool getLastModified(UDate& lastModified) const; 143*0e209d39SAndroid Build Coastguard Worker 144*0e209d39SAndroid Build Coastguard Worker /** 145*0e209d39SAndroid Build Coastguard Worker * Sets the RFC2445 LAST-MODIFIED property value. 146*0e209d39SAndroid Build Coastguard Worker * @param lastModified The LAST-MODIFIED date. 147*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 148*0e209d39SAndroid Build Coastguard Worker */ 149*0e209d39SAndroid Build Coastguard Worker void setLastModified(UDate lastModified); 150*0e209d39SAndroid Build Coastguard Worker 151*0e209d39SAndroid Build Coastguard Worker /** 152*0e209d39SAndroid Build Coastguard Worker * Writes RFC2445 VTIMEZONE data for this time zone 153*0e209d39SAndroid Build Coastguard Worker * @param result Output param to filled in with the VTIMEZONE data. 154*0e209d39SAndroid Build Coastguard Worker * @param status Output param to filled in with a success or an error. 155*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 156*0e209d39SAndroid Build Coastguard Worker */ 157*0e209d39SAndroid Build Coastguard Worker void write(UnicodeString& result, UErrorCode& status) const; 158*0e209d39SAndroid Build Coastguard Worker 159*0e209d39SAndroid Build Coastguard Worker /** 160*0e209d39SAndroid Build Coastguard Worker * Writes RFC2445 VTIMEZONE data for this time zone applicable 161*0e209d39SAndroid Build Coastguard Worker * for dates after the specified start time. 162*0e209d39SAndroid Build Coastguard Worker * @param start The start date. 163*0e209d39SAndroid Build Coastguard Worker * @param result Output param to filled in with the VTIMEZONE data. 164*0e209d39SAndroid Build Coastguard Worker * @param status Output param to filled in with a success or an error. 165*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 166*0e209d39SAndroid Build Coastguard Worker */ 167*0e209d39SAndroid Build Coastguard Worker void write(UDate start, UnicodeString& result, UErrorCode& status) const; 168*0e209d39SAndroid Build Coastguard Worker 169*0e209d39SAndroid Build Coastguard Worker /** 170*0e209d39SAndroid Build Coastguard Worker * Writes RFC2445 VTIMEZONE data applicable for the specified date. 171*0e209d39SAndroid Build Coastguard Worker * Some common iCalendar implementations can only handle a single time 172*0e209d39SAndroid Build Coastguard Worker * zone property or a pair of standard and daylight time properties using 173*0e209d39SAndroid Build Coastguard Worker * BYDAY rule with day of week (such as BYDAY=1SUN). This method produce 174*0e209d39SAndroid Build Coastguard Worker * the VTIMEZONE data which can be handled these implementations. The rules 175*0e209d39SAndroid Build Coastguard Worker * produced by this method can be used only for calculating time zone offset 176*0e209d39SAndroid Build Coastguard Worker * around the specified date. 177*0e209d39SAndroid Build Coastguard Worker * @param time The date used for rule extraction. 178*0e209d39SAndroid Build Coastguard Worker * @param result Output param to filled in with the VTIMEZONE data. 179*0e209d39SAndroid Build Coastguard Worker * @param status Output param to filled in with a success or an error. 180*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 181*0e209d39SAndroid Build Coastguard Worker */ 182*0e209d39SAndroid Build Coastguard Worker void writeSimple(UDate time, UnicodeString& result, UErrorCode& status) const; 183*0e209d39SAndroid Build Coastguard Worker 184*0e209d39SAndroid Build Coastguard Worker /** 185*0e209d39SAndroid Build Coastguard Worker * Clones TimeZone objects polymorphically. Clients are responsible for deleting 186*0e209d39SAndroid Build Coastguard Worker * the TimeZone object cloned. 187*0e209d39SAndroid Build Coastguard Worker * @return A new copy of this TimeZone object. 188*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 189*0e209d39SAndroid Build Coastguard Worker */ 190*0e209d39SAndroid Build Coastguard Worker virtual VTimeZone* clone() const override; 191*0e209d39SAndroid Build Coastguard Worker 192*0e209d39SAndroid Build Coastguard Worker /** 193*0e209d39SAndroid Build Coastguard Worker * Returns the TimeZone's adjusted GMT offset (i.e., the number of milliseconds to add 194*0e209d39SAndroid Build Coastguard Worker * to GMT to get local time in this time zone, taking daylight savings time into 195*0e209d39SAndroid Build Coastguard Worker * account) as of a particular reference date. The reference date is used to determine 196*0e209d39SAndroid Build Coastguard Worker * whether daylight savings time is in effect and needs to be figured into the offset 197*0e209d39SAndroid Build Coastguard Worker * that is returned (in other words, what is the adjusted GMT offset in this time zone 198*0e209d39SAndroid Build Coastguard Worker * at this particular date and time?). For the time zones produced by createTimeZone(), 199*0e209d39SAndroid Build Coastguard Worker * the reference data is specified according to the Gregorian calendar, and the date 200*0e209d39SAndroid Build Coastguard Worker * and time fields are local standard time. 201*0e209d39SAndroid Build Coastguard Worker * 202*0e209d39SAndroid Build Coastguard Worker * <p>Note: Don't call this method. Instead, call the getOffset(UDate...) overload, 203*0e209d39SAndroid Build Coastguard Worker * which returns both the raw and the DST offset for a given time. This method 204*0e209d39SAndroid Build Coastguard Worker * is retained only for backward compatibility. 205*0e209d39SAndroid Build Coastguard Worker * 206*0e209d39SAndroid Build Coastguard Worker * @param era The reference date's era 207*0e209d39SAndroid Build Coastguard Worker * @param year The reference date's year 208*0e209d39SAndroid Build Coastguard Worker * @param month The reference date's month (0-based; 0 is January) 209*0e209d39SAndroid Build Coastguard Worker * @param day The reference date's day-in-month (1-based) 210*0e209d39SAndroid Build Coastguard Worker * @param dayOfWeek The reference date's day-of-week (1-based; 1 is Sunday) 211*0e209d39SAndroid Build Coastguard Worker * @param millis The reference date's milliseconds in day, local standard time 212*0e209d39SAndroid Build Coastguard Worker * @param status Output param to filled in with a success or an error. 213*0e209d39SAndroid Build Coastguard Worker * @return The offset in milliseconds to add to GMT to get local time. 214*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 215*0e209d39SAndroid Build Coastguard Worker */ 216*0e209d39SAndroid Build Coastguard Worker virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day, 217*0e209d39SAndroid Build Coastguard Worker uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const override; 218*0e209d39SAndroid Build Coastguard Worker 219*0e209d39SAndroid Build Coastguard Worker /** 220*0e209d39SAndroid Build Coastguard Worker * Gets the time zone offset, for current date, modified in case of 221*0e209d39SAndroid Build Coastguard Worker * daylight savings. This is the offset to add *to* UTC to get local time. 222*0e209d39SAndroid Build Coastguard Worker * 223*0e209d39SAndroid Build Coastguard Worker * <p>Note: Don't call this method. Instead, call the getOffset(UDate...) overload, 224*0e209d39SAndroid Build Coastguard Worker * which returns both the raw and the DST offset for a given time. This method 225*0e209d39SAndroid Build Coastguard Worker * is retained only for backward compatibility. 226*0e209d39SAndroid Build Coastguard Worker * 227*0e209d39SAndroid Build Coastguard Worker * @param era The reference date's era 228*0e209d39SAndroid Build Coastguard Worker * @param year The reference date's year 229*0e209d39SAndroid Build Coastguard Worker * @param month The reference date's month (0-based; 0 is January) 230*0e209d39SAndroid Build Coastguard Worker * @param day The reference date's day-in-month (1-based) 231*0e209d39SAndroid Build Coastguard Worker * @param dayOfWeek The reference date's day-of-week (1-based; 1 is Sunday) 232*0e209d39SAndroid Build Coastguard Worker * @param millis The reference date's milliseconds in day, local standard time 233*0e209d39SAndroid Build Coastguard Worker * @param monthLength The length of the given month in days. 234*0e209d39SAndroid Build Coastguard Worker * @param status Output param to filled in with a success or an error. 235*0e209d39SAndroid Build Coastguard Worker * @return The offset in milliseconds to add to GMT to get local time. 236*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 237*0e209d39SAndroid Build Coastguard Worker */ 238*0e209d39SAndroid Build Coastguard Worker virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day, 239*0e209d39SAndroid Build Coastguard Worker uint8_t dayOfWeek, int32_t millis, 240*0e209d39SAndroid Build Coastguard Worker int32_t monthLength, UErrorCode& status) const override; 241*0e209d39SAndroid Build Coastguard Worker 242*0e209d39SAndroid Build Coastguard Worker /** 243*0e209d39SAndroid Build Coastguard Worker * Returns the time zone raw and GMT offset for the given moment 244*0e209d39SAndroid Build Coastguard Worker * in time. Upon return, local-millis = GMT-millis + rawOffset + 245*0e209d39SAndroid Build Coastguard Worker * dstOffset. All computations are performed in the proleptic 246*0e209d39SAndroid Build Coastguard Worker * Gregorian calendar. The default implementation in the TimeZone 247*0e209d39SAndroid Build Coastguard Worker * class delegates to the 8-argument getOffset(). 248*0e209d39SAndroid Build Coastguard Worker * 249*0e209d39SAndroid Build Coastguard Worker * @param date moment in time for which to return offsets, in 250*0e209d39SAndroid Build Coastguard Worker * units of milliseconds from January 1, 1970 0:00 GMT, either GMT 251*0e209d39SAndroid Build Coastguard Worker * time or local wall time, depending on `local'. 252*0e209d39SAndroid Build Coastguard Worker * @param local if true, `date' is local wall time; otherwise it 253*0e209d39SAndroid Build Coastguard Worker * is in GMT time. 254*0e209d39SAndroid Build Coastguard Worker * @param rawOffset output parameter to receive the raw offset, that 255*0e209d39SAndroid Build Coastguard Worker * is, the offset not including DST adjustments 256*0e209d39SAndroid Build Coastguard Worker * @param dstOffset output parameter to receive the DST offset, 257*0e209d39SAndroid Build Coastguard Worker * that is, the offset to be added to `rawOffset' to obtain the 258*0e209d39SAndroid Build Coastguard Worker * total offset between local and GMT time. If DST is not in 259*0e209d39SAndroid Build Coastguard Worker * effect, this value is zero; otherwise it is a positive value, 260*0e209d39SAndroid Build Coastguard Worker * typically one hour. 261*0e209d39SAndroid Build Coastguard Worker * @param ec input-output error code 262*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 263*0e209d39SAndroid Build Coastguard Worker */ 264*0e209d39SAndroid Build Coastguard Worker virtual void getOffset(UDate date, UBool local, int32_t& rawOffset, 265*0e209d39SAndroid Build Coastguard Worker int32_t& dstOffset, UErrorCode& ec) const override; 266*0e209d39SAndroid Build Coastguard Worker 267*0e209d39SAndroid Build Coastguard Worker /** 268*0e209d39SAndroid Build Coastguard Worker * Get time zone offsets from local wall time. 269*0e209d39SAndroid Build Coastguard Worker * @stable ICU 69 270*0e209d39SAndroid Build Coastguard Worker */ 271*0e209d39SAndroid Build Coastguard Worker virtual void getOffsetFromLocal( 272*0e209d39SAndroid Build Coastguard Worker UDate date, UTimeZoneLocalOption nonExistingTimeOpt, 273*0e209d39SAndroid Build Coastguard Worker UTimeZoneLocalOption duplicatedTimeOpt, 274*0e209d39SAndroid Build Coastguard Worker int32_t& rawOffset, int32_t& dstOffset, UErrorCode& status) const override; 275*0e209d39SAndroid Build Coastguard Worker 276*0e209d39SAndroid Build Coastguard Worker /** 277*0e209d39SAndroid Build Coastguard Worker * Sets the TimeZone's raw GMT offset (i.e., the number of milliseconds to add 278*0e209d39SAndroid Build Coastguard Worker * to GMT to get local time, before taking daylight savings time into account). 279*0e209d39SAndroid Build Coastguard Worker * 280*0e209d39SAndroid Build Coastguard Worker * @param offsetMillis The new raw GMT offset for this time zone. 281*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 282*0e209d39SAndroid Build Coastguard Worker */ 283*0e209d39SAndroid Build Coastguard Worker virtual void setRawOffset(int32_t offsetMillis) override; 284*0e209d39SAndroid Build Coastguard Worker 285*0e209d39SAndroid Build Coastguard Worker /** 286*0e209d39SAndroid Build Coastguard Worker * Returns the TimeZone's raw GMT offset (i.e., the number of milliseconds to add 287*0e209d39SAndroid Build Coastguard Worker * to GMT to get local time, before taking daylight savings time into account). 288*0e209d39SAndroid Build Coastguard Worker * 289*0e209d39SAndroid Build Coastguard Worker * @return The TimeZone's raw GMT offset. 290*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 291*0e209d39SAndroid Build Coastguard Worker */ 292*0e209d39SAndroid Build Coastguard Worker virtual int32_t getRawOffset() const override; 293*0e209d39SAndroid Build Coastguard Worker 294*0e209d39SAndroid Build Coastguard Worker /** 295*0e209d39SAndroid Build Coastguard Worker * Queries if this time zone uses daylight savings time. 296*0e209d39SAndroid Build Coastguard Worker * @return true if this time zone uses daylight savings time, 297*0e209d39SAndroid Build Coastguard Worker * false, otherwise. 298*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 299*0e209d39SAndroid Build Coastguard Worker */ 300*0e209d39SAndroid Build Coastguard Worker virtual UBool useDaylightTime() const override; 301*0e209d39SAndroid Build Coastguard Worker 302*0e209d39SAndroid Build Coastguard Worker #ifndef U_FORCE_HIDE_DEPRECATED_API 303*0e209d39SAndroid Build Coastguard Worker /** 304*0e209d39SAndroid Build Coastguard Worker * Queries if the given date is in daylight savings time in 305*0e209d39SAndroid Build Coastguard Worker * this time zone. 306*0e209d39SAndroid Build Coastguard Worker * This method is wasteful since it creates a new GregorianCalendar and 307*0e209d39SAndroid Build Coastguard Worker * deletes it each time it is called. This is a deprecated method 308*0e209d39SAndroid Build Coastguard Worker * and provided only for Java compatibility. 309*0e209d39SAndroid Build Coastguard Worker * 310*0e209d39SAndroid Build Coastguard Worker * @param date the given UDate. 311*0e209d39SAndroid Build Coastguard Worker * @param status Output param filled in with success/error code. 312*0e209d39SAndroid Build Coastguard Worker * @return true if the given date is in daylight savings time, 313*0e209d39SAndroid Build Coastguard Worker * false, otherwise. 314*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 2.4. Use Calendar::inDaylightTime() instead. 315*0e209d39SAndroid Build Coastguard Worker */ 316*0e209d39SAndroid Build Coastguard Worker virtual UBool inDaylightTime(UDate date, UErrorCode& status) const override; 317*0e209d39SAndroid Build Coastguard Worker #endif // U_FORCE_HIDE_DEPRECATED_API 318*0e209d39SAndroid Build Coastguard Worker 319*0e209d39SAndroid Build Coastguard Worker /** 320*0e209d39SAndroid Build Coastguard Worker * Returns true if this zone has the same rule and offset as another zone. 321*0e209d39SAndroid Build Coastguard Worker * That is, if this zone differs only in ID, if at all. 322*0e209d39SAndroid Build Coastguard Worker * @param other the <code>TimeZone</code> object to be compared with 323*0e209d39SAndroid Build Coastguard Worker * @return true if the given zone is the same as this one, 324*0e209d39SAndroid Build Coastguard Worker * with the possible exception of the ID 325*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 326*0e209d39SAndroid Build Coastguard Worker */ 327*0e209d39SAndroid Build Coastguard Worker virtual UBool hasSameRules(const TimeZone& other) const override; 328*0e209d39SAndroid Build Coastguard Worker 329*0e209d39SAndroid Build Coastguard Worker /** 330*0e209d39SAndroid Build Coastguard Worker * Gets the first time zone transition after the base time. 331*0e209d39SAndroid Build Coastguard Worker * @param base The base time. 332*0e209d39SAndroid Build Coastguard Worker * @param inclusive Whether the base time is inclusive or not. 333*0e209d39SAndroid Build Coastguard Worker * @param result Receives the first transition after the base time. 334*0e209d39SAndroid Build Coastguard Worker * @return true if the transition is found. 335*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 336*0e209d39SAndroid Build Coastguard Worker */ 337*0e209d39SAndroid Build Coastguard Worker virtual UBool getNextTransition(UDate base, UBool inclusive, TimeZoneTransition& result) const override; 338*0e209d39SAndroid Build Coastguard Worker 339*0e209d39SAndroid Build Coastguard Worker /** 340*0e209d39SAndroid Build Coastguard Worker * Gets the most recent time zone transition before the base time. 341*0e209d39SAndroid Build Coastguard Worker * @param base The base time. 342*0e209d39SAndroid Build Coastguard Worker * @param inclusive Whether the base time is inclusive or not. 343*0e209d39SAndroid Build Coastguard Worker * @param result Receives the most recent transition before the base time. 344*0e209d39SAndroid Build Coastguard Worker * @return true if the transition is found. 345*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 346*0e209d39SAndroid Build Coastguard Worker */ 347*0e209d39SAndroid Build Coastguard Worker virtual UBool getPreviousTransition(UDate base, UBool inclusive, TimeZoneTransition& result) const override; 348*0e209d39SAndroid Build Coastguard Worker 349*0e209d39SAndroid Build Coastguard Worker /** 350*0e209d39SAndroid Build Coastguard Worker * Returns the number of <code>TimeZoneRule</code>s which represents time transitions, 351*0e209d39SAndroid Build Coastguard Worker * for this time zone, that is, all <code>TimeZoneRule</code>s for this time zone except 352*0e209d39SAndroid Build Coastguard Worker * <code>InitialTimeZoneRule</code>. The return value range is 0 or any positive value. 353*0e209d39SAndroid Build Coastguard Worker * @param status Receives error status code. 354*0e209d39SAndroid Build Coastguard Worker * @return The number of <code>TimeZoneRule</code>s representing time transitions. 355*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 356*0e209d39SAndroid Build Coastguard Worker */ 357*0e209d39SAndroid Build Coastguard Worker virtual int32_t countTransitionRules(UErrorCode& status) const override; 358*0e209d39SAndroid Build Coastguard Worker 359*0e209d39SAndroid Build Coastguard Worker /** 360*0e209d39SAndroid Build Coastguard Worker * Gets the <code>InitialTimeZoneRule</code> and the set of <code>TimeZoneRule</code> 361*0e209d39SAndroid Build Coastguard Worker * which represent time transitions for this time zone. On successful return, 362*0e209d39SAndroid Build Coastguard Worker * the argument initial points to non-nullptr <code>InitialTimeZoneRule</code> and 363*0e209d39SAndroid Build Coastguard Worker * the array trsrules is filled with 0 or multiple <code>TimeZoneRule</code> 364*0e209d39SAndroid Build Coastguard Worker * instances up to the size specified by trscount. The results are referencing the 365*0e209d39SAndroid Build Coastguard Worker * rule instance held by this time zone instance. Therefore, after this time zone 366*0e209d39SAndroid Build Coastguard Worker * is destructed, they are no longer available. 367*0e209d39SAndroid Build Coastguard Worker * @param initial Receives the initial timezone rule 368*0e209d39SAndroid Build Coastguard Worker * @param trsrules Receives the timezone transition rules 369*0e209d39SAndroid Build Coastguard Worker * @param trscount On input, specify the size of the array 'transitions' receiving 370*0e209d39SAndroid Build Coastguard Worker * the timezone transition rules. On output, actual number of 371*0e209d39SAndroid Build Coastguard Worker * rules filled in the array will be set. 372*0e209d39SAndroid Build Coastguard Worker * @param status Receives error status code. 373*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 374*0e209d39SAndroid Build Coastguard Worker */ 375*0e209d39SAndroid Build Coastguard Worker virtual void getTimeZoneRules(const InitialTimeZoneRule*& initial, 376*0e209d39SAndroid Build Coastguard Worker const TimeZoneRule* trsrules[], int32_t& trscount, UErrorCode& status) const override; 377*0e209d39SAndroid Build Coastguard Worker 378*0e209d39SAndroid Build Coastguard Worker private: 379*0e209d39SAndroid Build Coastguard Worker enum { DEFAULT_VTIMEZONE_LINES = 100 }; 380*0e209d39SAndroid Build Coastguard Worker 381*0e209d39SAndroid Build Coastguard Worker /** 382*0e209d39SAndroid Build Coastguard Worker * Default constructor. 383*0e209d39SAndroid Build Coastguard Worker */ 384*0e209d39SAndroid Build Coastguard Worker VTimeZone(); 385*0e209d39SAndroid Build Coastguard Worker void write(VTZWriter& writer, UErrorCode& status) const; 386*0e209d39SAndroid Build Coastguard Worker void write(UDate start, VTZWriter& writer, UErrorCode& status) const; 387*0e209d39SAndroid Build Coastguard Worker void writeSimple(UDate time, VTZWriter& writer, UErrorCode& status) const; 388*0e209d39SAndroid Build Coastguard Worker void load(VTZReader& reader, UErrorCode& status); 389*0e209d39SAndroid Build Coastguard Worker void parse(UErrorCode& status); 390*0e209d39SAndroid Build Coastguard Worker 391*0e209d39SAndroid Build Coastguard Worker void writeZone(VTZWriter& w, BasicTimeZone& basictz, UVector* customProps, 392*0e209d39SAndroid Build Coastguard Worker UErrorCode& status) const; 393*0e209d39SAndroid Build Coastguard Worker 394*0e209d39SAndroid Build Coastguard Worker void writeHeaders(VTZWriter& w, UErrorCode& status) const; 395*0e209d39SAndroid Build Coastguard Worker void writeFooter(VTZWriter& writer, UErrorCode& status) const; 396*0e209d39SAndroid Build Coastguard Worker 397*0e209d39SAndroid Build Coastguard Worker void writeZonePropsByTime(VTZWriter& writer, UBool isDst, const UnicodeString& zonename, 398*0e209d39SAndroid Build Coastguard Worker int32_t fromOffset, int32_t toOffset, UDate time, UBool withRDATE, 399*0e209d39SAndroid Build Coastguard Worker UErrorCode& status) const; 400*0e209d39SAndroid Build Coastguard Worker void writeZonePropsByDOM(VTZWriter& writer, UBool isDst, const UnicodeString& zonename, 401*0e209d39SAndroid Build Coastguard Worker int32_t fromOffset, int32_t toOffset, 402*0e209d39SAndroid Build Coastguard Worker int32_t month, int32_t dayOfMonth, UDate startTime, UDate untilTime, 403*0e209d39SAndroid Build Coastguard Worker UErrorCode& status) const; 404*0e209d39SAndroid Build Coastguard Worker void writeZonePropsByDOW(VTZWriter& writer, UBool isDst, const UnicodeString& zonename, 405*0e209d39SAndroid Build Coastguard Worker int32_t fromOffset, int32_t toOffset, 406*0e209d39SAndroid Build Coastguard Worker int32_t month, int32_t weekInMonth, int32_t dayOfWeek, 407*0e209d39SAndroid Build Coastguard Worker UDate startTime, UDate untilTime, UErrorCode& status) const; 408*0e209d39SAndroid Build Coastguard Worker void writeZonePropsByDOW_GEQ_DOM(VTZWriter& writer, UBool isDst, const UnicodeString& zonename, 409*0e209d39SAndroid Build Coastguard Worker int32_t fromOffset, int32_t toOffset, 410*0e209d39SAndroid Build Coastguard Worker int32_t month, int32_t dayOfMonth, int32_t dayOfWeek, 411*0e209d39SAndroid Build Coastguard Worker UDate startTime, UDate untilTime, UErrorCode& status) const; 412*0e209d39SAndroid Build Coastguard Worker void writeZonePropsByDOW_GEQ_DOM_sub(VTZWriter& writer, int32_t month, int32_t dayOfMonth, 413*0e209d39SAndroid Build Coastguard Worker int32_t dayOfWeek, int32_t numDays, 414*0e209d39SAndroid Build Coastguard Worker UDate untilTime, int32_t fromOffset, UErrorCode& status) const; 415*0e209d39SAndroid Build Coastguard Worker void writeZonePropsByDOW_LEQ_DOM(VTZWriter& writer, UBool isDst, const UnicodeString& zonename, 416*0e209d39SAndroid Build Coastguard Worker int32_t fromOffset, int32_t toOffset, 417*0e209d39SAndroid Build Coastguard Worker int32_t month, int32_t dayOfMonth, int32_t dayOfWeek, 418*0e209d39SAndroid Build Coastguard Worker UDate startTime, UDate untilTime, UErrorCode& status) const; 419*0e209d39SAndroid Build Coastguard Worker void writeFinalRule(VTZWriter& writer, UBool isDst, const AnnualTimeZoneRule* rule, 420*0e209d39SAndroid Build Coastguard Worker int32_t fromRawOffset, int32_t fromDSTSavings, 421*0e209d39SAndroid Build Coastguard Worker UDate startTime, UErrorCode& status) const; 422*0e209d39SAndroid Build Coastguard Worker 423*0e209d39SAndroid Build Coastguard Worker void beginZoneProps(VTZWriter& writer, UBool isDst, const UnicodeString& zonename, 424*0e209d39SAndroid Build Coastguard Worker int32_t fromOffset, int32_t toOffset, UDate startTime, UErrorCode& status) const; 425*0e209d39SAndroid Build Coastguard Worker void endZoneProps(VTZWriter& writer, UBool isDst, UErrorCode& status) const; 426*0e209d39SAndroid Build Coastguard Worker void beginRRULE(VTZWriter& writer, int32_t month, UErrorCode& status) const; 427*0e209d39SAndroid Build Coastguard Worker void appendUNTIL(VTZWriter& writer, const UnicodeString& until, UErrorCode& status) const; 428*0e209d39SAndroid Build Coastguard Worker 429*0e209d39SAndroid Build Coastguard Worker BasicTimeZone *tz; 430*0e209d39SAndroid Build Coastguard Worker UVector *vtzlines; 431*0e209d39SAndroid Build Coastguard Worker UnicodeString tzurl; 432*0e209d39SAndroid Build Coastguard Worker UDate lastmod; 433*0e209d39SAndroid Build Coastguard Worker UnicodeString olsonzid; 434*0e209d39SAndroid Build Coastguard Worker UnicodeString icutzver; 435*0e209d39SAndroid Build Coastguard Worker 436*0e209d39SAndroid Build Coastguard Worker public: 437*0e209d39SAndroid Build Coastguard Worker /** 438*0e209d39SAndroid Build Coastguard Worker * Return the class ID for this class. This is useful only for comparing to 439*0e209d39SAndroid Build Coastguard Worker * a return value from getDynamicClassID(). For example: 440*0e209d39SAndroid Build Coastguard Worker * <pre> 441*0e209d39SAndroid Build Coastguard Worker * . Base* polymorphic_pointer = createPolymorphicObject(); 442*0e209d39SAndroid Build Coastguard Worker * . if (polymorphic_pointer->getDynamicClassID() == 443*0e209d39SAndroid Build Coastguard Worker * . erived::getStaticClassID()) ... 444*0e209d39SAndroid Build Coastguard Worker * </pre> 445*0e209d39SAndroid Build Coastguard Worker * @return The class ID for all objects of this class. 446*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 447*0e209d39SAndroid Build Coastguard Worker */ 448*0e209d39SAndroid Build Coastguard Worker static UClassID U_EXPORT2 getStaticClassID(); 449*0e209d39SAndroid Build Coastguard Worker 450*0e209d39SAndroid Build Coastguard Worker /** 451*0e209d39SAndroid Build Coastguard Worker * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This 452*0e209d39SAndroid Build Coastguard Worker * method is to implement a simple version of RTTI, since not all C++ 453*0e209d39SAndroid Build Coastguard Worker * compilers support genuine RTTI. Polymorphic operator==() and clone() 454*0e209d39SAndroid Build Coastguard Worker * methods call this method. 455*0e209d39SAndroid Build Coastguard Worker * 456*0e209d39SAndroid Build Coastguard Worker * @return The class ID for this object. All objects of a 457*0e209d39SAndroid Build Coastguard Worker * given class have the same class ID. Objects of 458*0e209d39SAndroid Build Coastguard Worker * other classes have different class IDs. 459*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 460*0e209d39SAndroid Build Coastguard Worker */ 461*0e209d39SAndroid Build Coastguard Worker virtual UClassID getDynamicClassID() const override; 462*0e209d39SAndroid Build Coastguard Worker }; 463*0e209d39SAndroid Build Coastguard Worker 464*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_END 465*0e209d39SAndroid Build Coastguard Worker 466*0e209d39SAndroid Build Coastguard Worker #endif /* #if !UCONFIG_NO_FORMATTING */ 467*0e209d39SAndroid Build Coastguard Worker 468*0e209d39SAndroid Build Coastguard Worker #endif /* U_SHOW_CPLUSPLUS_API */ 469*0e209d39SAndroid Build Coastguard Worker 470*0e209d39SAndroid Build Coastguard Worker #endif // VTZONE_H 471*0e209d39SAndroid Build Coastguard Worker //eof 472