No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
.travis.functions
.travis.install Run clang analyzer during tests Oct 20, 2017
.travis.script
.travis.yml
LICENSE Initial commit Feb 20, 2017
README.md Add a basic README.md Oct 21, 2017
add.c Fix stray line in header Oct 21, 2017
internal.c Increase coverage in t_internal Oct 21, 2017
internal.h Add vim modeline Oct 19, 2017
iso8601.h
libiso8601.map Add iso8601_add_years() Oct 19, 2017
meson.build
misc.c Add vim modeline Oct 19, 2017
parse.c Increase coverage in t_parse Oct 21, 2017
t_add.c Add tests for addition and subtraction Oct 19, 2017
t_internal.c Increase coverage in t_internal Oct 21, 2017
t_misc.c Increase coverage in t_misc Oct 21, 2017
t_parse.c Increase coverage in t_parse Oct 21, 2017
t_unparse.c Test invalid inputs in t_unparse Oct 20, 2017
unparse.c Test invalid inputs in t_unparse Oct 20, 2017

README.md

Travis Codecov

This is a C simple library for parsing and managing ISO 8601 dates and times. It is extensively tested (check out our test coverage!) and is available under the Apache 2.0 license. We also believe that it will successfully parse all variants of the specification as well as many common non-conformant formats.

Here are the two main functions:

#include <iso8601.h>
#include <assert.h>
#include <string.h>

int main() {
    iso8601_time time = {};
    char str[128] = {};

    iso8601_parse("2010-02-14T13:14:23.123456Z", &time);

    assert(time.year == 2010);
    assert(time.month == 2);
    assert(time.day == 14);
    assert(time.hour == 13);
    assert(time.minute == 14);
    assert(time.second == 23);
    assert(time.usecond == 123456);

    iso8601_unparse(&time, ISO8601_FLAG_NONE, 4, ISO8601_FORMAT_WEEKDATE,
                    ISO8601_TRUNCATE_DAY, sizeof(str), str);

    assert(strcmp(str, "2010-W06-7") == 0);
    return 0;
}