]>
git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/unicode/basictz.h
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 *******************************************************************************
5 * Copyright (C) 2007-2013, International Business Machines Corporation and
6 * others. All Rights Reserved.
7 *******************************************************************************
14 * \brief C++ API: ICU TimeZone base class
17 #include "unicode/utypes.h"
19 #if !UCONFIG_NO_FORMATTING
21 #include "unicode/timezone.h"
22 #include "unicode/tzrule.h"
23 #include "unicode/tztrans.h"
25 #if U_SHOW_CPLUSPLUS_API
28 // forward declarations
32 * <code>BasicTimeZone</code> is an abstract class extending <code>TimeZone</code>.
33 * This class provides some additional methods to access time zone transitions and rules.
34 * All ICU <code>TimeZone</code> concrete subclasses extend this class.
37 class U_I18N_API BasicTimeZone
: public TimeZone
{
43 virtual ~BasicTimeZone();
46 * Gets the first time zone transition after the base time.
47 * @param base The base time.
48 * @param inclusive Whether the base time is inclusive or not.
49 * @param result Receives the first transition after the base time.
50 * @return TRUE if the transition is found.
53 virtual UBool
getNextTransition(UDate base
, UBool inclusive
, TimeZoneTransition
& result
) const = 0;
56 * Gets the most recent time zone transition before the base time.
57 * @param base The base time.
58 * @param inclusive Whether the base time is inclusive or not.
59 * @param result Receives the most recent transition before the base time.
60 * @return TRUE if the transition is found.
63 virtual UBool
getPreviousTransition(UDate base
, UBool inclusive
, TimeZoneTransition
& result
) const = 0;
66 * Checks if the time zone has equivalent transitions in the time range.
67 * This method returns true when all of transition times, from/to standard
68 * offsets and DST savings used by this time zone match the other in the
70 * @param tz The <code>BasicTimeZone</code> object to be compared with.
71 * @param start The start time of the evaluated time range (inclusive)
72 * @param end The end time of the evaluated time range (inclusive)
73 * @param ignoreDstAmount
74 * When true, any transitions with only daylight saving amount
75 * changes will be ignored, except either of them is zero.
76 * For example, a transition from rawoffset 3:00/dstsavings 1:00
77 * to rawoffset 2:00/dstsavings 2:00 is excluded from the comparison,
78 * but a transtion from rawoffset 2:00/dstsavings 1:00 to
79 * rawoffset 3:00/dstsavings 0:00 is included.
80 * @param ec Output param to filled in with a success or an error.
81 * @return true if the other time zone has the equivalent transitions in the
85 virtual UBool
hasEquivalentTransitions(const BasicTimeZone
& tz
, UDate start
, UDate end
,
86 UBool ignoreDstAmount
, UErrorCode
& ec
) const;
89 * Returns the number of <code>TimeZoneRule</code>s which represents time transitions,
90 * for this time zone, that is, all <code>TimeZoneRule</code>s for this time zone except
91 * <code>InitialTimeZoneRule</code>. The return value range is 0 or any positive value.
92 * @param status Receives error status code.
93 * @return The number of <code>TimeZoneRule</code>s representing time transitions.
96 virtual int32_t countTransitionRules(UErrorCode
& status
) const = 0;
99 * Gets the <code>InitialTimeZoneRule</code> and the set of <code>TimeZoneRule</code>
100 * which represent time transitions for this time zone. On successful return,
101 * the argument initial points to non-NULL <code>InitialTimeZoneRule</code> and
102 * the array trsrules is filled with 0 or multiple <code>TimeZoneRule</code>
103 * instances up to the size specified by trscount. The results are referencing the
104 * rule instance held by this time zone instance. Therefore, after this time zone
105 * is destructed, they are no longer available.
106 * @param initial Receives the initial timezone rule
107 * @param trsrules Receives the timezone transition rules
108 * @param trscount On input, specify the size of the array 'transitions' receiving
109 * the timezone transition rules. On output, actual number of
110 * rules filled in the array will be set.
111 * @param status Receives error status code.
114 virtual void getTimeZoneRules(const InitialTimeZoneRule
*& initial
,
115 const TimeZoneRule
* trsrules
[], int32_t& trscount
, UErrorCode
& status
) const = 0;
118 * Gets the set of time zone rules valid at the specified time. Some known external time zone
119 * implementations are not capable to handle historic time zone rule changes. Also some
120 * implementations can only handle certain type of rule definitions.
121 * If this time zone does not use any daylight saving time within about 1 year from the specified
122 * time, only the <code>InitialTimeZone</code> is returned. Otherwise, the rule for standard
123 * time and daylight saving time transitions are returned in addition to the
124 * <code>InitialTimeZoneRule</code>. The standard and daylight saving time transition rules are
125 * represented by <code>AnnualTimeZoneRule</code> with <code>DateTimeRule::DOW</code> for its date
126 * rule and <code>DateTimeRule::WALL_TIME</code> for its time rule. Because daylight saving time
127 * rule is changing time to time in many time zones and also mapping a transition time rule to
128 * different type is lossy transformation, the set of rules returned by this method may be valid
129 * for short period of time.
130 * The time zone rule objects returned by this method is owned by the caller, so the caller is
131 * responsible for deleting them after use.
132 * @param date The date used for extracting time zone rules.
133 * @param initial Receives the <code>InitialTimeZone</code>, always not NULL.
134 * @param std Receives the <code>AnnualTimeZoneRule</code> for standard time transitions.
135 * When this time time zone does not observe daylight saving times around the
136 * specified date, NULL is set.
137 * @param dst Receives the <code>AnnualTimeZoneRule</code> for daylight saving time
138 * transitions. When this time zone does not observer daylight saving times
139 * around the specified date, NULL is set.
140 * @param status Receives error status code.
143 virtual void getSimpleRulesNear(UDate date
, InitialTimeZoneRule
*& initial
,
144 AnnualTimeZoneRule
*& std
, AnnualTimeZoneRule
*& dst
, UErrorCode
& status
) const;
147 #ifndef U_HIDE_INTERNAL_API
149 * The time type option bit flags used by getOffsetFromLocal
158 #endif /* U_HIDE_INTERNAL_API */
161 * Get time zone offsets from local wall time.
164 virtual void getOffsetFromLocal(UDate date
, int32_t nonExistingTimeOpt
, int32_t duplicatedTimeOpt
,
165 int32_t& rawOffset
, int32_t& dstOffset
, UErrorCode
& status
) const;
169 #ifndef U_HIDE_INTERNAL_API
171 * The time type option bit masks used by getOffsetFromLocal
175 kStdDstMask
= kDaylight
,
176 kFormerLatterMask
= kLatter
178 #endif /* U_HIDE_INTERNAL_API */
181 * Default constructor.
187 * Construct a timezone with a given ID.
188 * @param id a system time zone ID
191 BasicTimeZone(const UnicodeString
&id
);
195 * @param source the object to be copied.
198 BasicTimeZone(const BasicTimeZone
& source
);
201 * Gets the set of TimeZoneRule instances applicable to the specified time and after.
202 * @param start The start date used for extracting time zone rules
203 * @param initial Receives the InitialTimeZone, always not NULL
204 * @param transitionRules Receives the transition rules, could be NULL
205 * @param status Receives error status code
207 void getTimeZoneRulesAfter(UDate start
, InitialTimeZoneRule
*& initial
, UVector
*& transitionRules
,
208 UErrorCode
& status
) const;
212 #endif // U_SHOW_CPLUSPLUS_API
214 #endif /* #if !UCONFIG_NO_FORMATTING */