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

📄 datelegal.cpp

📁 自己写的date类
💻 CPP
字号:
//DateLegal类的实现
#include "datelegal.h"

//-----------------------------------------------------------
inline void DateLegal::DLsetdate(int y,int m,int d)
{
	year=y;
	month=m;
	day=d;
}

DateLegal::DateLegal(int y,int m,int d)
{
	DateLegal::DLsetdate(y,m,d);
}

bool  DateLegal::year_legal()
{
	return (year >= 1000) && ( year <= 9999 ) ? true : false;
}

bool DateLegal::month_legal()
{
	return ( month > 0 ) && ( month < 13)? true : false;
}

bool DateLegal::is_super_year()
{
	return (( year%4 == 0 ) && ( year%100 != 0 )) || ( year%400 == 0 )? 
		   true : false;
}

bool DateLegal::is_big_month()
{
	return ( month == 1 ) || ( month ==3 ) || ( month == 5) || ( month == 7 )
		|| ( month == 8 ) || ( month == 10 ) || ( month == 12 )? 
		true : false;
}

bool DateLegal::is_month_2()
{
	return month==2? true :false;
}

bool DateLegal::day_legal()
{
	if( !DateLegal::year_legal() )
	{
		return false;
	}

	if( !DateLegal::month_legal() )
	{
		return false;
	}

	if( DateLegal::is_big_month() )
	{
		return ( day > 0 ) && ( day < 32 ) ? true : false; 
	}

	if ( DateLegal::is_month_2() )
	{
		if( DateLegal::is_super_year() )
		{	return ( day > 0 	) && ( day < 30 ) ? true : false;
		}
		else
		{
			return ( day > 0 ) && ( day < 29 ) ? true : false;
		}
	}

	return ( day > 0 ) && ( day < 31 ) ? true : false;
}

bool DateLegal::fine()
{
	return DateLegal::day_legal()? true:false;
}

⌨️ 快捷键说明

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