sl@0: // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Defines TTsTime class, to represent UTC and Local Time for use within Task Scheduler sl@0: // sl@0: // sl@0: sl@0: sl@0: #ifndef __SCHTIME_H__ sl@0: #define __SCHTIME_H__ sl@0: sl@0: // System includes sl@0: #include sl@0: sl@0: //Forward declarations sl@0: class RWriteStream; sl@0: class RReadStream; sl@0: sl@0: /** sl@0: In Task Scheduler TTsTime is used to represent time as either UTC or Local Time. sl@0: It is used by many of the Task Scheduler API's and also used internally within Task Scheduler. sl@0: This class is not expected to be stored by Task Scheduler clients. sl@0: sl@0: It provides EXPORTed APIs for constructing, setting and getting UTC and Local Time. sl@0: sl@0: Internally the object always holds time as UTC (using the data member iUTC) irrespective of sl@0: whether the object is local time based or UTC based. sl@0: sl@0: If the object is local time based iOffset will be set to the system TimeZone/DST offset. sl@0: When UTC based iOffset will always be 0. sl@0: sl@0: Therefore: sl@0: sl@0: When representing UTC: sl@0: iUTC contains the UTC time sl@0: iOffSet is set to 0 sl@0: iFlags, bit 0 is set to 1 sl@0: sl@0: When representing Local Time: sl@0: iUTC contains the home time minus the TimeZone/DST offset sl@0: iOffSet contains the TimeZone/DST offset sl@0: iFlags, bit 0 is set to 0 sl@0: sl@0: If an instance of this class is created using the default constructor then: sl@0: iUTC is set to 0 sl@0: iOffSet is set to 0 sl@0: iFlags, bit 0 is set to 1 (indicating UTC time) sl@0: sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class TTsTime sl@0: { sl@0: public: sl@0: sl@0: IMPORT_C TTsTime(); sl@0: sl@0: IMPORT_C TTsTime(const TTime& aTime, TBool aIsUtc); sl@0: sl@0: IMPORT_C void SetLocalTime(const TTime& aLocalTime); sl@0: sl@0: IMPORT_C const TTime GetLocalTime(); sl@0: sl@0: IMPORT_C TTime GetLocalTime() const; sl@0: sl@0: IMPORT_C void SetUtcTime(const TTime& aUtcTime); sl@0: sl@0: IMPORT_C const TTime& GetUtcTime(); sl@0: sl@0: IMPORT_C const TTime& GetUtcTime() const; sl@0: sl@0: IMPORT_C TBool IsUtc() const; sl@0: sl@0: IMPORT_C TTsTime& operator=(const TTsTime& aTsTime); sl@0: sl@0: IMPORT_C TTsTime(const TTsTime& aTTsTime); sl@0: sl@0: public: sl@0: // APIs for use within the Task Scheduler server sl@0: sl@0: void ExternalizeL(RWriteStream& aStream) const; sl@0: sl@0: void InternalizeL(RReadStream& aStream); sl@0: sl@0: void ProcessOffsetEvent(); sl@0: sl@0: inline TTimeIntervalSeconds GetOffset(); sl@0: sl@0: sl@0: sl@0: private: sl@0: sl@0: TTime DetermineLocalTime() const; sl@0: sl@0: /** sl@0: This object always stores time as UTC irrespective of whether the object is home time or UTC based. sl@0: */ sl@0: TTime iUtcTime; sl@0: sl@0: /** sl@0: If the object is UTC based then this will always be 0. If home time based then this will contain the value sl@0: of system TimeZone/DST offset at the time that the object was created or last updated. sl@0: */ sl@0: TTimeIntervalSeconds iOffset; sl@0: sl@0: /** sl@0: 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: */ sl@0: TUint32 iFlags; sl@0: sl@0: }; sl@0: sl@0: /** sl@0: This method must only be used by Task Scheduler itself as it returns raw offset data sl@0: that can become out of date if system Timezone/DST changes occur. sl@0: @internalComponent sl@0: */ sl@0: // Not for Client Use , Only to be used Internally. sl@0: inline TTimeIntervalSeconds TTsTime::GetOffset() sl@0: { sl@0: return iOffset; sl@0: } sl@0: sl@0: #endif