/* Checks whether the date and time passed in is valid.  */
static bool RTC_CheckDatetimeFormat(const rtc_datetime_t *datetime)
/* Checks whether the date and time passed in is valid.  */
static bool RTC_CheckDatetimeFormat(const rtc_datetime_t *datetime)
{
    uint8_t daysPerMonth[] = {0U, 31U, 28U, 31U, 30U, 31U, 30U, 31U, 31U, 30U, 31U, 30U, 31U};
    if ((datetime->year < YEAR_RANGE_START) || (datetime->year > YEAR_RANGE_END) || (datetime->month > 12U) ||
        (datetime->month < 1U) || (datetime->hour >= 24U) || (datetime->minute >= 60U) || (datetime->second >= 60U))
    {
        return false;
    }
    if (!(datetime->year & 3U))
    {
        daysPerMonth[2] = 29U;
    }
    if (datetime->day > daysPerMonth[datetime->month])
    {
        return false;
    }
    return true;
}