libepoch/test/dtfromtimespec.c

22 lines
459 B
C
Raw Normal View History

2024-02-09 12:14:57 -05:00
#include "epoch.h"
#include <assert.h>
#include <time.h>
int main() {
struct timespec ts;
DateTime dt;
ts.tv_nsec = 42;
ts.tv_sec = 1706571482;
dateTimeFromTimespec(&ts, &dt);
assert(dt.year.year == 2024);
assert(dt.month == January);
assert(dt.day == 29);
assert(dt.hour == 23);
assert(dt.minute == 38);
assert(dt.second == 02);
assert(dt.nanoseconds == 42);
assert(dt.zone.tag == UTC);
return 0;
}