From 903a4b3a66bb37a029906ef20b97ca68619a5310 Mon Sep 17 00:00:00 2001 From: Arun Prakash Jana Date: Thu, 8 Apr 2021 03:13:43 +0530 Subject: [PATCH] Use printw() to print time --- src/nnn.c | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/src/nnn.c b/src/nnn.c index faeb6c48..cbfcfdf8 100644 --- a/src/nnn.c +++ b/src/nnn.c @@ -3599,30 +3599,12 @@ static void print_icon(const struct entry *ent, const int attrs) } #endif -static void zeroleft(int val) -{ - if (val < 10) { - addch('0'); - addch('0' + val); - } else - addstr(xitoa(val)); -} - static void print_time(const time_t *timep) { struct tm *t = localtime(timep); - addstr(xitoa(t->tm_year + 1900)); /* YYYY-MM-DD */ - addch('-'); - zeroleft(t->tm_mon + 1); - addch('-'); - zeroleft(t->tm_mday); - - addch(' '); - - zeroleft(t->tm_hour); /* HH:MM */ - addch(':'); - zeroleft(t->tm_min); + printw("%s-%02d-%02d %02d:%02d", + xitoa(t->tm_year + 1900), t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min); } static char get_detail_ind(const mode_t mode) @@ -5556,10 +5538,7 @@ static void statusbar(char *path) tolastln(); attron(COLOR_PAIR(cfg.curctx + 1)); - addstr(xitoa(cur + 1)); - addch('/'); - addstr(xitoa(ndents)); - addch(' '); + printw("%d/%s ", cur + 1, xitoa(ndents)); if (g_state.selmode) { attron(A_REVERSE);