/* Check if a date is valid. 
Checks that number of seconds, minutes and hours is a valid value. Checks that number of days does not exceed number of days in current month. Checks that number of months is a valid value, and checks that year is between 1970 (epoch year) and 2106 (overflow year). */
bool calendar_is_date_valid(struct calendar_date *date)
/* Check if a date is valid. 
Checks that number of seconds, minutes and hours is a valid value. Checks that number of days does not exceed number of days in current month. Checks that number of months is a valid value, and checks that year is between 1970 (epoch year) and 2106 (overflow year). */
bool calendar_is_date_valid(struct calendar_date *date)
{
	if ((date->second >= 60) || (date->minute >= 60) || (date->hour >= 24)) {
		return false;
	}
	if ((date->month >= 12) || (date->date >=31)) {
		return false;
	}
	if (date->date >= month[calendar_leapyear(date->year)][date->month]) {
		return false;
	}
	if ((date->year < EPOCH_YEAR) || (date->year >= 2106)) {
		return false;
	} else {
		return true;
	}
}