[gnome-shell] dateMenu: Show minutes for timezones that have minutes offset



commit 6893fc381064573cb1e628d26e37ae94a96a0628
Author: Jonas Dreßler <verdre v0yd nl>
Date:   Thu Mar 19 20:53:19 2020 +0100

    dateMenu: Show minutes for timezones that have minutes offset
    
    Some timezones, like the one of Kathmandu don't only have hour-based
    timezone offsets, but their timezones are also offset by minutes. So
    instead of showing weird values like "+5.8", show the minutes properly
    in a format like "+5:45".
    
    Fixes https://gitlab.gnome.org/GNOME/gnome-shell/issues/2438

 js/ui/dateMenu.js | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/js/ui/dateMenu.js b/js/ui/dateMenu.js
index 14a0ef48d6..a10c6fcf46 100644
--- a/js/ui/dateMenu.js
+++ b/js/ui/dateMenu.js
@@ -182,14 +182,19 @@ class WorldClocksSection extends St.Button {
 
             const utcOffset = this._getTimeAtLocation(l).get_utc_offset();
             const offsetCurrentTz = utcOffset - localOffset;
-            const offsetHours = offsetCurrentTz / GLib.TIME_SPAN_HOUR;
+            const offsetHours = Math.abs(offsetCurrentTz) / GLib.TIME_SPAN_HOUR;
+            const offsetMinutes =
+                (Math.abs(offsetCurrentTz) % GLib.TIME_SPAN_HOUR) /
+                GLib.TIME_SPAN_MINUTE;
 
-            const fmt = Math.trunc(offsetHours) == offsetHours ? '%s%.0f' : '%s%.1f';
             const prefix = offsetCurrentTz >= 0 ? '+' : '-';
+            const text = offsetMinutes === 0
+                ? '%s%d'.format(prefix, offsetHours)
+                : '%s%d\u2236%d'.format(prefix, offsetHours, offsetMinutes);
 
             const tz = new St.Label({
                 style_class: 'world-clocks-timezone',
-                text: fmt.format(prefix, Math.abs(offsetHours)),
+                text,
                 x_align: Clutter.ActorAlign.END,
                 y_align: Clutter.ActorAlign.CENTER,
             });


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]