Back to the WFC main page


$Revision: 27 $


This class encapsulates the SYSTEMTIME data structure in Win32. The benefit from doing this is adding capability to convert between a bunch of time representations.


CSystemTime( const COleDateTime& source )
CSystemTime( const CSystemTime& source )
CSystemTime( const CFileTime& source )
CSystemTime( const CTime& source )
CSystemTime( const SYSTEMTIME * source )
CSystemTime( const FILETIME * source )
CSystemTime( const TIME_OF_DAY_INFO * source )
CSystemTime( const TIMESTAMP_STRUCT * source )
Constructs the object. The constructor that takes a COleDateTime parameter is not present in STL builds.

Data Members

Whatever is in SYSTEMTIME.


LONG Compare( const CSystemTime& source )
Returns the same values as CString::Compare().
void Copy( const COleDateTime& source )
void Copy( const CSystemTime& source )
void Copy( const CFileTime& source )
void Copy( const CTime& source )
void Copy( const SYSTEMTIME * source )
void Copy( const FILETIME * source )
void Copy( const TIME_OF_DAY_INFO * source )
void Copy( const TIMESTAMP_STRUCT * source )
Sets the time to what you specify, you can copy another CFileTime, CSystemTime, FILETIME, SYSTEMTIME or TIME_OF_DAY_INFO.
void CopyTo( COleDateTime& destination ) const
void CopyTo( CTime& destination ) const
void CopyTo( TIMESTAMP_STRUCT * destination )
Copies the date/time out to the various types.
void Empty( void )
Clears the data members.
void Get( void )
Retrieves the current time and stores in in the object.
static CSystemTime GetTheCurrentTime( void )
I would have liked to call this function GetCurrentTime() but Microsoft screwed me in the winbase.h file with a #define. Oh well, that's life. This method retrieves the current time and returns it as a CSystemTime object.
BOOL Set( void ) const
Sets the computer's clock equal to the time stored in this object.


#include <wfc.h>
#pragma hdrstop

int _tmain( int number_of_command_line_arguments, LPCTSTR command_line_arguments[] )
   WFCTRACEINIT( TEXT( "_tmain()" ) );

   CSystemTime the_time;

   the_time.Get(); // Get the current time


   if ( the_time.Set() != FALSE )
      _tprintf( TEXT( "Time advanced by one hour\n" ) );
      _tprintf( TEXT( "Can't adjust time\n" ) );

API's Used

Copyright, 2000, Samuel R. Blackburn
$Workfile: CSystemTime.cpp $
$Modtime: 1/17/00 9:25a $