1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/icu/source/i18n/unicode/basictz.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,214 @@ 1.4 +/* 1.5 +******************************************************************************* 1.6 +* Copyright (C) 2007-2013, International Business Machines Corporation and 1.7 +* others. All Rights Reserved. 1.8 +******************************************************************************* 1.9 +*/ 1.10 +#ifndef BASICTZ_H 1.11 +#define BASICTZ_H 1.12 + 1.13 +/** 1.14 + * \file 1.15 + * \brief C++ API: ICU TimeZone base class 1.16 + */ 1.17 + 1.18 +#include "unicode/utypes.h" 1.19 + 1.20 +#if !UCONFIG_NO_FORMATTING 1.21 + 1.22 +#include "unicode/timezone.h" 1.23 +#include "unicode/tzrule.h" 1.24 +#include "unicode/tztrans.h" 1.25 + 1.26 +U_NAMESPACE_BEGIN 1.27 + 1.28 +// forward declarations 1.29 +class UVector; 1.30 + 1.31 +/** 1.32 + * <code>BasicTimeZone</code> is an abstract class extending <code>TimeZone</code>. 1.33 + * This class provides some additional methods to access time zone transitions and rules. 1.34 + * All ICU <code>TimeZone</code> concrete subclasses extend this class. 1.35 + * @stable ICU 3.8 1.36 + */ 1.37 +class U_I18N_API BasicTimeZone: public TimeZone { 1.38 +public: 1.39 + /** 1.40 + * Destructor. 1.41 + * @stable ICU 3.8 1.42 + */ 1.43 + virtual ~BasicTimeZone(); 1.44 + 1.45 + /** 1.46 + * Gets the first time zone transition after the base time. 1.47 + * @param base The base time. 1.48 + * @param inclusive Whether the base time is inclusive or not. 1.49 + * @param result Receives the first transition after the base time. 1.50 + * @return TRUE if the transition is found. 1.51 + * @stable ICU 3.8 1.52 + */ 1.53 + virtual UBool getNextTransition(UDate base, UBool inclusive, TimeZoneTransition& result) const = 0; 1.54 + 1.55 + /** 1.56 + * Gets the most recent time zone transition before the base time. 1.57 + * @param base The base time. 1.58 + * @param inclusive Whether the base time is inclusive or not. 1.59 + * @param result Receives the most recent transition before the base time. 1.60 + * @return TRUE if the transition is found. 1.61 + * @stable ICU 3.8 1.62 + */ 1.63 + virtual UBool getPreviousTransition(UDate base, UBool inclusive, TimeZoneTransition& result) const = 0; 1.64 + 1.65 + /** 1.66 + * Checks if the time zone has equivalent transitions in the time range. 1.67 + * This method returns true when all of transition times, from/to standard 1.68 + * offsets and DST savings used by this time zone match the other in the 1.69 + * time range. 1.70 + * @param tz The <code>BasicTimeZone</code> object to be compared with. 1.71 + * @param start The start time of the evaluated time range (inclusive) 1.72 + * @param end The end time of the evaluated time range (inclusive) 1.73 + * @param ignoreDstAmount 1.74 + * When true, any transitions with only daylight saving amount 1.75 + * changes will be ignored, except either of them is zero. 1.76 + * For example, a transition from rawoffset 3:00/dstsavings 1:00 1.77 + * to rawoffset 2:00/dstsavings 2:00 is excluded from the comparison, 1.78 + * but a transtion from rawoffset 2:00/dstsavings 1:00 to 1.79 + * rawoffset 3:00/dstsavings 0:00 is included. 1.80 + * @param ec Output param to filled in with a success or an error. 1.81 + * @return true if the other time zone has the equivalent transitions in the 1.82 + * time range. 1.83 + * @stable ICU 3.8 1.84 + */ 1.85 + virtual UBool hasEquivalentTransitions(const BasicTimeZone& tz, UDate start, UDate end, 1.86 + UBool ignoreDstAmount, UErrorCode& ec) const; 1.87 + 1.88 + /** 1.89 + * Returns the number of <code>TimeZoneRule</code>s which represents time transitions, 1.90 + * for this time zone, that is, all <code>TimeZoneRule</code>s for this time zone except 1.91 + * <code>InitialTimeZoneRule</code>. The return value range is 0 or any positive value. 1.92 + * @param status Receives error status code. 1.93 + * @return The number of <code>TimeZoneRule</code>s representing time transitions. 1.94 + * @stable ICU 3.8 1.95 + */ 1.96 + virtual int32_t countTransitionRules(UErrorCode& status) const = 0; 1.97 + 1.98 + /** 1.99 + * Gets the <code>InitialTimeZoneRule</code> and the set of <code>TimeZoneRule</code> 1.100 + * which represent time transitions for this time zone. On successful return, 1.101 + * the argument initial points to non-NULL <code>InitialTimeZoneRule</code> and 1.102 + * the array trsrules is filled with 0 or multiple <code>TimeZoneRule</code> 1.103 + * instances up to the size specified by trscount. The results are referencing the 1.104 + * rule instance held by this time zone instance. Therefore, after this time zone 1.105 + * is destructed, they are no longer available. 1.106 + * @param initial Receives the initial timezone rule 1.107 + * @param trsrules Receives the timezone transition rules 1.108 + * @param trscount On input, specify the size of the array 'transitions' receiving 1.109 + * the timezone transition rules. On output, actual number of 1.110 + * rules filled in the array will be set. 1.111 + * @param status Receives error status code. 1.112 + * @stable ICU 3.8 1.113 + */ 1.114 + virtual void getTimeZoneRules(const InitialTimeZoneRule*& initial, 1.115 + const TimeZoneRule* trsrules[], int32_t& trscount, UErrorCode& status) const = 0; 1.116 + 1.117 + /** 1.118 + * Gets the set of time zone rules valid at the specified time. Some known external time zone 1.119 + * implementations are not capable to handle historic time zone rule changes. Also some 1.120 + * implementations can only handle certain type of rule definitions. 1.121 + * If this time zone does not use any daylight saving time within about 1 year from the specified 1.122 + * time, only the <code>InitialTimeZone</code> is returned. Otherwise, the rule for standard 1.123 + * time and daylight saving time transitions are returned in addition to the 1.124 + * <code>InitialTimeZoneRule</code>. The standard and daylight saving time transition rules are 1.125 + * represented by <code>AnnualTimeZoneRule</code> with <code>DateTimeRule::DOW</code> for its date 1.126 + * rule and <code>DateTimeRule::WALL_TIME</code> for its time rule. Because daylight saving time 1.127 + * rule is changing time to time in many time zones and also mapping a transition time rule to 1.128 + * different type is lossy transformation, the set of rules returned by this method may be valid 1.129 + * for short period of time. 1.130 + * The time zone rule objects returned by this method is owned by the caller, so the caller is 1.131 + * responsible for deleting them after use. 1.132 + * @param date The date used for extracting time zone rules. 1.133 + * @param initial Receives the <code>InitialTimeZone</code>, always not NULL. 1.134 + * @param std Receives the <code>AnnualTimeZoneRule</code> for standard time transitions. 1.135 + * When this time time zone does not observe daylight saving times around the 1.136 + * specified date, NULL is set. 1.137 + * @param dst Receives the <code>AnnualTimeZoneRule</code> for daylight saving time 1.138 + * transitions. When this time zone does not observer daylight saving times 1.139 + * around the specified date, NULL is set. 1.140 + * @param status Receives error status code. 1.141 + * @stable ICU 3.8 1.142 + */ 1.143 + virtual void getSimpleRulesNear(UDate date, InitialTimeZoneRule*& initial, 1.144 + AnnualTimeZoneRule*& std, AnnualTimeZoneRule*& dst, UErrorCode& status) const; 1.145 + 1.146 + 1.147 +#ifndef U_HIDE_INTERNAL_API 1.148 + /** 1.149 + * The time type option bit flags used by getOffsetFromLocal 1.150 + * @internal 1.151 + */ 1.152 + enum { 1.153 + kStandard = 0x01, 1.154 + kDaylight = 0x03, 1.155 + kFormer = 0x04, 1.156 + kLatter = 0x0C 1.157 + }; 1.158 +#endif /* U_HIDE_INTERNAL_API */ 1.159 + 1.160 + /** 1.161 + * Get time zone offsets from local wall time. 1.162 + * @internal 1.163 + */ 1.164 + virtual void getOffsetFromLocal(UDate date, int32_t nonExistingTimeOpt, int32_t duplicatedTimeOpt, 1.165 + int32_t& rawOffset, int32_t& dstOffset, UErrorCode& status) const; 1.166 + 1.167 +protected: 1.168 + 1.169 +#ifndef U_HIDE_INTERNAL_API 1.170 + /** 1.171 + * The time type option bit masks used by getOffsetFromLocal 1.172 + * @internal 1.173 + */ 1.174 + enum { 1.175 + kStdDstMask = kDaylight, 1.176 + kFormerLatterMask = kLatter 1.177 + }; 1.178 +#endif /* U_HIDE_INTERNAL_API */ 1.179 + 1.180 + /** 1.181 + * Default constructor. 1.182 + * @stable ICU 3.8 1.183 + */ 1.184 + BasicTimeZone(); 1.185 + 1.186 + /** 1.187 + * Construct a timezone with a given ID. 1.188 + * @param id a system time zone ID 1.189 + * @stable ICU 3.8 1.190 + */ 1.191 + BasicTimeZone(const UnicodeString &id); 1.192 + 1.193 + /** 1.194 + * Copy constructor. 1.195 + * @param source the object to be copied. 1.196 + * @stable ICU 3.8 1.197 + */ 1.198 + BasicTimeZone(const BasicTimeZone& source); 1.199 + 1.200 + /** 1.201 + * Gets the set of TimeZoneRule instances applicable to the specified time and after. 1.202 + * @param start The start date used for extracting time zone rules 1.203 + * @param initial Receives the InitialTimeZone, always not NULL 1.204 + * @param transitionRules Receives the transition rules, could be NULL 1.205 + * @param status Receives error status code 1.206 + */ 1.207 + void getTimeZoneRulesAfter(UDate start, InitialTimeZoneRule*& initial, UVector*& transitionRules, 1.208 + UErrorCode& status) const; 1.209 +}; 1.210 + 1.211 +U_NAMESPACE_END 1.212 + 1.213 +#endif /* #if !UCONFIG_NO_FORMATTING */ 1.214 + 1.215 +#endif // BASICTZ_H 1.216 + 1.217 +//eof