Add iso8601 when setting a time format

Instead of manually typing the format-string, one can now simply use
`iso8601`.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
This commit is contained in:
Steffen Jaeckel
2025-04-01 12:19:47 +02:00
parent 9c2b3f6579
commit 3bf72210e1
2 changed files with 18 additions and 3 deletions

View File

@@ -5326,7 +5326,20 @@ cmd_time(ProfWin* window, const char* const command, gchar** args)
auto_gchar gchar* format = prefs_get_string(tp->pref);
cons_show("%s time format: '%s'.", tp->description, format);
} else if (g_strcmp0(args[1], "set") == 0 && args[2] != NULL) {
prefs_set_string(tp->pref, args[2]);
const struct format_strings
{
const char *name, *format;
} format_strings[] = {
{ .name = "iso8601", .format = "%Y-%m-%dT%H:%M:%S" },
};
const gchar* set_arg = args[2];
for (size_t m = 0; m < ARRAY_SIZE(format_strings); ++m) {
if (g_strcmp0(args[2], format_strings[m].name) == 0) {
set_arg = format_strings[m].format;
break;
}
}
prefs_set_string(tp->pref, set_arg);
cons_show("%s time format set to '%s'.", tp->description, args[2]);
redraw = TRUE;
} else if (g_strcmp0(args[1], "off") == 0) {