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

📄 eroomtime.h

📁 network library that can be use all network application!
💻 H
字号:
/*
// All Rights Reserved Copyright(c) Eroombox Telecom Technology.
//==============================================================================
//EroomTime.h:矫埃贸府 包访 傍烹窃荐
//==============================================================================
*/

#ifndef _EROOMTIME_H
#define _EROOMTIME_H

#include <time.h>

#define		EROOMTIME_NONE		-1000

// INTERVAL
#define	EROOMITV_SEC(Y)	\
	(((Y)>=0) ? ((Y)&0x1ff):(((-(Y))&0x1ff)|0x0400))	// 
#define	EROOMITV_MIN(Y)	\
	(((Y)>=0) ? (((Y)&0x1ff)<<11):((((-(Y))&0x1ff)<<11)|0x080000)) // 
#define	EROOMITV_HOUR(Y)	\
	(((Y)>=0) ? (((Y)&0x1ff)<<21):((((-(Y))&0x1ff)<<21)|0x20000000)) 
								// 

#define	EROOMITV_DAY(Y)	\
	(((Y)>=0) ? ((Y)&0x1ff):(((-(Y))&0x1ff)|0x0400)) // 
#define	EROOMITV_MON(Y)	\
	(((Y)>=0) ? (((Y)&0x1ff)<<11):((((-(Y))&0x1ff)<<11)|0x080000)) // 
#define	EROOMITV_YEAR(Y)	\
	(((Y)>=0) ? (((Y)&0x1ff)<<21):((((-(Y))&0x1ff)<<21)|0x20000000))
								 // 

#define	EROOMITV_GSEC(Y)	\
	(((Y)&0x0400) ? (-((Y)&0x1ff)) : ((Y)&0x1ff))
#define	EROOMITV_GMIN(Y)	\
	(((Y)&0x080000) ? (-((((Y)^0x080000)>>11)&0x1ff)) : (((Y)>>11)&0x1ff))
#define	EROOMITV_GHOUR(Y)	\
	(((Y)&0x20000000) ? (-((((Y)^0x20000000)>>21)&0x1ff)) : \
		(((Y)>>21)&0x1ff))

#define	EROOMITV_GDAY(Y)	\
	(((Y)&0x0400) ? (-((Y)&0x1ff)) : ((Y)&0x1ff))
#define	EROOMITV_GMON(Y)	\
	(((Y)&0x080000) ? (-((((Y)^0x080000)>>11)&0x1ff)) : (((Y)>>11)&0x1ff))
#define	EROOMITV_GYEAR(Y)	\
	(((Y)&0x20000000) ? (-((((Y)^0x20000000)>>21)&0x1ff)) : \
		 (((Y)>>21)&0x1ff))

#define		EROOMTIME_VALID		0	// 

#define		EROOMEQU_TIME		0 	
#define		EROOMPRV_TIME		1	
#define		EROOMAFT_TIME		2	

#define		EROOMERR_YEAR		-1
#define		EROOMERR_MON			-2	
#define		EROOMERR_DAY			-3	
#define		EROOMERR_HOUR		-4	
#define		EROOMERR_MIN			-5
#define		EROOMERR_SEC			-6
#define		EROOMERR_OTHER		-7

#define		EROOMERR_DYEAR		-11
#define		EROOMERR_DMON		-12
#define		EROOMERR_DDAY		-13
#define		EROOMERR_DHOUR		-14
#define		EROOMERR_DMIN		-15
#define		EROOMERR_DSEC		-16
#define		EROOMERR_DOTHER		-17

#define		EROOMYEAR_MIN		1900
#define		EROOMYEAR_MAX		9999
#define		EROOMMON_MIN			1
#define		EROOMMON_MAX			12
#define		EROOMDAY_MIN			1
#define		EROOMDAY_MAX			31
#define		EROOMHOUR_MIN		0
#define		EROOMHOUR_MAX		23
#define		EROOMMIN_MIN			0
#define		EROOMMIN_MAX			59
#define		EROOMSEC_MIN			0
#define		EROOMSEC_MAX			59

#define		EROOMYEAR_CMAX		9999
#define		EROOMMON_CMAX		12
#define		EROOMHOUR_CMAX		24
#define		EROOMMIN_CMAX		60
#define		EROOMSEC_CMAX		60

#define		EROOMYEAR_DIGIT		4
#define		EROOMMON_DIGIT		2
#define		EROOMDAY_DIGIT		2
#define		EROOMHOUR_DIGIT		2
#define		EROOMMIN_DIGIT		2
#define		EROOMSEC_DIGIT		2
#define		EROOMHIDUKE_DIGIT	(EROOMYEAR_DIGIT + \
					EROOMMON_DIGIT + \
					EROOMDAY_DIGIT + \
					EROOMHOUR_DIGIT + \
					EROOMMIN_DIGIT + \
					EROOMSEC_DIGIT)

#define EROOMISUYEAR(y)       ((!((y) % 4) && ((y) % 100)) || !((y) % 400))
#define	EROOMMAXDAY_INMON(y, m) \
		(EROOMISUYEAR(y) ? uyear_day[(m)] : nyear_day[(m)])

#define EROOMYEARTODAY(y)	(365*(y-1) + (y-1)/4 - (y-1)/100 + (y-1)/400)
#define EROOMMONTODAY(y, m)   \
		(EROOMISUYEAR(y) ? uyear_days[(m)]: nyear_days[(m)])

extern int uyear_days[];
extern int nyear_days[];
extern int uyear_day[];
extern int nyear_day[];


class CEroomTime
{
public:

	void GetTime(int &a_Year, int &a_Mon, int &a_Day,
		int &a_Hour, int &a_Min, int &a_Sec);

	void GetTime(int &a_Year, int &a_Mon, int &a_Day,
		int &a_Hour, int &a_Min, int &a_Sec, int &a_WDay);

	int GetDayOfWeek();
	time_t GetTime();

	struct tm *GetTm();

	void GetIntervalTime(int a_DDate, int a_DTime,
		int &a_CYear, int &a_CMon, int &a_CDay,
		int &a_CHour, int &a_CMin, int &a_CSec);

	void GetIntervalTime(int a_DDate, int a_DTime,
		int &a_CYear, int &a_CMon, int &a_CDay,
		int &a_CHour, int &a_CMin, int &a_CSec,
		int a_Year, int a_Mon, int a_Day,
		int a_Hour, int a_Min, int a_Sec);
	
	int CheckDate(
		int a_Year=EROOMTIME_NONE,
		int a_Mon=EROOMTIME_NONE,
		int a_Day=EROOMTIME_NONE,
		int a_Hour=EROOMTIME_NONE,
		int a_Min=EROOMTIME_NONE,
		int a_Sec=EROOMTIME_NONE);

	int CheckDateInterval(
		int a_OYear,
		int a_OMon,
		int a_ODay,
		int a_OHour,
		int a_OMin,
		int a_OSec,
		int a_CYear,
		int a_CMon,
		int a_CDay,
		int a_CHour,
		int a_CMin,
		int a_CSec);

	int CheckDateInterval(
		int a_IntervalDate,
		int a_IntervalTime,
		int a_Year=EROOMTIME_NONE,
		int a_Mon=EROOMTIME_NONE,
		int a_Day=EROOMTIME_NONE,
		int a_Hour=EROOMTIME_NONE,
		int a_Min=EROOMTIME_NONE,
		int a_Sec=EROOMTIME_NONE);

};

#endif

⌨️ 快捷键说明

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