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@4
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
williamr@2
|
5 |
// which accompanies this distribution, and is available
|
williamr@4
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.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 |
// Defines TTsTime class, to represent UTC and Local Time for use within Task Scheduler
|
williamr@2
|
15 |
//
|
williamr@2
|
16 |
//
|
williamr@2
|
17 |
|
williamr@2
|
18 |
|
williamr@2
|
19 |
#ifndef __SCHTIME_H__
|
williamr@2
|
20 |
#define __SCHTIME_H__
|
williamr@2
|
21 |
|
williamr@2
|
22 |
// System includes
|
williamr@2
|
23 |
#include <e32std.h>
|
williamr@2
|
24 |
|
williamr@2
|
25 |
//Forward declarations
|
williamr@2
|
26 |
class RWriteStream;
|
williamr@2
|
27 |
class RReadStream;
|
williamr@2
|
28 |
|
williamr@2
|
29 |
/**
|
williamr@2
|
30 |
In Task Scheduler TTsTime is used to represent time as either UTC or Local Time.
|
williamr@2
|
31 |
It is used by many of the Task Scheduler API's and also used internally within Task Scheduler.
|
williamr@2
|
32 |
This class is not expected to be stored by Task Scheduler clients.
|
williamr@2
|
33 |
|
williamr@2
|
34 |
It provides EXPORTed APIs for constructing, setting and getting UTC and Local Time.
|
williamr@2
|
35 |
|
williamr@2
|
36 |
Internally the object always holds time as UTC (using the data member iUTC) irrespective of
|
williamr@2
|
37 |
whether the object is local time based or UTC based.
|
williamr@2
|
38 |
|
williamr@2
|
39 |
If the object is local time based iOffset will be set to the system TimeZone/DST offset.
|
williamr@2
|
40 |
When UTC based iOffset will always be 0.
|
williamr@2
|
41 |
|
williamr@2
|
42 |
Therefore:
|
williamr@2
|
43 |
|
williamr@2
|
44 |
When representing UTC:
|
williamr@2
|
45 |
iUTC contains the UTC time
|
williamr@2
|
46 |
iOffSet is set to 0
|
williamr@2
|
47 |
iFlags, bit 0 is set to 1
|
williamr@2
|
48 |
|
williamr@2
|
49 |
When representing Local Time:
|
williamr@2
|
50 |
iUTC contains the home time minus the TimeZone/DST offset
|
williamr@2
|
51 |
iOffSet contains the TimeZone/DST offset
|
williamr@2
|
52 |
iFlags, bit 0 is set to 0
|
williamr@2
|
53 |
|
williamr@2
|
54 |
If an instance of this class is created using the default constructor then:
|
williamr@2
|
55 |
iUTC is set to 0
|
williamr@2
|
56 |
iOffSet is set to 0
|
williamr@2
|
57 |
iFlags, bit 0 is set to 1 (indicating UTC time)
|
williamr@2
|
58 |
|
williamr@2
|
59 |
@publishedAll
|
williamr@2
|
60 |
@released
|
williamr@2
|
61 |
*/
|
williamr@2
|
62 |
class TTsTime
|
williamr@2
|
63 |
{
|
williamr@2
|
64 |
public:
|
williamr@2
|
65 |
|
williamr@2
|
66 |
IMPORT_C TTsTime();
|
williamr@2
|
67 |
|
williamr@2
|
68 |
IMPORT_C TTsTime(const TTime& aTime, TBool aIsUtc);
|
williamr@2
|
69 |
|
williamr@2
|
70 |
IMPORT_C void SetLocalTime(const TTime& aLocalTime);
|
williamr@2
|
71 |
|
williamr@2
|
72 |
IMPORT_C const TTime GetLocalTime();
|
williamr@2
|
73 |
|
williamr@2
|
74 |
IMPORT_C TTime GetLocalTime() const;
|
williamr@2
|
75 |
|
williamr@2
|
76 |
IMPORT_C void SetUtcTime(const TTime& aUtcTime);
|
williamr@2
|
77 |
|
williamr@2
|
78 |
IMPORT_C const TTime& GetUtcTime();
|
williamr@2
|
79 |
|
williamr@2
|
80 |
IMPORT_C const TTime& GetUtcTime() const;
|
williamr@2
|
81 |
|
williamr@2
|
82 |
IMPORT_C TBool IsUtc() const;
|
williamr@2
|
83 |
|
williamr@2
|
84 |
IMPORT_C TTsTime& operator=(const TTsTime& aTsTime);
|
williamr@2
|
85 |
|
williamr@2
|
86 |
IMPORT_C TTsTime(const TTsTime& aTTsTime);
|
williamr@2
|
87 |
|
williamr@2
|
88 |
public:
|
williamr@2
|
89 |
// APIs for use within the Task Scheduler server
|
williamr@2
|
90 |
|
williamr@2
|
91 |
void ExternalizeL(RWriteStream& aStream) const;
|
williamr@2
|
92 |
|
williamr@2
|
93 |
void InternalizeL(RReadStream& aStream);
|
williamr@2
|
94 |
|
williamr@2
|
95 |
void ProcessOffsetEvent();
|
williamr@2
|
96 |
|
williamr@2
|
97 |
inline TTimeIntervalSeconds GetOffset();
|
williamr@2
|
98 |
|
williamr@2
|
99 |
|
williamr@2
|
100 |
|
williamr@2
|
101 |
private:
|
williamr@2
|
102 |
|
williamr@2
|
103 |
TTime DetermineLocalTime() const;
|
williamr@2
|
104 |
|
williamr@2
|
105 |
/**
|
williamr@2
|
106 |
This object always stores time as UTC irrespective of whether the object is home time or UTC based.
|
williamr@2
|
107 |
*/
|
williamr@2
|
108 |
TTime iUtcTime;
|
williamr@2
|
109 |
|
williamr@2
|
110 |
/**
|
williamr@2
|
111 |
If the object is UTC based then this will always be 0. If home time based then this will contain the value
|
williamr@2
|
112 |
of system TimeZone/DST offset at the time that the object was created or last updated.
|
williamr@2
|
113 |
*/
|
williamr@2
|
114 |
TTimeIntervalSeconds iOffset;
|
williamr@2
|
115 |
|
williamr@2
|
116 |
/**
|
williamr@2
|
117 |
Bit 0 is set to 0 when UTC based, Bit 0 is set to 1 when home time based, Bit1-Bit31 are reserved for future use.
|
williamr@2
|
118 |
*/
|
williamr@2
|
119 |
TUint32 iFlags;
|
williamr@2
|
120 |
|
williamr@2
|
121 |
};
|
williamr@2
|
122 |
|
williamr@2
|
123 |
/**
|
williamr@2
|
124 |
This method must only be used by Task Scheduler itself as it returns raw offset data
|
williamr@2
|
125 |
that can become out of date if system Timezone/DST changes occur.
|
williamr@2
|
126 |
@internalComponent
|
williamr@2
|
127 |
*/
|
williamr@4
|
128 |
// Not for Client Use , Only to be used Internally.
|
williamr@2
|
129 |
inline TTimeIntervalSeconds TTsTime::GetOffset()
|
williamr@2
|
130 |
{
|
williamr@2
|
131 |
return iOffset;
|
williamr@2
|
132 |
}
|
williamr@2
|
133 |
|
williamr@2
|
134 |
#endif
|