?? datetime.h
字號:
// Date.h: interface for the CFCWorldDate class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_DATE_H__FF59967B_C0A3_4CF9_9054_8578E83FF3BD__INCLUDED_)
#define AFX_DATE_H__FF59967B_C0A3_4CF9_9054_8578E83FF3BD__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <string>
class CDateTime
{
struct _FORMAT
{
int local;
std::string Key;
};
long m_lTime;
int m_iYear;
int m_iMonth;
int m_iDay;
int m_iHour;
int m_iMinute;
int m_iSecond;
int m_iWeek;
int m_iDiff;//UTC與LOCAL時間之間所差的秒數,用本地時間減去UTC時間
bool m_bLocal;
public:
//得到一個月的天數
int DaysInMonth();
//判斷是否為潤年
bool isLeapYear();
CDateTime(bool bLocal= false);//false表示構造的UTC時間,它構造的當前時間
CDateTime(int iYear,int iMonth,int iDay,int iHour,int iMinute,int iSecond,bool bLocal= false);//默認產生UTC時間
virtual ~CDateTime();
void Today(bool bLocal= false);//得到當前日期,默認產生UTC時間
int GetYear() {return m_iYear;}
int GetMonth(){ return m_iMonth ;}
int GetDay() { return m_iDay;}
int GetWeek() {return m_iMonth;}
CDateTime& AddYears(int iValue);
CDateTime& AddMonths(int iValue);
CDateTime& AddDays(int iValue);
CDateTime& AddWeeks(int iValue);
CDateTime& AddHours(int iValue);
CDateTime& AddMinutes(int iValue);
CDateTime& AddSeconds(int iValue);
//比較時間大小,如果比OtherDate大,返回1,如果相等,返回0,如果小于,返回-1
int Compare(CDateTime& OtherDate);
//格式化時間
std::string ToString(std::string sFormat="YYYY-MM-DD HH:MI:SS");
CDateTime StringToTime(std::string sDate,std::string sFormat="YYYY-MM-DD HH:MI:SS");
//把時間從UTC到本地時間轉換
CDateTime& UTCToLocalTime();
//把時間從本地到UTC時間轉換
CDateTime& LocalToUTCTime();
//得到兩個時間相差的秒數
long operator-(CDateTime& DT);
private:
int GetWeekFromLongTime();
void ToTime(long lDate);
long ToLong();
};
#endif // !defined(AFX_DATE_H__FF59967B_C0A3_4CF9_9054_8578E83FF3BD__INCLUDED_)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -