|
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-3F7142D6-261B-5FB9-888A-1A9BB51B67E5" xml:lang="en"><title>Using |
|
13 Date and Time Utilities </title><prolog><metadata><keywords/></metadata></prolog><conbody> |
|
14 <p>Stores dates in universal time format and supports the parsing of dates. </p> |
|
15 <section><title>Introduction</title><p><xref href="GUID-156E9C02-99AD-3C63-80AD-939A6DFB08B1.dita"><apiname>TInternetDate</apiname></xref> class |
|
16 stores the date in universal time and provides the functionality to parse |
|
17 internet style dates in different formats into <xref href="GUID-13A9DD2B-8ABC-3D62-B54E-4F5DD5B9228B.dita"><apiname>TDateTime</apiname></xref> and |
|
18 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 |
|
19 parsing of the following date time formats: </p><ul> |
|
20 <li><p>Sun, 06 Nov 1994 08:49:37 GMT, RFC 822 and RFC 1123 </p></li> |
|
21 <li><p>Sunday, 06-Nov-94 08:49:37 GMT, RFC 850 </p></li> |
|
22 <li><p>Sun Nov 6 08:49:37 1994 ANSI C's asctime() format </p></li> |
|
23 </ul> </section> |
|
24 <section><title>Converting date to text format </title><p>The following code |
|
25 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. |
|
26 It converts the date '<userinput>2006,EJanuary,17,06,36,30,000000</userinput>' |
|
27 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 |
|
28 TDateTime time(2006,EJanuary,17,06,36,30,000000); TInternetDate internetDate(time); |
|
29 |
|
30 //get the text form "Wed, 17 Jan 2006 06:36:30 GMT" |
|
31 HBufC8* textDate = internetDate.InternetDateTimeL(TInternetDate::ERfc1123Format); |
|
32 CleanupStack::PushL(textDate); |
|
33 |
|
34 //use textDate here |
|
35 CleanupStack::PopAndDestroy(textDate); |
|
36 </codeblock></section> |
|
37 <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 |
|
38 set the text from of the date. Construct a <xref href="GUID-156E9C02-99AD-3C63-80AD-939A6DFB08B1.dita"><apiname>TInternetDate</apiname></xref> object |
|
39 [date string] from a desciptor which contains date. </p><codeblock xml:space="preserve">_LIT8(KTextDate, "Wed, 17 Jan 2006 06:36:30 GMT"); |
|
40 TInternetDate internetDate1; |
|
41 |
|
42 //set date time, "Wed, 17 Jan 2006 06:36:30 GMT" |
|
43 internetDate1.SetDateL(KTextDate); |
|
44 |
|
45 //convert textDate to Date time format |
|
46 TDateTime time1 = internetDate1.DateTime(); |
|
47 </codeblock><p>The code fragment sets the text form of date, |
|
48 "<codeph>Wed, 17 Jan 2006 06:36:30 GMT</codeph>" and converts it to DateTime |
|
49 format. </p></section> |
|
50 <section><title>See also</title> <p><xref href="GUID-795B41AF-FBEA-56CE-AE20-EF17BE754723.dita">HTTP |
|
51 Utilities Library Overview</xref> </p> </section> |
|
52 </conbody></concept> |