Skip to content

Commit

Permalink
Add real time and use for display and file
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruno Randolf committed Jul 12, 2017
1 parent 874929e commit a674e84
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions display.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ static void update_menu(void)
wattroff(stdscr, BLACKONWHITE);

update_mini_status();
update_clock(&time_mono.tv_sec);
update_clock(&time_real.tv_sec);
}

/******************* WINDOW MANAGEMENT / UPDATE *******************/
Expand Down Expand Up @@ -306,7 +306,7 @@ void update_display_clock(void)
{
/* helper to update just the clock every second */
if (time_mono.tv_sec > time_mono.tv_sec) {
update_clock(&time_mono.tv_sec);
update_clock(&time_real.tv_sec);
doupdate();
}
}
Expand Down Expand Up @@ -339,7 +339,7 @@ void update_display(struct packet_info* pkt)

/* update clock every second */
if (time_mono.tv_sec > time_mono.tv_sec)
update_clock(&time_mono.tv_sec);
update_clock(&time_real.tv_sec);

last_time = time_mono;

Expand Down
5 changes: 4 additions & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ struct node_names_info node_names;
struct config conf;

struct timespec time_mono;
struct timespec time_real;

int mon; /* monitoring socket */

Expand Down Expand Up @@ -214,7 +215,7 @@ static void write_to_file(struct packet_info* p)
{
char buf[40];
int i;
struct tm* ltm = localtime(&time_mono.tv_sec);
struct tm* ltm = localtime(&time_real.tv_sec);

//timestamp, e.g. 2015-05-16 15:05:44.338806 +0300
i = strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", ltm);
Expand Down Expand Up @@ -725,6 +726,8 @@ int main(int argc, char** argv)
exit(1);

clock_gettime(CLOCK_MONOTONIC, &time_mono);
clock_gettime(CLOCK_REALTIME, &time_real);

node_timeout();

if (conf.serveraddr[0] == '\0') { /* server */
Expand Down
1 change: 1 addition & 0 deletions main.h
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ struct config {
extern struct config conf;

extern struct timespec time_mono;
extern struct timespec time_real;

void free_lists(void);
void init_spectrum(void);
Expand Down

0 comments on commit a674e84

Please sign in to comment.