Format timestamp
[lttngtop.git] / src / cursesdisplay.c
index 2262d41db4fc6e9cc1edc94ed73f56f7dca1a83b..e4565ede33708d4410842062d86c6f0a7fe87d78 100644 (file)
@@ -261,20 +261,42 @@ void basic_header()
        wrefresh(header);
 }
 
+struct tm format_timestamp(uint64_t timestamp)
+{
+       struct tm tm;
+       uint64_t ts_sec = 0, ts_nsec;
+       time_t time_s;
+
+       ts_nsec = timestamp;
+       ts_sec += ts_nsec / NSEC_PER_SEC;
+       ts_nsec = ts_nsec % NSEC_PER_SEC;
+
+       time_s = (time_t) ts_sec;
+
+       localtime_r(&time_s, &tm);
+
+       return tm;
+}
+
 void update_header()
 {
+       struct tm start, end;
+       uint64_t ts_nsec_start, ts_nsec_end;
+
+       ts_nsec_start = data->start % NSEC_PER_SEC;
+       start = format_timestamp(data->start);
+
+       ts_nsec_end = data->end % NSEC_PER_SEC;
+       end = format_timestamp(data->end);
+
        werase(header);
        box(header, 0 , 0);
        set_window_title(header, "Statistics for interval ");
        wattron(header, A_BOLD);
-       /*
-       wprintw(header, "[%lu.%lu, %lu.%lu[",
-                       data->start.tv_sec, data->start.tv_nsec,
-                       data->end.tv_sec, data->end.tv_nsec);
-                       */
-       wprintw(header, "[%lu, %lu[",
-            data->start,
-            data->end);
+
+       wprintw(header, "[%02d:%02d:%02d.%09" PRIu64 ", %02d:%02d:%02d.%09" PRIu64 "[",
+               start.tm_hour, start.tm_min, start.tm_sec, ts_nsec_start,
+               end.tm_hour, end.tm_min, end.tm_sec, ts_nsec_end);
        mvwprintw(header, 1, 4, "CPUs");
        wattroff(header, A_BOLD);
        wprintw(header, "\t%d\t(max/cpu : %0.2f%)", data->cpu_table->len,
@@ -505,7 +527,7 @@ void update_perf()
 
        g_ptr_array_sort_with_data(data->process_table, sort_perf, perf_key);
 
-       for (i = 0; i < data->process_table->len && 
+       for (i = 0; i < data->process_table->len &&
                        nblinedisplayed < max_center_lines; i++) {
                tmp = g_ptr_array_index(data->process_table, i);
 
@@ -722,7 +744,7 @@ void update_perf_panel(int line_selected, int toggle_view, int toggle_sort)
                        wattron(perf_panel_window, A_BOLD);
                mvwprintw(perf_panel_window, i + 1, 1, "[%c] %s",
                                perf->visible == 1 ? 'x' : ' ',
-                               (char *) perflist->data + 6);
+                               (char *) perflist->data + 5);
                wattroff(perf_panel_window, A_BOLD);
                wattroff(perf_panel_window, COLOR_PAIR(5));
                i++;
This page took 0.022961 seconds and 4 git commands to generate.