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