epoc32/include/schtime.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
     1.1 --- a/epoc32/include/schtime.h	Tue Nov 24 13:55:44 2009 +0000
     1.2 +++ b/epoc32/include/schtime.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -1,1 +1,133 @@
     1.4 -schtime.h
     1.5 +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +// All rights reserved.
     1.7 +// This component and the accompanying materials are made available
     1.8 +// 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
     1.9 +// which accompanies this distribution, and is available
    1.10 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.11 +//
    1.12 +// Initial Contributors:
    1.13 +// Nokia Corporation - initial contribution.
    1.14 +//
    1.15 +// Contributors:
    1.16 +//
    1.17 +// Description:
    1.18 +// Defines TTsTime class, to represent UTC and  Local Time for use within Task Scheduler
    1.19 +// 
    1.20 +//
    1.21 +
    1.22 +
    1.23 +#ifndef __SCHTIME_H__
    1.24 +#define __SCHTIME_H__
    1.25 +
    1.26 +// System includes
    1.27 +#include <e32std.h>
    1.28 +
    1.29 +//Forward declarations
    1.30 +class RWriteStream;
    1.31 +class RReadStream;
    1.32 +
    1.33 +/**
    1.34 +In Task Scheduler TTsTime is used to represent time as either UTC or Local Time.
    1.35 +It is used by many of the Task Scheduler API's and also used internally within Task Scheduler.
    1.36 +This class is not expected to be stored by Task Scheduler clients.
    1.37 +
    1.38 +It provides EXPORTed APIs for constructing, setting and getting UTC and Local Time.
    1.39 +
    1.40 +Internally the object always holds time as UTC (using the data member iUTC) irrespective of 
    1.41 +whether the object is local time based or UTC based. 
    1.42 +
    1.43 +If the object is local time based iOffset will be set to the system TimeZone/DST offset.
    1.44 +When UTC based iOffset will always be 0. 
    1.45 +
    1.46 +Therefore:
    1.47 +
    1.48 +When representing UTC:
    1.49 +	iUTC contains the UTC time
    1.50 +	iOffSet is set to 0
    1.51 +	iFlags, bit 0 is set to 1
    1.52 +
    1.53 +When representing Local Time:
    1.54 +	iUTC contains the home time minus the TimeZone/DST offset
    1.55 +	iOffSet contains the TimeZone/DST offset 
    1.56 +	iFlags, bit 0 is set to 0
    1.57 +
    1.58 +If an instance of this class is created using the default constructor then:
    1.59 +	iUTC is set to 0
    1.60 +	iOffSet is set to 0 
    1.61 +	iFlags, bit 0 is set to 1 (indicating UTC time)
    1.62 +
    1.63 +@publishedAll
    1.64 +@released
    1.65 +*/
    1.66 +class TTsTime
    1.67 +	{
    1.68 +public:
    1.69 +	
    1.70 +	IMPORT_C TTsTime();
    1.71 +	
    1.72 +	IMPORT_C TTsTime(const TTime& aTime, TBool aIsUtc);
    1.73 +	
    1.74 +	IMPORT_C void SetLocalTime(const TTime& aLocalTime);
    1.75 +	
    1.76 +	IMPORT_C const TTime GetLocalTime(); 
    1.77 +
    1.78 +	IMPORT_C TTime GetLocalTime() const; 
    1.79 +
    1.80 +	IMPORT_C void SetUtcTime(const TTime& aUtcTime);
    1.81 +	
    1.82 +	IMPORT_C const TTime& GetUtcTime(); 
    1.83 +
    1.84 +	IMPORT_C const TTime& GetUtcTime() const;
    1.85 +	
    1.86 +	IMPORT_C TBool IsUtc() const;
    1.87 +	
    1.88 +	IMPORT_C TTsTime& operator=(const TTsTime& aTsTime);
    1.89 +	
    1.90 +	IMPORT_C TTsTime(const TTsTime& aTTsTime);
    1.91 + 	
    1.92 +public:
    1.93 +	// APIs for use within the Task Scheduler server
    1.94 +
    1.95 +	void ExternalizeL(RWriteStream& aStream) const;
    1.96 +	
    1.97 +	void InternalizeL(RReadStream& aStream);
    1.98 +	
    1.99 +	void ProcessOffsetEvent();
   1.100 +
   1.101 +	inline TTimeIntervalSeconds GetOffset();
   1.102 +	
   1.103 +			
   1.104 +
   1.105 +private:
   1.106 +
   1.107 +	TTime DetermineLocalTime() const;
   1.108 +
   1.109 +	/**
   1.110 +	This object always stores time as UTC irrespective of whether the object is home time or UTC based.
   1.111 +	*/
   1.112 +	TTime iUtcTime;
   1.113 +	
   1.114 +	/**
   1.115 +	If the object is UTC based then this will always be 0. 	If home time based then this will contain the value
   1.116 +	of system TimeZone/DST offset at the time that the object was created or last updated.
   1.117 +	*/
   1.118 +	TTimeIntervalSeconds iOffset;
   1.119 +	
   1.120 +	/**
   1.121 +	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.
   1.122 +	*/
   1.123 +	TUint32 iFlags;
   1.124 +
   1.125 +	};
   1.126 +	
   1.127 +/**
   1.128 +This method must only be used by Task Scheduler itself as it returns raw offset data
   1.129 +that can become out of date if system Timezone/DST changes occur.
   1.130 +@internalComponent
   1.131 +*/
   1.132 +inline TTimeIntervalSeconds TTsTime::GetOffset()
   1.133 +	{
   1.134 +	return iOffset;
   1.135 +	}
   1.136 +
   1.137 +#endif