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