os/ossrv/genericservices/httputils/internetdateutils/tinternetdate.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 2002-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 // This file contains implementation for classes defined in tinternetdate.h
    15 // 
    16 //
    17 
    18 /**
    19  @file tinternetdate.cpp
    20  @see	tinternetdate.h
    21 */
    22  
    23 
    24 #include "tinternetdate.h"
    25 #include "inetprottextutils.h"
    26 #include "tinternetdateparser.h"
    27 
    28 
    29 /**
    30 	Used to set a date which is in a Internet form.
    31 	
    32 	@since			7.0
    33 	@param			aDate	the text form of the date			.
    34 	@leave			KErrCorrupt, if the date is not in the correct format
    35 */
    36 EXPORT_C void TInternetDate::SetDateL(const TDesC8& aDate)
    37 	{
    38 	TInternetDateParser dateParser;
    39 
    40 	TPtrC8 datePtr(aDate);
    41 	// Remove the any leading and trailing whitespaces from the date.
    42 	InetProtTextUtils::RemoveWhiteSpace(datePtr, InetProtTextUtils::ERemoveBoth);
    43 
    44 	dateParser.ConvertFromInternetFormL(datePtr, iDateTime);
    45 	}
    46 
    47 /**
    48 	Used to access the date/time
    49 	
    50 	@since			7.0
    51 	@return			const TDateTime& The time stored in this object
    52 */
    53 EXPORT_C const TDateTime& TInternetDate::DateTime()
    54 	{
    55 	return iDateTime;
    56 	}
    57 
    58 /**
    59 	Used to access the date/time in a text formate
    60 	
    61 	@since			7.0
    62 	@param			aInternetDateFormat The format of the date. Only RFC1123 dates are supported
    63 	@return			HBufC8* A descriptor containing the date/time in the format 
    64 					specifed by the parameter aInternetDateFormat
    65 	@leave			KErrNoMemory
    66 */
    67 EXPORT_C HBufC8* TInternetDate::InternetDateTimeL(TInternetDateFormat /*aInternetDateFormat*/)
    68 	{
    69 	TInternetDateParser dateParser;
    70 	return dateParser.ConvertToRfc1123FormL(iDateTime);
    71 	}