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.
sl@0
     1
// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// This file contains implementation for classes defined in tinternetdate.h
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
/**
sl@0
    19
 @file tinternetdate.cpp
sl@0
    20
 @see	tinternetdate.h
sl@0
    21
*/
sl@0
    22
 
sl@0
    23
sl@0
    24
#include "tinternetdate.h"
sl@0
    25
#include "inetprottextutils.h"
sl@0
    26
#include "tinternetdateparser.h"
sl@0
    27
sl@0
    28
sl@0
    29
/**
sl@0
    30
	Used to set a date which is in a Internet form.
sl@0
    31
	
sl@0
    32
	@since			7.0
sl@0
    33
	@param			aDate	the text form of the date			.
sl@0
    34
	@leave			KErrCorrupt, if the date is not in the correct format
sl@0
    35
*/
sl@0
    36
EXPORT_C void TInternetDate::SetDateL(const TDesC8& aDate)
sl@0
    37
	{
sl@0
    38
	TInternetDateParser dateParser;
sl@0
    39
sl@0
    40
	TPtrC8 datePtr(aDate);
sl@0
    41
	// Remove the any leading and trailing whitespaces from the date.
sl@0
    42
	InetProtTextUtils::RemoveWhiteSpace(datePtr, InetProtTextUtils::ERemoveBoth);
sl@0
    43
sl@0
    44
	dateParser.ConvertFromInternetFormL(datePtr, iDateTime);
sl@0
    45
	}
sl@0
    46
sl@0
    47
/**
sl@0
    48
	Used to access the date/time
sl@0
    49
	
sl@0
    50
	@since			7.0
sl@0
    51
	@return			const TDateTime& The time stored in this object
sl@0
    52
*/
sl@0
    53
EXPORT_C const TDateTime& TInternetDate::DateTime()
sl@0
    54
	{
sl@0
    55
	return iDateTime;
sl@0
    56
	}
sl@0
    57
sl@0
    58
/**
sl@0
    59
	Used to access the date/time in a text formate
sl@0
    60
	
sl@0
    61
	@since			7.0
sl@0
    62
	@param			aInternetDateFormat The format of the date. Only RFC1123 dates are supported
sl@0
    63
	@return			HBufC8* A descriptor containing the date/time in the format 
sl@0
    64
					specifed by the parameter aInternetDateFormat
sl@0
    65
	@leave			KErrNoMemory
sl@0
    66
*/
sl@0
    67
EXPORT_C HBufC8* TInternetDate::InternetDateTimeL(TInternetDateFormat /*aInternetDateFormat*/)
sl@0
    68
	{
sl@0
    69
	TInternetDateParser dateParser;
sl@0
    70
	return dateParser.ConvertToRfc1123FormL(iDateTime);
sl@0
    71
	}