Merge branch 'obsd-master'

This commit is contained in:
Thomas Adam
2025-11-26 00:01:08 +00:00
3 changed files with 19 additions and 9 deletions

View File

@@ -36,7 +36,7 @@ static const char *options_table_mode_keys_list[] = {
"emacs", "vi", NULL "emacs", "vi", NULL
}; };
static const char *options_table_clock_mode_style_list[] = { static const char *options_table_clock_mode_style_list[] = {
"12", "24", NULL "12", "24", "12-with-seconds", "24-with-seconds", NULL
}; };
static const char *options_table_status_list[] = { static const char *options_table_status_list[] = {
"off", "on", "2", "3", "4", "5", NULL "off", "on", "2", "3", "4", "5", NULL

2
tmux.1
View File

@@ -4927,7 +4927,7 @@ option is enabled.
Set clock colour. Set clock colour.
.Pp .Pp
.It Xo Ic clock-mode-style .It Xo Ic clock-mode-style
.Op Ic 12 | 24 .Op Ic 12 | 24 | 12-with-seconds | 24-with-seconds
.Xc .Xc
Set clock hour format. Set clock hour format.
.Pp .Pp

View File

@@ -142,7 +142,7 @@ window_clock_timer_callback(__unused int fd, __unused short events, void *arg)
t = time(NULL); t = time(NULL);
gmtime_r(&t, &now); gmtime_r(&t, &now);
gmtime_r(&data->tim, &then); gmtime_r(&data->tim, &then);
if (now.tm_min == then.tm_min) if (now.tm_sec == then.tm_sec)
return; return;
data->tim = t; data->tim = t;
@@ -212,6 +212,7 @@ window_clock_draw_screen(struct window_mode_entry *wme)
struct screen *s = &data->screen; struct screen *s = &data->screen;
struct grid_cell gc; struct grid_cell gc;
char tim[64], *ptr; char tim[64], *ptr;
const char *timeformat;
time_t t; time_t t;
struct tm *tm; struct tm *tm;
u_int i, j, x, y, idx; u_int i, j, x, y, idx;
@@ -223,14 +224,23 @@ window_clock_draw_screen(struct window_mode_entry *wme)
t = time(NULL); t = time(NULL);
tm = localtime(&t); tm = localtime(&t);
if (style == 0) { if (style == 0 || style == 2) {
strftime(tim, sizeof tim, "%l:%M ", localtime(&t)); if (style == 2)
timeformat = "%l:%M:%S ";
else
timeformat = "%l:%M ";
strftime(tim, sizeof tim, timeformat, localtime(&t));
if (tm->tm_hour >= 12) if (tm->tm_hour >= 12)
strlcat(tim, "PM", sizeof tim); strlcat(tim, "PM", sizeof tim);
else else
strlcat(tim, "AM", sizeof tim); strlcat(tim, "AM", sizeof tim);
} else } else {
strftime(tim, sizeof tim, "%H:%M", tm); if (style == 3)
timeformat = "%H:%M:%S";
else
timeformat = "%H:%M";
strftime(tim, sizeof tim, timeformat, tm);
}
screen_write_clearscreen(&ctx, 8); screen_write_clearscreen(&ctx, 8);