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) {
const struct tm *const p = localtime(&t);
char buf[256];
if (p) {
char buf[256];
strftime(buf, sizeof(buf), "%FT%T%z", p);
fputs(buf, stdout);
} else {
printf("%llu", zero_extend_signed_to_ull(t));
if (!p) {
perror_msg_and_fail("localtime");
}
strftime(buf, sizeof(buf), "%FT%T%z", p);
fputs(buf, stdout);
} else {
putchar('0');
}