diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -729,6 +729,10 @@ static int compare_tracked_item(const void *a, const void *b) { return list_data_a->updated_time - list_data_b->updated_time; } +static int time_diff_to_days(time_t start, time_t end) { + return (end - start) / 60LL / 60LL / 24LL; +} + static void command_cleanup(int argc, char **argv, const char *rss_config_dir, const char *html_config_dir) { time_t days = 0; const char *search_term = NULL; @@ -780,13 +784,14 @@ static void command_cleanup(int argc, char **argv, const char *rss_config_dir, c qsort(tracked_items.data, num_rss_items, sizeof(TrackedItemData), compare_tracked_item); qsort((TrackedItemData*)tracked_items.data + num_rss_items, num_tracked_items - num_rss_items, sizeof(TrackedItemData), compare_tracked_item); + time_t time_now = time(NULL); TrackedItemData *list_begin = buffer_begin(&tracked_items); TrackedItemData *list_it = list_begin; TrackedItemData *list_end = buffer_end(&tracked_items); int index = 0; for(; list_it != list_end; ++list_it) { const char *name = path_get_filename(list_it->item_tracked_path); - printf("%d %s/%s\n", 1 + index, index < num_rss_items ? "rss" : "html", name); + printf("%d (last updated: %d day(s) ago): %s/%s\n", 1 + index, (int)time_diff_to_days(list_it->updated_time, time_now), index < num_rss_items ? "rss" : "html", name); ++index; } @@ -862,6 +867,7 @@ static void command_cleanup(int argc, char **argv, const char *rss_config_dir, c continue; for(;;) { + time_now = time(NULL); size_t *tracks_to_remove_it = buffer_begin(&tracks_to_remove); size_t *tracks_to_remove_end = buffer_end(&tracks_to_remove); fprintf(stderr, "==> Are you sure you want to stop tracking:\n"); @@ -869,7 +875,7 @@ static void command_cleanup(int argc, char **argv, const char *rss_config_dir, c const size_t track_index = *tracks_to_remove_it; TrackedItemData *track_item = &list_begin[track_index]; const char *name = path_get_filename(track_item->item_tracked_path); - printf(" %s/%s\n", track_index < (size_t)num_rss_items ? "rss" : "html", name); + printf(" (last updated: %d day(s) ago): %s/%s\n", (int)time_diff_to_days(track_item->updated_time, time_now), track_index < (size_t)num_rss_items ? "rss" : "html", name); } fprintf(stderr, "==> Yes/No: "); |