#define _DEFAULT_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <strings.h>
#include <sys/time.h>
#include <errno.h>
#include <time.h>
#include "config.h"
#ifdef LOCALE
#include <locale.h>
#endif
int
main(void)
{
char buf[129];
time_t tim;
struct tm *timtm;
#ifdef LOCALE
setlocale(LC_TIME, LOCALE);
#endif
#ifdef TIMEZONE
setenv("TZ", TIMEZONE, 1);
#endif
while (1) {
bzero(buf, sizeof(buf));
tim = time(NULL);
timtm = localtime(&tim);
if (timtm == NULL) {
perror("localtime");
exit(1);
}
if (!strftime(buf, sizeof(buf)-1, TIMEFORMAT, timtm)) {
fprintf(stderr, "strftime == 0\n");
exit(1);
}
printf("%s\n", buf);
fflush(stdout);
sleep(UPDATE_PERIOD);
}
}