Timezone Offsets

Some time and date values can have a timezone qualifier suffix.

A timezone isn’t a datatype unto itself, but only exists as a part of another value.

Canonical form starts with a sign, followed by two-digit hour and minute offsets separated by a colon, like “-06:00” and “+02:30”. The zero offset, UTC, is written “Z”.

Non-canonical form also allows writing UTC as “-00:00” or “+00:00”.

This implementation only supports a resolution of 15 minutes, that is, only offsets at 0, 15, 30, and 45 minutes within an hour.

EXESS_TIMEZONE_LOCAL

((ExessTimezone)127U)

Sentinel value for local time.

EXESS_TIMEZONE_UTC

((ExessTimezone)0U)

Sentinel value for UTC time.

typedef int8_t ExessTimezone

A time zone offset in quarter hours.

This is stored in a single byte for compactness in other structures. Valid values are from -56 to 56 inclusive.

ExessTimezone exess_timezone(int8_t hours, int8_t minutes)

Construct a time zone offset from hours and minutes.

This is a convenience constructor that handles the conversion from hours and minutes to the quarter-hour offset used in exess. The sign of both values must be the same. Hours can be from -14 to 14 inclusive, and minutes can only be -45, -30, -15, 0, 15, 30, or 45.

Returns:

A time zone offset in quarter hours, or EXESS_TIMEZONE_LOCAL if the parameters are invalid or not supported.