2
*******************************************************************************
3
* Copyright (C) 2007-2008, International Business Machines Corporation and *
4
* others. All Rights Reserved. *
5
*******************************************************************************
12
* \brief C++ API: ICU TimeZone base class
15
#include "unicode/utypes.h"
17
#if !UCONFIG_NO_FORMATTING
19
#include "unicode/timezone.h"
20
#include "unicode/tzrule.h"
21
#include "unicode/tztrans.h"
25
// forward declarations
29
* <code>BasicTimeZone</code> is an abstract class extending <code>TimeZone</code>.
30
* This class provides some additional methods to access time zone transitions and rules.
31
* All ICU <code>TimeZone</code> concrete subclasses extend this class.
34
class U_I18N_API BasicTimeZone: public TimeZone {
40
virtual ~BasicTimeZone();
43
* Gets the first time zone transition after the base time.
44
* @param base The base time.
45
* @param inclusive Whether the base time is inclusive or not.
46
* @param result Receives the first transition after the base time.
47
* @return TRUE if the transition is found.
50
virtual UBool getNextTransition(UDate base, UBool inclusive, TimeZoneTransition& result) /*const*/ = 0;
53
* Gets the most recent time zone transition before the base time.
54
* @param base The base time.
55
* @param inclusive Whether the base time is inclusive or not.
56
* @param result Receives the most recent transition before the base time.
57
* @return TRUE if the transition is found.
60
virtual UBool getPreviousTransition(UDate base, UBool inclusive, TimeZoneTransition& result) /*const*/ = 0;
63
* Checks if the time zone has equivalent transitions in the time range.
64
* This method returns true when all of transition times, from/to standard
65
* offsets and DST savings used by this time zone match the other in the
67
* @param tz The <code>BasicTimeZone</code> object to be compared with.
68
* @param start The start time of the evaluated time range (inclusive)
69
* @param end The end time of the evaluated time range (inclusive)
70
* @param ignoreDstAmount
71
* When true, any transitions with only daylight saving amount
72
* changes will be ignored, except either of them is zero.
73
* For example, a transition from rawoffset 3:00/dstsavings 1:00
74
* to rawoffset 2:00/dstsavings 2:00 is excluded from the comparison,
75
* but a transtion from rawoffset 2:00/dstsavings 1:00 to
76
* rawoffset 3:00/dstsavings 0:00 is included.
77
* @param ec Output param to filled in with a success or an error.
78
* @return true if the other time zone has the equivalent transitions in the
82
virtual UBool hasEquivalentTransitions(/*const*/ BasicTimeZone& tz, UDate start, UDate end,
83
UBool ignoreDstAmount, UErrorCode& ec) /*const*/;
86
* Returns the number of <code>TimeZoneRule</code>s which represents time transitions,
87
* for this time zone, that is, all <code>TimeZoneRule</code>s for this time zone except
88
* <code>InitialTimeZoneRule</code>. The return value range is 0 or any positive value.
89
* @param status Receives error status code.
90
* @return The number of <code>TimeZoneRule</code>s representing time transitions.
93
virtual int32_t countTransitionRules(UErrorCode& status) /*const*/ = 0;
96
* Gets the <code>InitialTimeZoneRule</code> and the set of <code>TimeZoneRule</code>
97
* which represent time transitions for this time zone. On successful return,
98
* the argument initial points to non-NULL <code>InitialTimeZoneRule</code> and
99
* the array trsrules is filled with 0 or multiple <code>TimeZoneRule</code>
100
* instances up to the size specified by trscount. The results are referencing the
101
* rule instance held by this time zone instance. Therefore, after this time zone
102
* is destructed, they are no longer available.
103
* @param initial Receives the initial timezone rule
104
* @param trsrules Receives the timezone transition rules
105
* @param trscount On input, specify the size of the array 'transitions' receiving
106
* the timezone transition rules. On output, actual number of
107
* rules filled in the array will be set.
108
* @param status Receives error status code.
111
virtual void getTimeZoneRules(const InitialTimeZoneRule*& initial,
112
const TimeZoneRule* trsrules[], int32_t& trscount, UErrorCode& status) /*const*/ = 0;
115
* Gets the set of time zone rules valid at the specified time. Some known external time zone
116
* implementations are not capable to handle historic time zone rule changes. Also some
117
* implementations can only handle certain type of rule definitions.
118
* If this time zone does not use any daylight saving time within about 1 year from the specified
119
* time, only the <code>InitialTimeZone</code> is returned. Otherwise, the rule for standard
120
* time and daylight saving time transitions are returned in addition to the
121
* <code>InitialTimeZoneRule</code>. The standard and daylight saving time transition rules are
122
* represented by <code>AnnualTimeZoneRule</code> with <code>DateTimeRule::DOW</code> for its date
123
* rule and <code>DateTimeRule::WALL_TIME</code> for its time rule. Because daylight saving time
124
* rule is changing time to time in many time zones and also mapping a transition time rule to
125
* different type is lossy transformation, the set of rules returned by this method may be valid
126
* for short period of time.
127
* The time zone rule objects returned by this method is owned by the caller, so the caller is
128
* responsible for deleting them after use.
129
* @param date The date used for extracting time zone rules.
130
* @param initial Receives the <code>InitialTimeZone</code>, always not NULL.
131
* @param std Receives the <code>AnnualTimeZoneRule</code> for standard time transitions.
132
* When this time time zone does not observe daylight saving times around the
133
* specified date, NULL is set.
134
* @param dst Receives the <code>AnnualTimeZoneRule</code> for daylight saving time
135
* transitions. When this time zone does not observer daylight saving times
136
* around the specified date, NULL is set.
137
* @param status Receives error status code.
140
virtual void getSimpleRulesNear(UDate date, InitialTimeZoneRule*& initial,
141
AnnualTimeZoneRule*& std, AnnualTimeZoneRule*& dst, UErrorCode& status) /*const*/;
145
* The time type option bit flags used by getOffsetFromLocal
156
* Get time zone offsets from local wall time.
159
virtual void getOffsetFromLocal(UDate date, int32_t nonExistingTimeOpt, int32_t duplicatedTimeOpt,
160
int32_t& rawOffset, int32_t& dstOffset, UErrorCode& status) /*const*/;
165
* The time type option bit masks used by getOffsetFromLocal
169
kStdDstMask = kDaylight,
170
kFormerLatterMask = kLatter
174
* Default constructor.
180
* Construct a timezone with a given ID.
181
* @param id a system time zone ID
184
BasicTimeZone(const UnicodeString &id);
188
* @param source the object to be copied.
191
BasicTimeZone(const BasicTimeZone& source);
194
* Gets the set of TimeZoneRule instances applicable to the specified time and after.
195
* @param start The start date used for extracting time zone rules
196
* @param initial Receives the InitialTimeZone, always not NULL
197
* @param transitionRules Receives the transition rules, could be NULL
198
* @param status Receives error status code
200
void getTimeZoneRulesAfter(UDate start, InitialTimeZoneRule*& initial, UVector*& transitionRules,
201
UErrorCode& status) /*const*/;
206
#endif /* #if !UCONFIG_NO_FORMATTING */