1 vtzrules.h |
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __VTZRULES_H__ |
|
17 #define __VTZRULES_H__ |
|
18 |
|
19 #include <e32base.h> |
|
20 #include <s32strm.h> |
|
21 #include <tzdefines.h> |
|
22 #include <tz.h> |
|
23 |
|
24 class CVTzActualisedRules; |
|
25 class TVTzActualisedRule; |
|
26 |
|
27 const TInt KVTzRulesGranularity = 4; |
|
28 |
|
29 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
|
30 * Time zone rules |
|
31 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
|
32 |
|
33 /** |
|
34 Encapsulates one time zone rule. |
|
35 |
|
36 @publishedAll |
|
37 @released |
|
38 */ |
|
39 class TTzRule |
|
40 { |
|
41 public: |
|
42 IMPORT_C TTzRule(TInt16 aFromYear, TInt16 aToYear, TInt16 aOldOffset, TInt16 aNewOffset, TMonth aMonth, TTzRuleDay aDayRule, |
|
43 TUint8 aDayOfMonth, TUint8 aDayOfWeek, TTzTimeReference aTimeReference, TUint16 aTimeOfChange); |
|
44 IMPORT_C TTzRule(); |
|
45 IMPORT_C TTzRule(const TTzRule& aRule); |
|
46 IMPORT_C TTzRule(TTimeWithReference aFromYear, TTimeWithReference aToYear, TInt16 aOldOffset, TInt16 aNewOffset, TMonth aMonth, TTzRuleDay aDayRule, |
|
47 TUint8 aDayOfMonth, TUint8 aDayOfWeek, TTzTimeReference aTimeReference, TUint16 aTimeOfChange); |
|
48 |
|
49 |
|
50 void ExternalizeL(RWriteStream& aStream) const; |
|
51 void InternalizeL(RReadStream& aStream); |
|
52 TBool RuleApplies(const TTime& aStart, const TTime& aEnd) const; |
|
53 |
|
54 IMPORT_C TVTzActualisedRule Actualise(TInt aYear) const; // deprecated, replace by the L version |
|
55 IMPORT_C TVTzActualisedRule ActualiseL(TInt aYear) const; |
|
56 |
|
57 public: |
|
58 TTimeWithReference iFrom; // first date the rule applies |
|
59 TTimeWithReference iTo; // last date the rule applies |
|
60 TInt16 iOldLocalTimeOffset; // local time offset (in minutes) BEFORE the change (local time = UTC + DST) |
|
61 TInt16 iNewLocalTimeOffset; // local time offset (in minutes) AFTER the change |
|
62 TMonth iMonth; |
|
63 TTzRuleDay iDayRule; // format in which the rule is expressed |
|
64 TUint8 iDayOfMonth; |
|
65 TUint8 iDayOfWeek; |
|
66 TTzTimeReference iTimeReference; |
|
67 TUint16 iTimeOfChange; // number of minutes since midnight |
|
68 TUint32 iReserved; |
|
69 }; |
|
70 |
|
71 |
|
72 |
|
73 /** |
|
74 Encapsulates a collection of time zone rules, and includes the period covered by the rules |
|
75 and the standard time offset at the start of that period. |
|
76 |
|
77 @publishedAll |
|
78 @released |
|
79 */ |
|
80 class CTzRules : public CBase |
|
81 { |
|
82 public: |
|
83 IMPORT_C static CTzRules* NewL(); |
|
84 IMPORT_C static CTzRules* NewL(TInt aStartYear, TInt aEndYear); |
|
85 IMPORT_C static CTzRules* NewL(RReadStream& aStream); |
|
86 IMPORT_C ~CTzRules(); |
|
87 IMPORT_C TBool RulesApply(const TTime& aTime) const; |
|
88 IMPORT_C void AddRuleL(TTzRule aRule); |
|
89 IMPORT_C void RemoveRule(TInt aIndex); |
|
90 IMPORT_C TTzRule& operator[](TInt aIndex); |
|
91 IMPORT_C TInt Count() const; |
|
92 IMPORT_C TInt StartYear() const; |
|
93 IMPORT_C TInt EndYear() const; |
|
94 IMPORT_C void SetStartYear(TInt aYear); |
|
95 IMPORT_C void SetEndYear(TInt aYear); |
|
96 IMPORT_C void ExternalizeL(RWriteStream& aStream) const; |
|
97 IMPORT_C void InternalizeL(RReadStream& aStream); |
|
98 IMPORT_C TInt InitialStdTimeOffset() const; |
|
99 IMPORT_C void SetInitialStdTimeOffset(TInt aOffset); |
|
100 IMPORT_C void ConvertToUtcL(TTime& aLocalTime) const; |
|
101 IMPORT_C void ConvertToLocalL(TTime& aUtcTime) const; |
|
102 IMPORT_C CTzRules* CloneL() const; |
|
103 IMPORT_C TBool IsEqualTo(const CTzRules& aRules) const; |
|
104 |
|
105 IMPORT_C void GetActualisedRulesL(CVTzActualisedRules& aActRules) const; |
|
106 IMPORT_C TInt ConvertTime(CVTzActualisedRules& aRules, TTime& aTime, TTzTimeReference aTimerRef) const; |
|
107 |
|
108 private: |
|
109 CTzRules(); |
|
110 CTzRules(TInt aStartYear, TInt aEndYear); |
|
111 void GetActualisedRulesL(CVTzActualisedRules& aActRules, TInt aYear) const; |
|
112 TInt GetOffsetL(const TTime& aTime, TTzTimeReference aTimeRef) const; |
|
113 TInt AddActualisedRulesL(CVTzActualisedRules& aActRules, TInt aYear) const; |
|
114 TInt CompareTimesWithRef(TTime aTimeA, TTzTimeReference aTimeARef, |
|
115 TTime aTimeB, TTzTimeReference aTimeBRef, TInt aStdOffset, TInt aWallOffset, |
|
116 TTimeIntervalMinutes* aMinutesDifference) const; |
|
117 |
|
118 private: |
|
119 TInt16 iStartYear; |
|
120 TInt16 iEndYear; |
|
121 RArray<TTzRule> iRules; |
|
122 TInt iInitialStdTimeOffset; |
|
123 }; |
|
124 |
|
125 |
|
126 |
|
127 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
|
128 * Actualised time zone rules |
|
129 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
|
130 |
|
131 /** |
|
132 Encapsulates a local time change. |
|
133 |
|
134 @publishedAll |
|
135 @released |
|
136 */ |
|
137 class TVTzActualisedRule |
|
138 { |
|
139 public: |
|
140 IMPORT_C TVTzActualisedRule(TTime aTimeOfChange, TInt aNewOffset, TTzTimeReference aTimeReference); |
|
141 IMPORT_C TVTzActualisedRule(); |
|
142 |
|
143 IMPORT_C void operator=(TVTzActualisedRule aRule); |
|
144 static TInt Order(const TVTzActualisedRule& aLeft, const TVTzActualisedRule& aRight); |
|
145 |
|
146 public: |
|
147 TTime iTimeOfChange; |
|
148 TInt32 iNewOffset; |
|
149 TTzTimeReference iTimeReference; |
|
150 }; |
|
151 |
|
152 |
|
153 /** |
|
154 Encapsulates a collection of the local time changes occurring during a range of years. |
|
155 |
|
156 @publishedAll |
|
157 @released |
|
158 */ |
|
159 NONSHARABLE_CLASS(CVTzActualisedRules) : public CBase |
|
160 { |
|
161 public: |
|
162 IMPORT_C static CVTzActualisedRules* NewL(TInt aStartYear, TInt aEndYear); |
|
163 IMPORT_C ~CVTzActualisedRules(); |
|
164 IMPORT_C void AddRuleL(const TVTzActualisedRule& aRule); |
|
165 IMPORT_C TInt Count() const; |
|
166 IMPORT_C TVTzActualisedRule& operator[](TInt aIndex) const; |
|
167 |
|
168 IMPORT_C TInt StartYear() const; |
|
169 IMPORT_C TInt EndYear() const; |
|
170 |
|
171 IMPORT_C TBool IsDaylightSavingOn(TTime& aTime) const; |
|
172 IMPORT_C TInt GetOffsetFromRuleL(const TTime& aTime, TTzTimeReference aTimeRef) const; |
|
173 |
|
174 private: |
|
175 CVTzActualisedRules(TInt aStartYear, TInt aEndYear); |
|
176 CVTzActualisedRules(); |
|
177 TInt CompareTimesWithRef(TTime aRolloverTime, TTzTimeReference aTimeRefRollover, |
|
178 TTime aUserTime, TTzTimeReference aTimeRefUser, |
|
179 TInt aOldWallOffset, TTimeIntervalMinutes& aDiffMinutes) const; |
|
180 |
|
181 private: |
|
182 TInt32 iStartYear; // years covered by |
|
183 TInt32 iEndYear; // the actualised rules |
|
184 RArray<TVTzActualisedRule> iRules; |
|
185 }; |
|
186 |
|
187 #endif |