time 1.0
Time validation library
Loading...
Searching...
No Matches
validate.c File Reference
#include "validate.h"
Include dependency graph for validate.c:

Functions

RETURN_Data_Status validate_time (const FORMAT_Time *time)
 Validates a FORMAT_Time instance for proper hour, minute, and second ranges.
RETURN_Data_Status validate_date (const FORMAT_Date *date)
 Validates a FORMAT_Date instance for basic day, month, and year ranges.
RETURN_Data_Status validate_datetime (const FORMAT_DateTime *datetime)
 Validates a FORMAT_DateTime instance by checking its date and time components.

Function Documentation

◆ validate_date()

RETURN_Data_Status validate_date ( const FORMAT_Date * date)

Validates a FORMAT_Date instance for basic day, month, and year ranges.

Parameters
datePointer to a FORMAT_Date structure whose fields will be checked:
  • day (expected range: 1–31, only an upper-bound check is performed here)
  • month (expected range: 1–12, only an upper-bound check is performed here)
  • year (expected range: 0–99, interpreted as an application-defined offset)
Returns
Returns one of the following status codes:
  • RETURN_Valid if all date fields are within their configured ranges.
  • RETURN_Invalid if any of the fields contain an out-of-range value.

This function performs a simple, range-based validation on the provided date structure. It checks only the maximum values for day, month, and year, and does not account for month-specific day counts or leap years. For stricter calendar validation, additional checks must be applied by the caller or a higher-level routine.

Here is the caller graph for this function:

◆ validate_datetime()

RETURN_Data_Status validate_datetime ( const FORMAT_DateTime * datetime)

Validates a FORMAT_DateTime instance by checking its date and time components.

Parameters
datetimePointer to a FORMAT_DateTime structure whose date and time substructures will be validated using validate_date() and validate_time().
Returns
Returns a combined status code:
  • RETURN_Valid if both the date and time components are valid.
  • RETURN_Invalid if either the date or the time (or both) are invalid.

This function delegates validation to validate_time() for the time portion and validate_date() for the date portion of datetime. The individual results are bitwise OR-combined into a single RETURN_Data_Status value, allowing callers to treat any invalid subcomponent as an overall invalid date-time.

Here is the call graph for this function:

◆ validate_time()

RETURN_Data_Status validate_time ( const FORMAT_Time * time)

Validates a FORMAT_Time instance for proper hour, minute, and second ranges.

Parameters
timePointer to a FORMAT_Time structure whose fields will be checked:
  • hour (expected range: 0–23)
  • minute (expected range: 0–59)
  • second (expected range: 0–59)
Returns
Returns one of the following status codes:
  • RETURN_Valid if all time fields are within their expected ranges.
  • RETURN_Invalid if any of the fields contain an out-of-range value.

This function performs a simple range validation on the provided time structure. If hour, minute, or second exceed their respective limits, the function reports an invalid status; otherwise, it reports a valid time.

Here is the caller graph for this function: