| 160 | } |
| 161 | |
| 162 | static void |
| 163 | display(char const *format, time_t now) |
| 164 | { |
| 165 | struct tm *tmp; |
| 166 | |
| 167 | tmp = localtime(&now); |
| 168 | if (!tmp) { |
| 169 | fprintf(stderr, |
| 170 | _("date: error: time out of range\n")); |
| 171 | errensure(); |
| 172 | return; |
| 173 | } |
| 174 | timeout(stdout, format, tmp); |
| 175 | putchar('\n'); |
| 176 | fflush(stdout); |
| 177 | fflush(stderr); |
| 178 | if (ferror(stdout) || ferror(stderr)) { |
| 179 | fprintf(stderr, |
| 180 | _("date: error: couldn't write results\n")); |
| 181 | errensure(); |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | static void |
| 186 | timeout(FILE *fp, char const *format, struct tm const *tmp) |