libiso8601
provides a C API for parsing and
manipulating ISO8601
times/dates. Each time/date object is specified to the nearest
nanosecond. Parsed times which are specified to less accuracy give a
start/end time and the parser can also record the original accuracy
and format for later reproduction after manipulation.
This library currently only has time/date parsing and printing, and some simple manipulation functions (it does allow parsing of basic or extended format ISO dates in ISO week, ordinal or calendar varieties). In particular it does not deal with recurring times. This is reflected in its low version number.
Note that libiso8601
has full leap second support. Leap
seconds cannot be computed in advance, so it is necessary to signal
new leap seconds to running applications somehow. The library has a
function, iso8601_leap_table_load()
, which can update the
table of leap seconds from a disk file. See the leaptable-compiler project for more
information. It might be sensible to design applications to try to
load this file from disk every few days, with a weekly or monthly cron
job to download the table of leap seconds.
You can download the latest version by cloning the git repository:
git clone git://git.lwithers.me.uk/libiso8601
Version | Date | Source | GPG Signature (key) | Documentation | Doc Signature | Dependencies |
---|---|---|---|---|---|---|
0.3.15 | 2012-06-12 | .tar.bz2 | .tar.bz2.asc | .tar.bz2 | .tar.bz2.asc | |
0.3.14 | 2013-04-05 | .tar.bz2 | .tar.bz2.asc | .tar.bz2 | .tar.bz2.asc |
Older releases may be found here.
date_prec
and
time_prec
in the header file.extern "C" { }
for C++ users.nonnull
attribute was removed from iso8601_leap_table_load()
.time_t
etc. values from
the C library to the libiso8601 conversion routines would result in invalid
struct iso8601
members. A check for negative C library values
(i.e. pre-1970 dates) has been added and the library now copes gracefully
and correctly with them.nonnull
attribute notation on the
function iso8601_difference()
which was calling crashes within
that function if a null pointer was passed for either of the last two
parameters.
__attribute__
annotations have been added.iso8601_elapsed_div()
function, to divide one elapsed time period by
another. Computes number of complete fits plus remainder.iso8601_leap_table_load()
.iso8601_cmp()
comparison function, can be used for qsort(3)
etc.iso8601_add_elapsed()
.iso8601_print()
, when
tz_sec = 0
.iso8601_print()
.isodate
, for displaying dates in ISO8601 format.setisodate
, for setting the system clock with an ISO8601 date.struct timespec
.iso8601_set_sysclock()
function.iso8601_difference()
, for computing the elapsed time between two dates.
struct libiso8601_elapsed
, for
simple manipulations.gettimeofday()
if clock_gettime()
fails.iso8601_invalid()
).