From 1453f46fcf325ba0116548d996f8d19f1b382782 Mon Sep 17 00:00:00 2001 From: Ailin Nemui Date: Sun, 18 Dec 2022 16:34:15 +0100 Subject: [PATCH] add timezone to g_date_time_new_from_iso8601 call --- src/fe-common/core/fe-log.c | 5 ++++- src/fe-text/textbuffer-formats.c | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/fe-common/core/fe-log.c b/src/fe-common/core/fe-log.c index 984b3548..25dc025c 100644 --- a/src/fe-common/core/fe-log.c +++ b/src/fe-common/core/fe-log.c @@ -57,6 +57,7 @@ static int skip_next_printtext; static char *log_theme_name; static char **autolog_ignore_targets; +static GTimeZone *utc; static char *log_colorizer_strip(const char *str) { @@ -542,7 +543,7 @@ static void log_line(TEXT_DEST_REC *dest, const char *text) char *val; if ((val = g_hash_table_lookup(dest->meta, "time")) != NULL) { GDateTime *time; - if ((time = g_date_time_new_from_iso8601(val, NULL)) != NULL) { + if ((time = g_date_time_new_from_iso8601(val, utc)) != NULL) { t = g_date_time_to_unix(time); g_date_time_unref(time); } @@ -744,6 +745,7 @@ void fe_log_init(void) { autoremove_tag = g_timeout_add(60000, (GSourceFunc) sig_autoremove, NULL); skip_next_printtext = FALSE; + utc = g_time_zone_new_utc(); settings_add_bool("log", "awaylog_colors", TRUE); settings_add_bool("log", "autolog", FALSE); @@ -811,6 +813,7 @@ void fe_log_deinit(void) if (autolog_ignore_targets != NULL) g_strfreev(autolog_ignore_targets); + g_time_zone_unref(utc); g_free_not_null(autolog_path); g_free_not_null(log_theme_name); } diff --git a/src/fe-text/textbuffer-formats.c b/src/fe-text/textbuffer-formats.c index 50d6250a..1de8c120 100644 --- a/src/fe-text/textbuffer-formats.c +++ b/src/fe-text/textbuffer-formats.c @@ -18,6 +18,7 @@ TEXT_BUFFER_REC *color_buf; gboolean scrollback_format; gboolean show_server_time; int signal_gui_render_line_text; +GTimeZone *utc; static void collector_free(GSList **collector) { @@ -125,7 +126,7 @@ static LINE_INFO_META_REC *line_meta_create(GHashTable *meta_hash) while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &val)) { if (g_strcmp0("time", key) == 0) { GDateTime *time; - if ((time = g_date_time_new_from_iso8601(val, NULL)) != NULL) { + if ((time = g_date_time_new_from_iso8601(val, utc)) != NULL) { meta->server_time = g_date_time_to_unix(time); g_date_time_unref(time); } @@ -446,6 +447,7 @@ static void read_settings(void) void textbuffer_formats_init(void) { signal_gui_render_line_text = signal_get_uniq_id("gui render line text"); + utc = g_time_zone_new_utc(); settings_add_bool("lookandfeel", "scrollback_format", TRUE); settings_add_bool("lookandfeel", "show_server_time", FALSE); @@ -463,4 +465,6 @@ void textbuffer_formats_deinit(void) signal_remove("print format", (SIGNAL_FUNC) sig_print_format); signal_remove("print noformat", (SIGNAL_FUNC) sig_print_noformat); signal_remove("gui print text finished", (SIGNAL_FUNC) sig_gui_print_text_finished); + + g_time_zone_unref(utc); }