📄 vmdatetime.h
字号:
#ifndef VM_DATETIME_H_INCLUDED
#define VM_DATETIME_H_INCLUDED
/*****************************************************************************/
/* HEADER FILE */
/*****************************************************************************/
/*
$Archive: $
$Revision: $
$Date: $
$Author: $
Description: Declaration of a datetime classes wrapping SYSTEMTIME
TOOL And XML FORMS License
==========================
Except where otherwise noted, all of the documentation
and software included in the TOOL package is
copyrighted by Michael Swartzendruber.
Copyright (C) 2005 Michael John Swartzendruber.
All rights reserved.
Access to this code, whether intentional or accidental,
does NOT IMPLY any transfer of rights.
This software is provided "as-is," without any express
or implied warranty. In no event shall the author be held
liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for
any purpose, including commercial applications, and to
alter and redistribute it, provided that the following
conditions are met:
1. All redistributions of source code files must retain
all copyright notices that are currently in place,
and this list of conditions without modification.
2. The origin of this software must not be misrepresented;
you must not claim that you wrote the original software.
3. If you use this software in another product, an acknowledgment
in the product documentation would be appreciated but is
not required.
4. Modified versions in source or binary form must be plainly
marked as such, and must not be misrepresented as being
the original software.
*/
/*****************************************************************************/
#include "VMString.h"
///////////////////////////////////////////////////////////////////////////////
//
// First define a class that represents a time offset. This class is used to
// calculate "delta times" from the basic VMDateTime class which follows.
//
///////////////////////////////////////////////////////////////////////////////
class VMTimeOffset
{
public:
VMTimeOffset( long lSpan );
VMTimeOffset( long lDays, int iHours, int iMins, int iSecs );
VMTimeOffset( const VMTimeOffset& roOther );
~VMTimeOffset( void ){;};
const VMTimeOffset& operator= ( const VMTimeOffset& roOther );
long GetDays( void ) const;
bool IsModByDaysZero( void ) const;
long GetTotalHours( void ) const;
int GetHours( void ) const;
bool IsModByHoursZero( void ) const;
long GetTotalMinutes( void ) const;
int GetMinutes( void ) const;
bool IsModByMinutesZero( void ) const;
long GetTotalSeconds( void ) const;
int GetSeconds( void ) const;
VMTimeOffset operator- ( VMTimeOffset oOther ) const;
VMTimeOffset operator+ ( VMTimeOffset oOther ) const;
const VMTimeOffset& operator+= ( VMTimeOffset oOther );
const VMTimeOffset& operator-= ( VMTimeOffset oOther );
bool operator== ( VMTimeOffset oOther ) const;
bool operator!= ( VMTimeOffset oOther ) const;
bool operator< ( VMTimeOffset oOther ) const;
bool operator> ( VMTimeOffset oOther ) const;
bool operator<= ( VMTimeOffset oOther ) const;
bool operator>= ( VMTimeOffset oOther ) const;
private:
long m_lTimeSpan;
};
///////////////////////////////////////////////////////////////////////////////
//
// Declaration of the Date-Time class wrapper over a SYSTEMTIME structure.
// Roughly modelled on MFC's CTime but without the "MFC-ness"
//
///////////////////////////////////////////////////////////////////////////////
class VMDateTime
{
public:
static VMDateTime CurrentTime( void );
VMDateTime( const char* pchDateTime );
VMDateTime( void );
VMDateTime( const SYSTEMTIME& rxTime );
VMDateTime( const FILETIME& rxFileTime );
VMDateTime( int iYear, int iMonth, int iDay, int iHour, int iMin, int iSec );
VMDateTime( const VMDateTime& timeSrc );
const VMDateTime& operator= ( const VMDateTime& roOther );
const VMDateTime& operator= ( SYSTEMTIME xTime );
void SubtractOneMonth( void );
void AddOneMonth( void );
void SubtractOneYear( void );
void AddOneYear( void );
SYSTEMTIME GetTime( void ) const;
int GetYear( void ) const;
int GetMonth( void ) const;
int GetDay( void ) const;
int GetHour( void ) const;
int GetMinute( void ) const;
int GetSecond( void ) const;
int GetDayOfWeek( void ) const;
static bool IsLeapYear( int nYear );
bool operator== ( VMDateTime roOther ) const;
bool operator!= ( VMDateTime roOther ) const;
bool operator< ( VMDateTime roOther ) const;
bool operator> ( VMDateTime roOther ) const;
bool operator<= ( VMDateTime roOther ) const;
bool operator>= ( VMDateTime roOther ) const;
VMDateTime operator- ( VMTimeOffset oOffset ) const;
VMDateTime operator+ ( VMTimeOffset oOffset ) const;
const VMDateTime& operator+= ( VMTimeOffset oOffset );
const VMDateTime& operator-= ( VMTimeOffset oOffset );
const long GetTimeSpan( VMDateTime& roOther );
VMString Format( const char* pchFormat ) const;
protected:
void SetDays( void );
void BackAdjustMDY( SYSTEMTIME& rxTime ) const;
void FrwdAdjustMDY( SYSTEMTIME& rxTime ) const;
private:
SYSTEMTIME m_xTime;
int m_iDayOfYear;
};
#endif
/*****************************************************************************/
/* Check-in history */
/*
*$Log: $
*/
/*****************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -