程设小组作业——计算机配件的进货/销售管理系统

judge_date.h 日期判断函数

/////////////////////////////////////
/*
时间判断函数:判断输入时间是否正确
*/
int judge_date(int year,int month,int day,int hour,int minute){
int judge[12]={31,28,31,30,31,30,31,31,30,31,30,31};
if(year%4==0&&year%100!=0||year%400==0)
judge[1]++;
if(month<1||month>12)
{
printf("\n\ndate error,please check your data and try again.");
return 0;
}
if(day<1||day>judge[month-1])
{
printf("\n\ndate error,please check your data and try again.");
return 0;
}
if(hour<0||hour>=24)
{
printf("\n\ndate error,please check your data and try again.");
return 0;
}
if(minute<0||minute>=60)
{
printf("\n\ndate error,please check your data and try again.");
return 0;
}
return 1;
}

点赞

发表评论