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

📄 date1.cpp

📁 Mysql的处理
💻 CPP
字号:
#include "Date1.h"#include <stdio.h>#include <string.h>#include <stdlib.h>CDate1::CDate1(const char* szYYMMDDHH24MI1, const char* szYYMMDDHH24MI2){	memset(m_szDate1, 0, sizeof(m_szDate1));	memset(m_szDate2, 0, sizeof(m_szDate2));	strcpy(m_szDate1, szYYMMDDHH24MI1);	strcpy(m_szDate2, szYYMMDDHH24MI2);	m_nList.clear();}CDate1::~CDate1(){	m_nList.clear();}int CDate1::GetCount(){	return m_nList.size();}bool CDate1::isLeap(int year){	int isLeap = 0;	if((year % 4) == 0)	{		isLeap = 1;		if((year % 100) == 0)		{			isLeap = 0;			if((year % 400) == 0)			{				isLeap = 1;			}		} 	}	return isLeap;	}string CDate1::GetAt(int i){	return m_nList.at(i);//.c_str();}void CDate1::Add(const char* sz){	m_nList.push_back(sz);}static int MM1[12] = {31,28,31,30,31,30,31,31,30,31,30,31};//leapstatic int MM2[12] = {31,29,31,30,31,30,31,31,30,31,30,31};bool CDate1::Calculate(){	m_nList.clear();		//	//Add();	char szIn[50+1];	int flag;	int nBegin[50],nEnd[50],nDiff[50];		//convert date value to relative int type	if(!strcmp(m_szDate1,"")) return 0;		Add(m_szDate1);		if(!strcmp(m_szDate1,m_szDate2)) return 1;		if(!strcmp(m_szDate2,"")) return 0; 		for(int i=0;i<5;i++)	{		nBegin[i]=(m_szDate1[2*i]-48)*10+(m_szDate1[2*i+1]-48);		nEnd[i]=(m_szDate2[2*i]-48)*10+(m_szDate2[2*i+1]-48);	}		//	for(;;)	{		if((nBegin[4]+=30)==60)		{			nBegin[4]=0;			nBegin[3]+=1;		};		if (nBegin[3]==24)		{			nBegin[3]=0;			flag=isLeap(2000+nBegin[0]);			//		printf("flag=[%d]",flag);			if (flag)			{				nBegin[2]+=1;				if(nBegin[2]>MM2[nBegin[1]-1])				{					nBegin[2]=1;					if ((nBegin[1]+=1)>12)					{						nBegin[0]+=1;					}				}			}			else			{				if((nBegin[2]+=1)>MM1[nBegin[1]-1])				{					nBegin[2]=1;					if ((nBegin[1]+=1)>12)					{						nBegin[0]+=1;					}				}							}				}			snprintf(szIn,50,"%02d%02d%02d%02d%02d",nBegin[0],nBegin[1],nBegin[2],nBegin[3],nBegin[4]);		Add(szIn);				if(strcmp(szIn,m_szDate2)==0) 			return true;			}		return true;}

⌨️ 快捷键说明

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