2 * Print time_t and nanoseconds in symbolic format.
4 * Copyright (c) 2015-2017 Dmitry V. Levin <ldv@altlinux.org>
7 * SPDX-License-Identifier: GPL-2.0-or-later
15 print_time_t_ex(const time_t t, const unsigned long long part_sec,
16 const unsigned int max_part_sec, const int width,
20 if ((!t && !part_sec) || part_sec > max_part_sec)
23 const struct tm *const p = localtime(&t);
25 if (!p || !strftime(buf, sizeof(buf), "%FT%T", p))
29 fputs(" /* ", stdout);
34 printf(".%0*llu", width, part_sec);
36 if (strftime(buf, sizeof(buf), "%z", p))
44 print_time_t_nsec(const time_t t, const unsigned long long nsec, int comment)
46 print_time_t_ex(t, nsec, 999999999, 9, comment);
50 print_time_t_usec(const time_t t, const unsigned long long usec, int comment)
52 print_time_t_ex(t, usec, 999999, 6, comment);