libiso8601
0.3.14
|
Enumerations | |
enum | iso8601_date_prec { iso8601_prec_year, iso8601_prec_month, iso8601_prec_day, iso8601_prec_ord, iso8601_prec_week, iso8601_prec_wday } |
Date (day portion) precision.This enumeration will record how precisely the date was specified, as well as the format in use. It allows the library to determine the earliest and latest dates that could possibly be represented with the given input and also allows the output format to match the input format. More... | |
enum | iso8601_time_prec { iso8601_prec_none, iso8601_prec_hour, iso8601_prec_min, iso8601_prec_sec, iso8601_prec_hourfrac, iso8601_prec_minfrac, iso8601_prec_secfrac } |
Time precision.This enumeration records how precisely the time was specified as well as its format. The fractional format will record whether it was the hour, minute or second that was specified with a fractional part, allowing a processed date/time to be presented to the user in the format it was originally encountered. More... | |
Functions | |
int | iso8601_parse (const char *str, struct iso8601_date *earliest, struct iso8601_date *latest, struct iso8601_details *details) |
Parse ISO8601 date/time. More... | |
char * | iso8601_print (char *str, int amt, const struct iso8601_date *date, const struct iso8601_details *details) |
Print ISO8601 date/time into string. More... | |
int | iso8601_invalid (const struct iso8601_date *date) |
Validate ISO8601 date/time. More... | |
These routines are used for parsing an ISO8601 date/time string into the internal structure used to represent them, and for validating such dates/times.
enum iso8601_date_prec |
Date (day portion) precision.This enumeration will record how precisely the date was specified, as well as the format in use. It allows the library to determine the earliest and latest dates that could possibly be represented with the given input and also allows the output format to match the input format.
enum iso8601_time_prec |
Time precision.This enumeration records how precisely the time was specified as well as its format. The fractional format will record whether it was the hour, minute or second that was specified with a fractional part, allowing a processed date/time to be presented to the user in the format it was originally encountered.
int iso8601_parse | ( | const char * | str, |
struct iso8601_date * | earliest, | ||
struct iso8601_date * | latest, | ||
struct iso8601_details * | details | ||
) |
Parse ISO8601 date/time.
str | The input string. Whitespace will be stripped. | |
[out] | earliest | The earliest possible time the string could represent. May be 0. |
[out] | latest | The latest possible time the string could represent. May be 0. |
[out] | details | Stores details such as the precision to which the time/date were specified. May be 0. |
-1 | on error. |
0 | on success. |
Parses a string containing the ISO8601 date/time. Deals with any format of date, optionally storing the details in details. The time may be partial, in which case this function returns the earliest and latest times that could possibly be represented by the string.
Note that this function will accept leap seconds (23:59:60) on days on which they occurred.
char* iso8601_print | ( | char * | str, |
int | amt, | ||
const struct iso8601_date * | date, | ||
const struct iso8601_details * | details | ||
) |
Print ISO8601 date/time into string.
str | Pointer to buffer into which result is written. |
amt | Number of bytes in str. |
date | Date to print. |
details | Formatting details (may be 0). |
Formats and prints an ISO8601 date, optionally using the details in details. Will always return a null-terminated result, even if that means truncating the output to fit the buffer.
int iso8601_invalid | ( | const struct iso8601_date * | date | ) |
Validate ISO8601 date/time.
date | The date to validate. |
-1 | if not valid. |
0 | if valid. |
Checks the details of date to ensure that they are sensible. This involves checking that sec is in the range 0 to 86399 (or 86400 if there is a leap second), and that nsec is in the range 0 to 999999999.