Change default timestamp format to %X

This respects the user's locale settings.
master
C. McEnroe 2021-01-27 14:18:20 -05:00
parent c118c594e3
commit d6ff9e53cf
3 changed files with 14 additions and 17 deletions

View File

@ -188,7 +188,7 @@ in the specified
.Xr strftime 3
.Ar format .
The default format is
.Qq \&%T .
.Qq \&%X .
.
.It Fl a Ar user : Ns Ar pass , Cm sasl-plain = Ar user : Ns Ar pass
Authenticate as

15
chat.c
View File

@ -125,16 +125,6 @@ static void parseHash(char *str) {
if (*str) hashBound = strtoul(&str[1], NULL, 0);
}
static void parseTimestamp(const char *format) {
uiTime.enable = true;
if (!format) return;
char buf[TimeCap];
uiTime.format = format;
struct tm *time = localtime(&(time_t) { -22100400 });
uiTime.width = strftime(buf, sizeof(buf), format, time);
if (!uiTime.width) errx(EX_USAGE, "invalid timestamp format: %s", format);
}
#ifdef __OpenBSD__
static void unveilConfig(const char *name) {
@ -246,7 +236,10 @@ int main(int argc, char *argv[]) {
break; case 'O': utilPush(&urlOpenUtil, optarg);
break; case 'R': self.restricted = true;
break; case 'S': bind = optarg;
break; case 'T': parseTimestamp(optarg);
break; case 'T': {
uiTime.enable = true;
if (optarg) uiTime.format = optarg;
}
break; case 'a': sasl = true; self.plain = optarg;
break; case 'c': cert = optarg;
break; case 'e': sasl = true;

14
ui.c
View File

@ -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();