diff options
author | C. McEnroe | 2021-01-27 14:18:20 -0500 |
---|---|---|
committer | C. McEnroe | 2021-01-27 14:18:20 -0500 |
commit | d6ff9e53cf724460b6f827edf40d698d35ffa2f7 (patch) | |
tree | f54e194740a4600a3ac6ea3966e58a76adf1f0fb /ui.c | |
parent | c118c594e3689bac3c6a083ecc05c1866e65927c (diff) |
Change default timestamp format to %X
This respects the user's locale settings.
Diffstat (limited to 'ui.c')
-rw-r--r-- | ui.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/ui.c b/ui.c index 5997571..da40dc0 100644 --- a/ui.c +++ b/ui.c @@ -69,11 +69,6 @@ enum { #define RIGHT (COLS - 1) #define MAIN_LINES (LINES - StatusLines - InputLines) -struct Time uiTime = { - .format = "%T", - .width = 8, -}; - static WINDOW *status; static WINDOW *main; static WINDOW *input; @@ -232,6 +227,8 @@ static const char *ExitFocusMode = "\33[?1004l"; static const char *EnterPasteMode = "\33[?2004h"; static const char *ExitPasteMode = "\33[?2004l"; +struct Time uiTime = { .format = "%X" }; + static void errExit(void) { putp(ExitFocusMode); putp(ExitPasteMode); @@ -239,6 +236,13 @@ static void errExit(void) { } void uiInitEarly(void) { + char buf[TimeCap]; + struct tm *time = localtime(&(time_t) { -22100400 }); + uiTime.width = strftime(buf, sizeof(buf), uiTime.format, time); + if (!uiTime.width) { + errx(EX_CONFIG, "invalid timestamp format: %s", uiTime.format); + } + initscr(); cbreak(); noecho(); |