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