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