Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

The Win32 Foundation Classes (WFC) - Version 45

, 16 May 2000
The Win32 Foundation Classes (WFC) are a library of C++ classes that extend Microsoft Foundation Classes (MFC) beyond mere GUI applications, and provide extensive support for system and NT specific applications
html.zip
HTML
html.dsw
html.mak
html.dsp
sample.zip
sample
Sample
ADO2XML
ADO2XML.dsp
ADO2XML.dsw
ChangeServiceConfiguration
ChangeServiceConfiguration.dsp
ChangeServiceConfiguration.dsw
ChangeServiceConfiguration.mak
ClockSync
ClockSync.dsp
ClockSync.dsw
ClockSync.mak
Counter
counter.mak
Crypto
Crypto.dsp
Crypto.dsw
Crypto.mak
CScript
CScript.dsp
CScript.dsw
Data
Receiver
Receiver.dsp
Receiver.dsw
Sender
Sender.dsp
Sender.dsw
DeMangle
DeMangle.dsp
DeMangle.dsw
DriverMover
DriverMover.dsp
DriverMover.dsw
res
DriverMover.ico
DumpEventLog
DumpEventLog.mak
EnableRASLogging
EnableRASLogging.mak
EventPager
EventPager.dsp
EventPager.dsw
EventPager.mak
messages.mc
GetWebPage
GetWebPage.dsp
GetWebPage.dsw
GetWebPage.mak
HTML
html.dsp
html.dsw
html.mak
KillDoc
KillDoc.dsp
KillDoc.dsw
LastEvent
LastEvent.dsp
LastEvent.dsw
LastEvent.mak
Listen
Listen.dsp
Listen.dsw
Listen.mak
ListProcesses
ListProcesses.dsp
ListProcesses.dsw
Map2Def
Map2Def.dsp
Map2Def.dsw
Map2Def.mak
Microphone
Microphone.dsp
Microphone.dsw
MIME2HTML
Debug
MIME2HTML.dsp
MIME2HTML.dsw
PasswordFilter
DLL
PasswordDLL.dsp
PasswordDLL.dsw
PasswordFilter.dsp
PasswordFilter.dsw
Ping
Ping.dsp
Ping.dsw
Ping.mak
Pinger
MESSAGES.MC
Pinger.dsp
Pinger.dsw
Pinger.mak
Pinger.ver
RasAdmin
RasAdmin.dsp
RasAdmin.dsw
RasAdmin.mak
Serial
Serial.dsp
Serial.dsw
Serial.mak
SerialTest
Normal
Receiver
Receiver.dsp
Receiver.dsw
Sender
Sender.dsp
Sender.dsw
Service
Service.dsp
Service.dsw
Service.mak
SkyPage
SkyPage.dsp
SkyPage.dsw
SkyPage.mak
SprintSpectrum
SprintSpectrum.dsp
SprintSpectrum.dsw
SprintSpectrum.mak
Squiggle
Squiggle.mak
TortureXML
TortureXML.dsp
TortureXML.dsw
USNOTime
USNOTime.dsp
USNOTime.dsw
WatchDog
messages.mc
WatchDog.dsp
WatchDog.dsw
WatchDog.mak
WatchDog.ver
Wfc2Html
Wfc2Html.dsp
Wfc2Html.dsw
WinPage
res
WinPage.ico
WinPage.dsp
WinPage.dsw
WinPage.mak
XML
Debug
XML.DSP
XML.dsw
XMLCheck
Debug
XML
XMLCheck.dsp
XMLCheck.dsw
XMLCheck.mak
XMLExplorer
res
bitmap1.bmp
CXMLExplorerDocument.ico
Toolbar.bmp
XMLExplorer.ico
XMLExplorer.dsp
XMLExplorer.dsw
XMLUser
XMLUser.dsp
XMLUser.dsw
TEST
Grid
Grid.mak
MESSAGES.MC
Pipe
Pipe.mak
TEST.dsp
TEST.dsw
TEST.MAK
XMLConformanceTest
XMLConformanceTest.dsp
XMLConformanceTest.dsw
wfc.zip
wfc
HTML
web
INCLUDE
LIB
WFC.dsp
WFC.dsw
WFC.mak
wfcvc42.mak
SRC
#if ! defined( TIME_EX_CLASS_HEADER_FILE )

#define TIME_EX_CLASS_HEADER_FILE

class CTimeSpan
{
   protected:

      time_t m_NumberOfSeconds;

   public:

      inline  CTimeSpan() { m_NumberOfSeconds = 0; }
      inline  CTimeSpan( unsigned long number_of_seconds ) { m_NumberOfSeconds = number_of_seconds; }
      inline  CTimeSpan( unsigned long days, unsigned long hours, unsigned long minutes, unsigned long number_of_seconds )
      {
         m_NumberOfSeconds  = number_of_seconds;
         m_NumberOfSeconds += ( minutes * 60L );
         m_NumberOfSeconds += ( 60L * 60L * hours );
         m_NumberOfSeconds += ( 24L * 60L * 60L * days );
      }
      inline CTimeSpan( const CTimeSpan& source ) { m_NumberOfSeconds = source.m_NumberOfSeconds; }
      inline ~CTimeSpan() { m_NumberOfSeconds = 0; }

      inline long   GetTotalHours( void ) const { return( m_NumberOfSeconds / 3600L ); }
      inline long   GetTotalMinutes( void ) const { return( m_NumberOfSeconds / 60L ); }
      inline time_t GetTotalSeconds( void ) const { return( m_NumberOfSeconds ); }
      inline long   GetDays( void ) const { return( m_NumberOfSeconds / 86400L ); }
      inline long   GetHours( void ) const { return( GetTotalHours() - ( GetDays() * 24L ) ); }
      inline long   GetMinutes( void ) const { return( GetTotalMinutes() - ( GetTotalHours() * 60L ) ); }
      inline long   GetSeconds( void ) const { return( GetTotalSeconds() - ( GetTotalMinutes() * 60L ) ); }
      inline CTimeSpan operator-( const CTimeSpan& source ) const { return( CTimeSpan( m_NumberOfSeconds - source.m_NumberOfSeconds ) ); }
      inline CTimeSpan operator+( const CTimeSpan& source ) const { return( CTimeSpan( m_NumberOfSeconds + source.m_NumberOfSeconds ) ); }
      inline const CTimeSpan& operator+=( const CTimeSpan& source ) { m_NumberOfSeconds += source.m_NumberOfSeconds; return( *this ); }
      inline const CTimeSpan& operator-=( const CTimeSpan& source ) { m_NumberOfSeconds -= source.m_NumberOfSeconds; return( *this ); }
      inline BOOL operator == ( const CTimeSpan& source ) const { return( m_NumberOfSeconds == source.m_NumberOfSeconds ); }
      inline BOOL operator != ( const CTimeSpan& source ) const { return( m_NumberOfSeconds != source.m_NumberOfSeconds ); }
      inline BOOL operator < ( const CTimeSpan& source ) const  { return( m_NumberOfSeconds <  source.m_NumberOfSeconds ); }
      inline BOOL operator > ( const CTimeSpan& source ) const  { return( m_NumberOfSeconds >  source.m_NumberOfSeconds ); }
      inline BOOL operator <= ( const CTimeSpan& source ) const { return( m_NumberOfSeconds <= source.m_NumberOfSeconds ); }
      inline BOOL operator >= ( const CTimeSpan& source ) const { return( m_NumberOfSeconds >= source.m_NumberOfSeconds ); }

      CString Format( LPCTSTR format_string ) const;
};

class CTimeEx
{
   protected:

      time_t m_Time;

      time_t m_Make_time_t( const struct tm * time_p );

   public:

      // Construction

      CTimeEx();
      CTimeEx( const CTimeEx&    source );
      CTimeEx( const CTimeEx *   source );
      CTimeEx( const time_t      source );
      CTimeEx( const struct tm * source );
      CTimeEx( const struct tm&  source );
      CTimeEx( int year, int month, int day, int hour, int minute, int second, int daylight_savings_time = -1 );
     ~CTimeEx();

      // Methods

      static void GetCurrentTheTime( CTimeEx& source );
      static void GreenwichMeanTime( const time_t * address_of_a_time_t, struct tm * address_of_a_tm_structure );

      int    Compare( const CTimeEx& source ) const;
      void   Copy( const CTimeEx&    source );
      void   Copy( const CTimeEx *   source );
      void   Copy( const time_t      source );
      void   Copy( const struct tm * source );
      void   Copy( const struct tm&  source );
      void   CopyModifiedJulianDate( double source );
      void   CopyTo( time_t&    destination ) const;
      void   CopyTo( struct tm& destination ) const;
      void   CopyTo( CString& iso_8601_date ) const;
      void   Empty( void );
      CString Format( LPCTSTR format_string ) const; // same as strftime
      int    GetDay( void ) const;
      int    GetDayOfWeek( void ) const;
      int    GetDayOfYear( void ) const;
      int    GetHour( void ) const;
      int    GetMinute( void ) const;
      int    GetMonth( void ) const;
      int    GetSecond( void ) const;
      void   GetTime( struct tm& time_structure ) const;
      time_t GetTotalSeconds( void ) const;
      int    GetYear( void ) const;
      void   Set( const CString& iso_8601_date );
      void   Set( int year, int month, int day, int hour, int minute, int second, int daylight_savings_time = -1 );

      // Operators

      inline                 operator time_t     ( void                     ) const { return( m_Time ); };
      inline       CTimeEx&  operator =          ( const CTimeEx&    source )       { Copy( source ); return( *this ); };
      inline       CTimeEx&  operator =          ( const time_t      source )       { Copy( source ); return( *this ); };
      inline       CTimeEx&  operator =          ( const struct tm&  source )       { Copy( source ); return( *this ); };
      inline       BOOL      operator ==         ( const CTimeEx&    source ) const { return( ( Compare( source ) == 0   ) ? TRUE  : FALSE ); };
      inline       BOOL      operator !=         ( const CTimeEx&    source ) const { return( ( Compare( source ) == 0   ) ? FALSE : TRUE  ); };
      inline       BOOL      operator >=         ( const CTimeEx&    source ) const { return( ( Compare( source ) > (-1) ) ? TRUE  : FALSE ); };
      inline       BOOL      operator <=         ( const CTimeEx&    source ) const { return( ( Compare( source ) < 1    ) ? TRUE  : FALSE ); };
      inline       BOOL      operator >          ( const CTimeEx&    source ) const { return( ( Compare( source ) > 0    ) ? TRUE  : FALSE ); };
      inline       BOOL      operator <          ( const CTimeEx&    source ) const { return( ( Compare( source ) < 0    ) ? TRUE  : FALSE ); };
      inline       CTimeSpan operator -          ( const CTimeEx&    source ) const { return( CTimeSpan( m_Time - source.m_Time ) ); };
      inline       CTimeEx   operator -          ( const CTimeSpan&  source ) const { return( CTimeEx( m_Time - source.GetTotalSeconds() ) ); };
      inline       CTimeEx   operator +          ( const CTimeSpan&  source ) const { return( CTimeEx( m_Time + source.GetTotalSeconds() ) ); };
      inline const CTimeEx&  operator +=         ( const CTimeSpan&  source )       { m_Time += source.GetTotalSeconds(); return( *this ); };
      inline const CTimeEx&  operator -=         ( const CTimeSpan&  source )       { m_Time -= source.GetTotalSeconds(); return( *this ); };
};

class CTime
{
   protected:

      CTimeEx m_Time;

   public:

      inline CTime(){};
      inline CTime( time_t the_time ) : m_Time( the_time ) {};
      inline CTime( int year, int month, int day, int hour, int minute, int second, int daylight_savings_time = -1 )
      {
         m_Time = CTimeEx( year, month, day, hour, minute, second, daylight_savings_time );
      }

      inline ~CTime() {};

      static CTime PASCAL GetCurrentTime() { CTimeEx the_time; CTimeEx::GetCurrentTheTime( the_time ); return( CTime( (time_t) the_time ) ); }

      // Snap all of the calls to CTimeEx

      inline CString Format( LPCTSTR format_string ) const { return( m_Time.Format( format_string ) ); }
      inline int GetDay(       void ) const { return( m_Time.GetDay()       ); }
      inline int GetDayOfWeek( void ) const { return( m_Time.GetDayOfWeek() ); }
      inline int GetHour(      void ) const { return( m_Time.GetHour()      ); }
      inline int GetMinute(    void ) const { return( m_Time.GetMinute()    ); }
      inline int GetMonth(     void ) const { return( m_Time.GetMonth()     ); }
      inline int GetSecond(    void ) const { return( m_Time.GetSecond()    ); }
      inline int GetYear(      void ) const { return( m_Time.GetYear()      ); }

      inline                 operator time_t     ( void                     ) const { return( m_Time.operator time_t() ); }
      inline       CTime&    operator =          ( const CTime&      source )       { m_Time.Copy( source.m_Time ); return( *this ); }
      inline       CTime&    operator =          ( const time_t      source )       { m_Time.Copy( source        ); return( *this ); }
      inline       CTime&    operator =          ( const struct tm&  source )       { m_Time.Copy( source        ); return( *this ); }
      inline       BOOL      operator ==         ( const CTime&      source ) const { return( m_Time.operator==( source.m_Time ) ); }
      inline       BOOL      operator !=         ( const CTime&      source ) const { return( m_Time.operator!=( source.m_Time ) ); }
      inline       BOOL      operator >=         ( const CTime&      source ) const { return( m_Time.operator>=( source.m_Time ) ); }
      inline       BOOL      operator <=         ( const CTime&      source ) const { return( m_Time.operator<=( source.m_Time ) ); }
      inline       BOOL      operator >          ( const CTime&      source ) const { return( m_Time.operator> ( source.m_Time ) ); }
      inline       BOOL      operator <          ( const CTime&      source ) const { return( m_Time.operator< ( source.m_Time ) ); }
      inline       CTimeSpan operator -          ( const CTime&      source ) const { return( m_Time.operator- ( source.m_Time ) ); }
      inline       CTime     operator -          ( const CTimeSpan&  source ) const { return( m_Time.operator- ( source        ) ); }
      inline       CTime     operator +          ( const CTimeSpan&  source ) const { return( m_Time.operator+ ( source        ) ); }
      inline const CTime&    operator +=         ( const CTimeSpan&  source )       { m_Time += source; return( *this ); }
      inline const CTime&    operator -=         ( const CTimeSpan&  source )       { m_Time -= source; return( *this ); }
};

#endif // TIME_EX_CLASS_HEADER_FILE

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Sam Blackburn

United States United States
I'm just a simple little NT programmer. Most of the work I do is remote controlling equipment in real time. I started out using Windows 3.0. Then came 3.1 and then NT. I started using NT but unfortunately, Microsoft didn't. I started using MFC but unfortunately, Microsoft didn't (and still doesn't) put any real support for NT into MFC so I wrote a bunch of C++ classes to make my life easier. Like all class libraries, mine grew. Now I'm giving it away, I call it Win32 Foundation Classes.
 
Check out Sam's homepage at www.SamBlackburn.com/wfc/.

| Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 17 May 2000
Article Copyright 2000 by Sam Blackburn
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid