tests: simplify print_time_t
* tests/print_time.c (print_time_t): Treat localtime errors as fatal.
This commit is contained in:
parent
2bba131575
commit
73a21f1a3f
@ -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');
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user