libowfat/test/fmt_iso8691.c

15 lines
421 B
C
Raw Normal View History

2016-03-17 11:13:23 +00:00
#include "fmt.h"
#include "scan.h"
2015-05-13 20:33:51 +00:00
#include <assert.h>
#include <unistd.h>
int main() {
char buf[1024];
2015-05-13 21:21:16 +00:00
buf[fmt_iso8601(buf,1431551843)]=0; // Wed May 13 14:17:23 PDT 2015
assert(!strcmp(buf,"2015-05-13T21:17:23Z"));
struct timespec t;
assert(scan_iso8601("2015-05-13T21:17:23Z",&t)==20 && t.tv_sec==1431551843);
2015-05-13 21:42:58 +00:00
assert(scan_iso8601("2015-05-13T14:17:23-0700",&t)==24 && t.tv_sec==1431551843);
2015-05-13 20:33:51 +00:00
return 0;
}