libdata-gcf  1.1.2
Functions
Date manipulation routines

Functions

int gcf_date_decode (struct iso8601_date *iso_date, uint32_t gcf_date)
 Decode a GCF date. More...
 
int gcf_date_encode (uint32_t *gcf_date, const struct iso8601_date *iso_date)
 Encode a GCF date. More...
 

Detailed Description

A small set of routines for manipulating the dates used in GCF block headers. GCF dates are encoded into a 32-bit field, the top 15 bits of which represent the number of days elasped since 1989-11-17, and the bottom 17 bits of which represent the number of seconds elapsed that day since 00:00:00. Both ISO8601 and GCF time deal correctly with leap seconds.

Function Documentation

◆ gcf_date_decode()

int gcf_date_decode ( struct iso8601_date *  iso_date,
uint32_t  gcf_date 
)

Decode a GCF date.

Parameters
[out]iso_dateThe ISO8601 date.
gcf_dateThe date (32-bit encoded value) to decode.
Return values
0on success.
-1on error (and see gcf_errstr).

This function will decode a GCF encoded date gcf_date and store the result in iso_date, also validating it.

◆ gcf_date_encode()

int gcf_date_encode ( uint32_t *  gcf_date,
const struct iso8601_date *  iso_date 
)

Encode a GCF date.

Parameters
[out]gcf_dateThe 32-bit encoded date is written here.
iso_dateThe ISO8601 date to encode.
Return values
0on success.
-1on error (and see gcf_errstr).

This function will encode an ISO8601 date iso_date, storing the result in gcf_date. It will fail if the date in iso_date is outside the range that can be represented by GCF dates. Any nanosecond component of iso_date is ignored.