Symbian3/SDK/Source/GUID-3F7142D6-261B-5FB9-888A-1A9BB51B67E5.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Tue, 20 Jul 2010 12:00:49 +0100
changeset 13 48780e181b38
parent 7 51a74ef9ed63
permissions -rw-r--r--
Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE concept
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="GUID-3F7142D6-261B-5FB9-888A-1A9BB51B67E5" xml:lang="en"><title>Using
Date and Time Utilities </title><prolog><metadata><keywords/></metadata></prolog><conbody>
<p>Stores dates in universal time format and supports the parsing of dates. </p>
<section><title>Introduction</title><p><xref href="GUID-156E9C02-99AD-3C63-80AD-939A6DFB08B1.dita"><apiname>TInternetDate</apiname></xref> class
stores the date in universal time and provides the functionality to parse
internet style dates in different formats into <xref href="GUID-13A9DD2B-8ABC-3D62-B54E-4F5DD5B9228B.dita"><apiname>TDateTime</apiname></xref> and
RFC 1123 dates. This class handles the 8-bit descriptors only. </p><p><xref href="GUID-156E9C02-99AD-3C63-80AD-939A6DFB08B1.dita"><apiname>TInternetDate</apiname></xref> supports
parsing of the following date time formats: </p><ul>
<li><p>Sun, 06 Nov 1994 08:49:37 GMT, RFC 822 and RFC 1123 </p></li>
<li><p>Sunday, 06-Nov-94 08:49:37 GMT, RFC 850 </p></li>
<li><p>Sun Nov 6 08:49:37 1994 ANSI C's asctime() format </p></li>
</ul> </section>
<section><title>Converting date to text format </title><p>The following code
fragment constructs a <xref href="GUID-156E9C02-99AD-3C63-80AD-939A6DFB08B1.dita"><apiname>TInternetDate</apiname></xref> object from a <xref href="GUID-13A9DD2B-8ABC-3D62-B54E-4F5DD5B9228B.dita"><apiname>TDateTime</apiname></xref> object.
It converts the date '<userinput>2006,EJanuary,17,06,36,30,000000</userinput>'
to the text form, that is '<userinput>Wed, 17 Jan 2006 06:36:30 GMT</userinput>'. </p><codeblock xml:space="preserve">//create a date time object
TDateTime time(2006,EJanuary,17,06,36,30,000000);  TInternetDate internetDate(time);

//get the text form "Wed, 17 Jan 2006 06:36:30 GMT"
HBufC8* textDate = internetDate.InternetDateTimeL(TInternetDate::ERfc1123Format);
CleanupStack::PushL(textDate);

//use textDate here
CleanupStack::PopAndDestroy(textDate);
</codeblock></section>
<section><title>Setting text form of date </title><p>Use <xref href="GUID-156E9C02-99AD-3C63-80AD-939A6DFB08B1.dita#GUID-156E9C02-99AD-3C63-80AD-939A6DFB08B1/GUID-62720E45-43B1-38A5-992F-74FFD953CAF2"><apiname>TInternetDate::SetDateL()</apiname></xref> to
set the text from of the date. Construct a <xref href="GUID-156E9C02-99AD-3C63-80AD-939A6DFB08B1.dita"><apiname>TInternetDate</apiname></xref> object
[date string] from a desciptor which contains date. </p><codeblock xml:space="preserve">_LIT8(KTextDate, "Wed, 17 Jan 2006 06:36:30 GMT");
TInternetDate internetDate1; 

//set date time, "Wed, 17 Jan 2006 06:36:30 GMT"
internetDate1.SetDateL(KTextDate); 

//convert textDate to Date time format
TDateTime time1 = internetDate1.DateTime(); 
</codeblock><p>The code fragment sets the text form of date,
"<codeph>Wed, 17 Jan 2006 06:36:30 GMT</codeph>" and converts it to DateTime
format. </p></section>
<section><title>See also</title> <p><xref href="GUID-795B41AF-FBEA-56CE-AE20-EF17BE754723.dita">HTTP
Utilities Library Overview</xref>  </p> </section>
</conbody></concept>