tests: simplify print_time_t

* tests/print_time.c (print_time_t): Treat localtime errors as fatal.
This commit is contained in:
Дмитрий Левин 2017-02-28 01:21:15 +00:00
parent 2bba131575
commit 73a21f1a3f

View File

@ -36,15 +36,14 @@ print_time_t_nsec(const time_t t, const unsigned long long nsec)
{ {
if (t) { if (t) {
const struct tm *const p = localtime(&t); const struct tm *const p = localtime(&t);
if (p) {
char buf[256]; char buf[256];
if (!p) {
perror_msg_and_fail("localtime");
}
strftime(buf, sizeof(buf), "%FT%T%z", p); strftime(buf, sizeof(buf), "%FT%T%z", p);
fputs(buf, stdout); fputs(buf, stdout);
} else {
printf("%llu", zero_extend_signed_to_ull(t));
}
} else { } else {
putchar('0'); putchar('0');
} }