Symbian3/PDK/Source/GUID-91E0E87B-FECA-5D19-AD48-9DEFD42B86B3.dita
changeset 1 25a17d01db0c
child 3 46218c8b8afa
equal deleted inserted replaced
0:89d6a7a84779 1:25a17d01db0c
       
     1 <?xml version="1.0" encoding="utf-8"?>
       
     2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
       
     3 <!-- This component and the accompanying materials are made available under the terms of the License 
       
     4 "Eclipse Public License v1.0" which accompanies this distribution, 
       
     5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
       
     6 <!-- Initial Contributors:
       
     7     Nokia Corporation - initial contribution.
       
     8 Contributors: 
       
     9 -->
       
    10 <!DOCTYPE concept
       
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
       
    12 <concept id="GUID-91E0E87B-FECA-5D19-AD48-9DEFD42B86B3" xml:lang="en"><title>How
       
    13 to implement universal time and home time</title><shortdesc>Add universal time offset to display the home time.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    14 <p>These code fragments demonstrate the various components which make up the
       
    15 time, including:</p>
       
    16 <ul>
       
    17 <li id="GUID-1224C41A-1736-528E-B782-16E8AF29B9D8"><p>the <keyword>universal
       
    18 time</keyword> </p> </li>
       
    19 <li id="GUID-790CEB46-8B7E-5B98-A9AF-00CAF254BA38"><p>the <keyword>universal
       
    20 time offset</keyword> </p> </li>
       
    21 </ul>
       
    22 <section id="GUID-70976CCC-3A00-4BAE-B6D8-1DD1CC621D9D"><title>Home time</title> <p>In the following example code fragment,
       
    23 the universal time offset is added to the universal time, giving the <keyword>home
       
    24 time</keyword>. The <keyword>universal time offset</keyword> is determined
       
    25 by the time zone, and by whether daylight savings is currently in effect.
       
    26 The offset is in seconds from <keyword>universal time</keyword>; this is positive
       
    27 for time zones east of universal time, and negative for time zones west of
       
    28 universal time. Home time is the same time as a wall clock would show, and
       
    29 it is not necessary to consider daylight savings independently of the time
       
    30 zone.</p> <codeblock id="GUID-C9B60594-EA11-5297-8546-99D6E2E64219" xml:space="preserve">TTime time;
       
    31 
       
    32     // Get Universal time
       
    33 time.UniversalTime();
       
    34 
       
    35     // Get Universal time offset
       
    36 TTimeIntervalSeconds universalTimeOffset(User::UTCOffset());
       
    37 
       
    38     // Add locale's universal time offset to universal time
       
    39     // to get the home time
       
    40 time+=universalTimeOffset;</codeblock> <p><codeph>time</codeph> now contains
       
    41 the home time. This may be tested by calling <codeph>TTime::HomeTime()</codeph>,
       
    42 which should give the same result.</p> <codeblock id="GUID-1E6576B5-CA22-5346-9076-B987741509C8" xml:space="preserve">TTime homeTime;
       
    43 homeTime.HomeTime(); // homeTime==time</codeblock> </section>
       
    44 </conbody></concept>