diff options
author | Gary E. Miller <gem@rellim.com> | 2015-02-05 00:32:10 -0800 |
---|---|---|
committer | Gary E. Miller <gem@rellim.com> | 2015-02-05 00:32:10 -0800 |
commit | 718db4342bb85570afba727886fff0b3311b2ff2 (patch) | |
tree | 4671d4cdac5ac66779c4fc24013541d73cecb3b3 /monitor_ubx.c | |
parent | a3a9587f80da3daccf1e830fb24096c0badd30d5 (diff) | |
download | gpsd-718db4342bb85570afba727886fff0b3311b2ff2.tar.gz |
Add function timespec_str(), and use it.
Converting a timespec to a printable string is odd, so
placed in a new function for ease of use.
Diffstat (limited to 'monitor_ubx.c')
-rw-r--r-- | monitor_ubx.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/monitor_ubx.c b/monitor_ubx.c index 2256d9e3..4fdfb58a 100644 --- a/monitor_ubx.c +++ b/monitor_ubx.c @@ -260,20 +260,15 @@ static void ubx_update(void) if (pps_thread_lastpps(&session, &drift) > 0) { /* NOTE: can not use double here due to precision requirements */ struct timespec timedelta; - char sign = ' '; + char buf[22]; TS_SUB( &timedelta, &drift.clock, &drift.real); if ( 86400 < (long)labs(timedelta.tv_sec) ) { /* more than one day off, overflow */ /* need a bigger field to show it */ (void)mvwprintw(ppswin, 1, 13, "> 1 day"); } else { - if ( (0 > timedelta.tv_nsec ) || ( 0 > timedelta.tv_sec ) ) { - sign = '-'; - } - (void)mvwprintw(ppswin, 1, 13, "%c%ld.%09ld", - sign, - (long)labs(timedelta.tv_sec), - (long)labs(timedelta.tv_nsec)); + (void)timespec_str( &timedelta, buf, sizeof(buf) ); + (void)mvwprintw(ppswin, 1, 13, "%s", buf); } (void)wnoutrefresh(ppswin); } |