Symbian3/PDK/Source/GUID-A3ACAE90-F1D5-5876-AA02-416B09112F88.dita
author Dominic Pinkman <Dominic.Pinkman@Nokia.com>
Tue, 30 Mar 2010 11:56:28 +0100
changeset 5 f345bda72bc4
parent 3 46218c8b8afa
child 14 578be2adaf3e
permissions -rw-r--r--
Week 12 contribution of PDK documentation_content. See release notes for details. Fixes Bug 2054, Bug 1583, Bug 381, Bug 390, Bug 463, Bug 1897, Bug 344, Bug 1319, Bug 394, Bug 1520, Bug 1522, Bug 1892"

<?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-A3ACAE90-F1D5-5876-AA02-416B09112F88" xml:lang="en"><title>How
to format date as text</title><shortdesc>Formats the day number, date suffix and month name as text into
a supplied descriptor.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
<p> The function in the code fragment assumes that the descriptor is sufficiently
big:</p>
<codeblock id="GUID-207CAB83-6D49-5D28-A2B3-283D2F767A40" xml:space="preserve">void formatDateTime(TDes&amp; aBuffer,TDateTime aDateTime)
    {
    _LIT(KFormatTxt,"Date as text: %d%S %S\n");
    aBuffer.Format(KFormatTxt,aDateTime.Day()+1,&amp;(TDateSuffix(aDateTime.Day())),&amp;(TMonthName(aDateTime.Month())));
    }</codeblock>
<p>Note the following:</p>
<ul>
<li id="GUID-CCF22563-3AAA-5A91-8BA4-B9EC20205E17"><p><xref href="GUID-E22ADC67-CEBC-3A6C-A507-EDB8C706476F.dita"><apiname>TDateSuffix</apiname></xref> and <xref href="GUID-98B3912D-84FC-3BD8-B1F0-1FF965C67D24.dita"><apiname>TMonthName</apiname></xref> are
descriptors</p> </li>
<li id="GUID-DEABA35F-1B1F-5895-A92C-B359B8478238"><p>A <codeph>TDateSuffix</codeph> object
can contain a maximum of 4 characters</p> </li>
<li id="GUID-FE7DEAD0-6BB7-5315-BF9C-818F7ACFE924"><p>A <codeph>TMonthName</codeph> object
can contain a maximum of 32 characters</p> </li>
<li id="GUID-980DC91A-A736-5D70-B8A3-7461DBFE0644"><p>In this example, both
objects are constructed with a <codeph>TInt</codeph> value representing the
day number within the month for the <codeph>TDateSuffix</codeph> object, and
the month number for the <codeph>TMonthName</codeph> object. Both numbers
are values offset from zero.</p> </li>
<li id="GUID-1C2F253C-3B25-5A07-A04E-37205C066E4E"><p>The numbers are used
to generate the appropriate text. For example, for a <codeph>TDateSuffix</codeph> object,
a value of zero gives "st", (fir<i>st</i> day of the month), one gives "nd"
etc.</p> </li>
</ul>
</conbody></concept>