linux判断日期是否合法

 #include <time.h>
#include <stdio.h> typedef enum
{
false = ,
true =
} bool; bool check_date(int year, int month, int day)
{
if (year < || month <= || month >
|| day <= || day > )
return false; struct tm tm_new;
tm_new.tm_year = year - ;
tm_new.tm_mon = month - ;
tm_new.tm_mday = day;
tm_new.tm_hour = ;
tm_new.tm_min = ;
tm_new.tm_sec = ; time_t time_new = mktime(&tm_new);
localtime_r(&time_new, &tm_new); if (tm_new.tm_year != year - || tm_new.tm_mon != month - || tm_new.tm_mday != day)
return false;
return true;
}
上一篇:无法上外网, ping网关ping不通的解决——arp命令


下一篇:.Net Standard(.Net Core)实现获取配置信息