add test for timestamp millisec
This commit is contained in:
parent
bf0447ab49
commit
45921ae3db
3 changed files with 22 additions and 28 deletions
|
@ -1,5 +1,5 @@
|
||||||
odt1 = 1979-05-27T07:32:00Z
|
odt1 = 1979-05-27T07:32:00Z
|
||||||
odt2 = 1979-05-27T00:32:00-07:00
|
odt2 = 1979-05-27T00:32:00-07:00
|
||||||
odt3 = 1979-05-27T00:32:00.999999-07:00
|
odt3 = 1979-05-27T00:32:00.999999-07:00
|
||||||
odt4 = 1979-05-27T00:32:00.1-07:00
|
odt4 = 1979-05-27T00:32:00.01-07:00
|
||||||
|
|
||||||
|
|
|
@ -2,5 +2,5 @@
|
||||||
odt1 = 1979-05-27T07:32:00Z,
|
odt1 = 1979-05-27T07:32:00Z,
|
||||||
odt2 = 1979-05-27T00:32:00-07:00,
|
odt2 = 1979-05-27T00:32:00-07:00,
|
||||||
odt3 = 1979-05-27T00:32:00.999-07:00,
|
odt3 = 1979-05-27T00:32:00.999-07:00,
|
||||||
odt4 = 1979-05-27T00:32:00.100-07:00,
|
odt4 = 1979-05-27T00:32:00.010-07:00,
|
||||||
}
|
}
|
||||||
|
|
46
toml_cat.c
46
toml_cat.c
|
@ -93,6 +93,24 @@ static void print_string(const char* s)
|
||||||
|
|
||||||
static void print_array(toml_array_t* arr);
|
static void print_array(toml_array_t* arr);
|
||||||
|
|
||||||
|
static void print_timestamp(toml_datum_t d)
|
||||||
|
{
|
||||||
|
if (d.u.ts->year) {
|
||||||
|
printf("%04d-%02d-%02d%s", *d.u.ts->year, *d.u.ts->month, *d.u.ts->day,
|
||||||
|
d.u.ts->hour ? "T" : "");
|
||||||
|
}
|
||||||
|
if (d.u.ts->hour) {
|
||||||
|
printf("%02d:%02d:%02d", *d.u.ts->hour, *d.u.ts->minute, *d.u.ts->second);
|
||||||
|
if (d.u.ts->millisec) {
|
||||||
|
printf(".%03d", *d.u.ts->millisec);
|
||||||
|
}
|
||||||
|
if (d.u.ts->z) {
|
||||||
|
printf("%s", d.u.ts->z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void print_table(toml_table_t* curtab)
|
static void print_table(toml_table_t* curtab)
|
||||||
{
|
{
|
||||||
|
@ -165,19 +183,7 @@ static void print_table(toml_table_t* curtab)
|
||||||
if (d.ok) {
|
if (d.ok) {
|
||||||
prindent();
|
prindent();
|
||||||
printf("%s = ", key);
|
printf("%s = ", key);
|
||||||
if (d.u.ts->year) {
|
print_timestamp(d);
|
||||||
printf("%04d-%02d-%02d%s", *d.u.ts->year, *d.u.ts->month, *d.u.ts->day,
|
|
||||||
d.u.ts->hour ? "T" : "");
|
|
||||||
}
|
|
||||||
if (d.u.ts->hour) {
|
|
||||||
printf("%02d:%02d:%02d", *d.u.ts->hour, *d.u.ts->minute, *d.u.ts->second);
|
|
||||||
if (d.u.ts->millisec) {
|
|
||||||
printf(".%d", *d.u.ts->millisec);
|
|
||||||
}
|
|
||||||
if (d.u.ts->z) {
|
|
||||||
printf("%s", d.u.ts->z);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
printf(",\n");
|
printf(",\n");
|
||||||
free(d.u.ts);
|
free(d.u.ts);
|
||||||
continue;
|
continue;
|
||||||
|
@ -254,19 +260,7 @@ static void print_array(toml_array_t* curarr)
|
||||||
d = toml_timestamp_at(curarr, i);
|
d = toml_timestamp_at(curarr, i);
|
||||||
if (d.ok) {
|
if (d.ok) {
|
||||||
prindent();
|
prindent();
|
||||||
if (d.u.ts->year) {
|
print_timestamp(d);
|
||||||
printf("%04d-%02d-%02d%s", *d.u.ts->year, *d.u.ts->month, *d.u.ts->day,
|
|
||||||
d.u.ts->hour ? "T" : "");
|
|
||||||
}
|
|
||||||
if (d.u.ts->hour) {
|
|
||||||
printf("%02d:%02d:%02d", *d.u.ts->hour, *d.u.ts->minute, *d.u.ts->second);
|
|
||||||
if (d.u.ts->millisec) {
|
|
||||||
printf(".%d", *d.u.ts->millisec);
|
|
||||||
}
|
|
||||||
if (d.u.ts->z) {
|
|
||||||
printf("%s", d.u.ts->z);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
printf(",\n");
|
printf(",\n");
|
||||||
free(d.u.ts);
|
free(d.u.ts);
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in a new issue