secureswitools/swisistools/source/sisxlibrary/datetime.cpp
changeset 0 ba25891c3a9e
child 26 04d4a7bbc3e0
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 * Note: This file may contain code to generate corrupt files for test purposes.
       
    16 * Such code is excluded from production builds by use of compiler defines;
       
    17 * it is recommended that such code should be removed if this code is ever published publicly.
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 /**
       
    23  @file 
       
    24  @internalComponent
       
    25  @released
       
    26 */
       
    27 
       
    28 #include "sisdatetime.h"
       
    29 #include <time.h>
       
    30 
       
    31 
       
    32 void CSISDateTime::InsertMembers ()
       
    33 	{
       
    34 	InsertMember (iDate);
       
    35 	InsertMember (iTime);
       
    36 	}
       
    37 
       
    38 
       
    39 CSISDateTime::CSISDateTime ()
       
    40 	{ 
       
    41 	InsertMembers ();
       
    42 	}
       
    43 
       
    44 
       
    45 CSISDateTime::CSISDateTime (const CSISDateTime& aInitialiser) :
       
    46 		CStructure <CSISFieldRoot::ESISDateTime> (aInitialiser),
       
    47 		iDate (aInitialiser.iDate),
       
    48 		iTime (aInitialiser.iTime)
       
    49 	{ 
       
    50 	InsertMembers (); 
       
    51 	}
       
    52 
       
    53 
       
    54 std::string CSISDateTime::Name () const
       
    55 	{
       
    56 	return "Date Time";
       
    57 	}
       
    58 
       
    59 
       
    60 
       
    61 void CSISDateTime::SetNow ()
       
    62 	{
       
    63 	time_t now;
       
    64 	struct tm *gmt;
       
    65 
       
    66 	time (&now);
       
    67 	gmt = gmtime (&now);
       
    68 	assert (gmt);
       
    69 
       
    70 	iDate.Set (gmt -> tm_year + 1900, gmt -> tm_mon, gmt -> tm_mday);
       
    71 	iTime.Set (gmt -> tm_hour, gmt -> tm_min, gmt -> tm_sec);
       
    72 	}
       
    73 
       
    74 void CSISDateTime::AddPackageEntry(std::wostream& aStream, bool aVerbose) const
       
    75 	{
       
    76 	iDate.AddPackageEntry(aStream, aVerbose);
       
    77 	aStream << L" ";
       
    78 	iTime.AddPackageEntry(aStream, aVerbose);
       
    79 	}
       
    80