]> Sergey Matveev's repositories - nnn.git/commitdiff
Use printw() to print time
authorArun Prakash Jana <engineerarun@gmail.com>
Wed, 7 Apr 2021 21:43:43 +0000 (03:13 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Wed, 7 Apr 2021 21:43:43 +0000 (03:13 +0530)
src/nnn.c

index faeb6c48edeeaa17dc1de3ee60f71ab1a0d27b2d..cbfcfdf8a066ab8333aab90ee278b41fb1670142 100644 (file)
--- 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);