date

A date is a year, month, and day, with an optional timezone offset.

Strings have the form YYYY-MM-DD with an optional timezone suffix, at least 4 year digits (negative or positive), and exactly 2 digits for both month and day. For example, “2001-02-03” or “2001-02-03-06:00”.

Canonical form has no leading zeros for the year.

EXESS_MAX_DATE_LENGTH

18U

The maximum length of a date string from exess_write_date()

struct ExessDate

Date.

int16_t year

Year.

uint8_t month

Month: [1, 12].

uint8_t day

Day: [1, 31].

ExessTimezone zone

Timezone offset in quarter hours.

ExessOrder exess_compare_date(ExessDate lhs, ExessDate rhs)

Compare two dates.

Note that local and zoned dates may not be comparable. See exess_compare_date_time() for details.

Returns:

Less than, equal to, or greater than zero if lhs is less than, equal to, or greater than rhs, respectively. Comparable and incomparable cases may also be distinguished, see ExessOrder for details.

ExessResult exess_read_date(const char *str, ExessDate *out)

Read a date string after any leading whitespace.

Parameters:
  • str – String to read.

  • out – Parsed value, or zero on error.

Returns:

The count of characters read, and a status.

ExessResult exess_write_date(ExessDate value, size_t buf_size, char *buf)

Write a canonical date string.

The output is always in canonical form, like 2001-04-12 or -2001-10-26+02:00.

Parameters:
  • value – Value to write.

  • buf_size – Size of buf in bytes.

  • buf – Output buffer, or null to only measure.

Returns:

ExessStatus.EXESS_SUCCESS on success, ExessStatus.EXESS_NO_SPACE if the buffer is too small, or ExessStatus.EXESS_BAD_VALUE if the value is invalid.