| 17 | to STDOUT. */ |
| 18 | |
| 19 | extern bool |
| 20 | show_date (char const *format, struct timespec when, timezone_t tz) |
| 21 | { |
| 22 | struct tm tm; |
| 23 | |
| 24 | if (!localtime_rz (tz, &when.tv_sec, &tm)) |
| 25 | { |
| 26 | char buf[INT_BUFSIZE_BOUND (intmax_t)]; |
| 27 | error (0, 0, _("time %s is out of range"), |
| 28 | quote (timetostr (when.tv_sec, buf))); |
| 29 | return false; |
| 30 | } |
| 31 | |
| 32 | if (fprintftime (stdout, format, &tm, tz, when.tv_nsec) < 0) |
| 33 | { |
| 34 | if (! ferror (stdout)) /* otherwise it will be diagnosed later. */ |
| 35 | error (0, errno, _("fprintftime error")); |
| 36 | return false; |
| 37 | } |
| 38 | |
| 39 | return true; |
| 40 | } |
no test coverage detected