标签:style blog color io ar div sp log on
1 #include <time.h> 2 #include <stdio.h> 3 4 5 typedef enum 6 { 7 false = 0, 8 true = 1 9 } bool; 10 11 bool check_date(int year, int month, int day) 12 { 13 if (year < 1900 || month <= 0 || month > 12 14 || day <= 0 || day > 31) 15 return false; 16 17 struct tm tm_new; 18 tm_new.tm_year = year - 1900; 19 tm_new.tm_mon = month - 1; 20 tm_new.tm_mday = day; 21 tm_new.tm_hour = 0; 22 tm_new.tm_min = 0; 23 tm_new.tm_sec = 0; 24 25 time_t time_new = mktime(&tm_new); 26 localtime_r(&time_new, &tm_new); 27 28 if (tm_new.tm_year != year - 1900 || tm_new.tm_mon != month - 1 || tm_new.tm_mday != day) 29 return false; 30 return true; 31 }
标签:style blog color io ar div sp log on
原文地址:http://www.cnblogs.com/iwateru/p/3976904.html