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:
@@ -1190,7 +1190,8 @@ static const struct cmd_t command_defs[] = {
|
|||||||
"Time formats are strings supported by g_date_time_format. "
|
"Time formats are strings supported by g_date_time_format. "
|
||||||
"See https://developer.gnome.org/glib/stable/glib-GDateTime.html#g-date-time-format for more details. "
|
"See https://developer.gnome.org/glib/stable/glib-GDateTime.html#g-date-time-format for more details. "
|
||||||
"Setting the format to an unsupported string, will display the string. "
|
"Setting the format to an unsupported string, will display the string. "
|
||||||
"If the format contains spaces, it must be surrounded with double quotes.")
|
"If the format contains spaces, it must be surrounded with double quotes. "
|
||||||
|
"It is possible to pass format as 'iso8601' in order to set the time format according to ISO-8601 (only local time, without Time zone designator).")
|
||||||
CMD_ARGS(
|
CMD_ARGS(
|
||||||
{ "console set <format>", "Set time format for console window." },
|
{ "console set <format>", "Set time format for console window." },
|
||||||
{ "console off", "Do not show time in console window." },
|
{ "console off", "Do not show time in console window." },
|
||||||
@@ -1216,7 +1217,8 @@ static const struct cmd_t command_defs[] = {
|
|||||||
"/time xml off",
|
"/time xml off",
|
||||||
"/time statusbar set %H:%M",
|
"/time statusbar set %H:%M",
|
||||||
"/time lastactivity set \"%d-%m-%y %H:%M:%S\"",
|
"/time lastactivity set \"%d-%m-%y %H:%M:%S\"",
|
||||||
"/time all set \"%d-%m-%y %H:%M:%S\"")
|
"/time all set \"%d-%m-%y %H:%M:%S\"",
|
||||||
|
"/time all set iso8601")
|
||||||
},
|
},
|
||||||
|
|
||||||
{ CMD_PREAMBLE("/inpblock",
|
{ CMD_PREAMBLE("/inpblock",
|
||||||
|
|||||||
@@ -5326,7 +5326,20 @@ cmd_time(ProfWin* window, const char* const command, gchar** args)
|
|||||||
auto_gchar gchar* format = prefs_get_string(tp->pref);
|
auto_gchar gchar* format = prefs_get_string(tp->pref);
|
||||||
cons_show("%s time format: '%s'.", tp->description, format);
|
cons_show("%s time format: '%s'.", tp->description, format);
|
||||||
} else if (g_strcmp0(args[1], "set") == 0 && args[2] != NULL) {
|
} 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]);
|
cons_show("%s time format set to '%s'.", tp->description, args[2]);
|
||||||
redraw = TRUE;
|
redraw = TRUE;
|
||||||
} else if (g_strcmp0(args[1], "off") == 0) {
|
} else if (g_strcmp0(args[1], "off") == 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user