uint32_t date2ms(uint16_t year, uint16_t month, uint16_t day) { uint16_t test_year; uint16_t lastyear_days; uint16_t previousYear; const uint16_t *month_days; uint32_t total_days; test_year = check_year(year); if((test_year == BAD_YEAR) || ((month <= 1) && (month >= 12))) return 0; if(test_year == NOT_LEAP_YEAR) month_days = days2month365; else month_days = days2month366; if( (day <= 1) || (day >= (month_days[month] - month_days[month - 1]))) return 0; previousYear = year-1; lastyear_days = ((((previousYear * 365) + (previousYear / 4)) - (previousYear / 100)) + (previousYear / 400)); total_days = (lastyear_days + month_days[month - 1] + day) - 1; return (total_days * 86400000); }
bool check(string date){ vector<string> z = splitString(date,'/'); int month = stoi(z[0]); int day = stoi(z[1]); int year = stoi(z[2]); if(month == 1){ if(check_year(year)) print(); else pring() } if(month == 2){ if() } if(month != 2) return day <= 31; else{ if(check_year(year)) return day <= 30; return day <= 29; } }
int check_dateformat(char* d,int *dt) { int leapyear = 0, i = 0; /*checking format DD-MM-YYYY*/ if (*(d + 2) != '-' || *(d + 5) != '-') return -1; while ((*(d + i)) != '\0') i++; if (i > 10) return -1; /*checking months less than 12*/ if ((*(dt + 1)) >12) return -1; /*checking for feb*/ if ((*(dt + 1)) == 2) { leapyear = check_year(dt + 2); if (leapyear == 1 && ((*(dt + 0)) > 29)) return -1; if (leapyear == 0 && (*(dt + 0)) > 28) return -1; } /*check for remining months*/ if ((*(dt + 1)) == 1 || (*(dt + 1)) == 3 || (*(dt + 1)) == 5 || (*(dt + 1)) == 7 || (*(dt + 1)) == 8 || (*(dt + 1)) == 10 || (*(dt + 1)) == 12) { if (((*(dt + 0)) > 31)) return -1; } if ((*(dt + 1)) == 4 || (*(dt + 1)) == 6 || (*(dt + 1)) == 9 || (*(dt + 1)) == 11) { if (((*(dt + 0)) > 30)) return -1; } else return 1; }