From d6b85291ea87b018de39bd6063140d160ca7524e Mon Sep 17 00:00:00 2001 From: Stefan Ritt Date: Fri, 5 Sep 2008 07:47:38 +0000 Subject: [PATCH] Added "past-n" to display last n hours SVN revision: 2124 --- src/elogd.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/elogd.c b/src/elogd.c index 7320ac9d..5683d60d 100755 --- a/src/elogd.c +++ b/src/elogd.c @@ -19027,8 +19027,10 @@ void show_elog_list(LOGBOOK * lbs, int past_n, int last_n, int page_n, BOOL defa /*---- apply start/end date cut ----*/ - if (past_n) - ltime_start = now - 3600 * 24 * past_n; + if (past_n > 0) + ltime_start = now - 3600 * 24 * past_n; // past n days + else + ltime_start = now + 3600 * past_n; // past n hours if (last_n && last_n < n_msg) { for (i = n_msg - last_n - 1; i >= 0; i--) @@ -19595,6 +19597,8 @@ void show_elog_list(LOGBOOK * lbs, int past_n, int last_n, int page_n, BOOL defa strcat(str, loc("Last day")); else if (past_n > 1) sprintf(str + strlen(str), loc("Last %d days"), past_n); + else if (past_n < 0) + sprintf(str + strlen(str), loc("Last %d hours"), -past_n); else if (last_n) sprintf(str + strlen(str), loc("Last %d entries"), last_n); else if (page_n == -1) @@ -19662,7 +19666,7 @@ void show_elog_list(LOGBOOK * lbs, int past_n, int last_n, int page_n, BOOL defa for (i = 0; i < n; i++) { if (is_user_allowed(lbs, menu_item[i])) { if (strieq(menu_item[i], "Last x")) { - if (past_n) { + if (past_n > 0) { sprintf(str, loc("Last %d days"), past_n * 2); rsprintf(" %s |\n", past_n * 2, mode, str); } @@ -25442,8 +25446,9 @@ void interprete(char *lbook, char *path) return; } - /* check for lastxx and pastxx and listxx */ - if (strncmp(path, "past", 4) == 0 && isdigit(path[4]) && isparam("cmd") == 0) { + /* check for pastxx */ + if (strncmp(path, "past", 4) == 0 && (isdigit(path[4]) || isdigit(path[5])) + && isparam("cmd") == 0) { show_elog_list(lbs, atoi(path + 4), 0, 0, FALSE, NULL); return; }