⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datetime.h

📁 多媒体电话记录程序
💻 H
字号:
/////////////////////////////////////////////////////////////////////////////
//  Name: datetime.h
//  Copyright: wellgain
//  Author: bet
//  Date: 2003-10-8
//  Description:  the interface for for classes CTime and CDateTime
/////////////////////////////////////////////////////////////////////////////
#ifndef _WG_MISC_H_
#define _WG_MISC_H_

#include <time.h>
#include <string>
#include "archive.h"

/////////////////////////////////////////////////////////////////////////////
// 时间类
class CTime
{
public:
	inline int GetHour() const		{ return hour; }
	inline int GetMinute() const	{ return min;  }
	inline int GetSecond() const	{ return sec;  }
	CTime(); 
	CTime& operator=(const CTime& timeSrc);
	virtual ~CTime();
	CTime(int h, int m, int s);
	CTime(long secs);
	CTime& operator=(long t);
	inline long to_long() const			//返回总秒数
		{ return ((long)GetHour())*3600 + 
					GetMinute()*60 + 
					GetSecond(); 
		}
	CTime operator-(CTime t);
	inline CTime operator+(CTime t)	{ return to_long() + t.to_long(); }
	CTime& operator+=(CTime t);	
	CTime& operator-=(CTime t);

	inline bool operator>(CTime t) const  { return (to_long() > t.to_long()); }
	inline bool operator<(CTime t) const  { return (to_long() < t.to_long()); }
	inline bool operator>=(CTime t) const { return (to_long() >= t.to_long()); }
	inline bool operator<=(CTime t) const { return (to_long() <= t.to_long()); }
	inline bool operator==(CTime t) const { return (to_long() == t.to_long()); }
	inline bool operator!=(CTime t) const { return (to_long() != t.to_long()); }
	string to_string() const;  	
	virtual void Serialize(CArchive& ar);

	
private:
	int hour;
	int min;
	int sec;
};

/////////////////////////////////////////////////////////////////////////////
// 日期类
class CDateTime : public CTime
{
public:
	CDateTime();
	CDateTime& operator=(CDateTime& dt);
	virtual ~CDateTime();
	CDateTime(int year, int month, int day,
			  int hour, int minute, int secord);
	CDateTime(time_t t);
	const CDateTime& operator=(const CDateTime& dt);
	inline CTime operator-(CDateTime& dt) const		{ return to_long()-dt.to_long(); }
	inline CDateTime operator-(CTime& t) const		{ return to_long()-t.to_long();  }
	inline CDateTime operator+(CTime& t) const		{ return to_long()+t.to_long();  }
	inline bool operator>(CDateTime dt) const		{ return (to_long() > dt.to_long()); }
	inline bool operator<(CDateTime dt) const		{ return (to_long() < dt.to_long()); }
	inline bool operator>=(CDateTime dt) const		{ return (to_long() >= dt.to_long()); }
	inline bool operator<=(CDateTime dt) const		{ return (to_long() <= dt.to_long()); }
	inline bool operator==(CDateTime dt) const		{ return (to_long() == dt.to_long()); }	 
	inline bool operator!=(CDateTime dt) const		{ return (to_long() != dt.to_long()); }	 
	inline int GetYear() const		{ return year; }
	inline int GetMonth() const		{ return month; }
	inline int GetDay() const		{ return day; }
	string to_string() const; 
	inline string time_string() const		{ return CTime::to_string(); }
	string date_string() const; 	
	long to_long() const;
	virtual void Serialize(CArchive& ar);

private:
	int year;
	int month;
	int day;
};




#endif //_WG_MISC_H_

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -