From a8df4be70c629536b36548c4cd932b53a1fac0cf Mon Sep 17 00:00:00 2001 From: rpm-build Date: Jan 15 2021 06:11:28 +0000 Subject: 0001-environment-reduce-calls-to-g_time_zone_new_local.patch patch_name: 0001-environment-reduce-calls-to-g_time_zone_new_local.patch present_in_specfile: true location_in_specfile: 40 --- diff --git a/js/ui/environment.js b/js/ui/environment.js index e22ec74..f3f2d17 100644 --- a/js/ui/environment.js +++ b/js/ui/environment.js @@ -11,6 +11,9 @@ imports.gi.versions.TelepathyLogger = '0.2'; const { Clutter, GLib, Shell, St } = imports.gi; const Gettext = imports.gettext; +const System = imports.system; + +let _localTimeZone = null; // We can't import shell JS modules yet, because they may have // variable initializations, etc, that depend on init() already having @@ -110,9 +113,26 @@ function init() { } }; + // Override to clear our own timezone cache as well + const origClearDateCaches = System.clearDateCaches; + System.clearDateCaches = function () { + _localTimeZone = null; + origClearDateCaches(); + }; + // Work around https://bugzilla.mozilla.org/show_bug.cgi?id=508783 Date.prototype.toLocaleFormat = function(format) { - return Shell.util_format_date(format, this.getTime()); + if (_localTimeZone === null) + _localTimeZone = GLib.TimeZone.new_local(); + + let dt = GLib.DateTime.new(_localTimeZone, + this.getYear(), + this.getMonth() + 1, + this.getDate(), + this.getHours(), + this.getMinutes(), + this.getSeconds()); + return dt ? dt.format(format) : ''; }; let slowdownEnv = GLib.getenv('GNOME_SHELL_SLOWDOWN_FACTOR');