in src/dt.c [381:401]
dt_bool_t dt_validate_representation(const dt_representation_t *representation)
{
if (!representation) {
return DT_FALSE;
}
// Simple checking for invalid values
if (representation->year == 0 || representation->month < 1 || representation->month > 12 || representation->day < 1 ||
representation->hour > 24 || representation->minute > 59 || representation->second > 59 || representation->nano_second > 999999999UL) {
return DT_FALSE;
}
// Passage from Julian to Gregorian calendar
if (representation->year == 1582 && representation->month == 10 && representation->day > 4 && representation->day < 15) {
return DT_FALSE;
}
// Checking leap year
if (dt_is_leap_year(representation->year) && representation->month == 2 && representation->day == 29) {
return DT_TRUE;
}
// Checking month days
return representation->day <= month_days[representation->month] ? DT_TRUE : DT_FALSE;
}