glanceapp / glance

A self-hosted dashboard that puts all your feeds in one place
GNU Affero General Public License v3.0
8.56k stars 297 forks source link

fix: non-whole-hour timezones now correctly shown on Clock widget #248

Closed oliver-mitchell closed 3 weeks ago

oliver-mitchell commented 3 weeks ago

Problem

Certain timezones use non-whole-hour definitions, for example, Australia/ACDT - which is GMT +10:30. Due to this, if either:

  1. The user is in a whole-hour timezone (eg: CEST GMT+1), and they add a non-whole-hour timezone, or
  2. The user is in a non-whole-hour timezone (eg: ACDT GMT+10:30), and they add a whole-hour timezone,

then the relative difference between timezones is displayed within the Clock widget incorrectly, where the minutes are ignored, and only hourly differences being shown. Using the example of the user being in CEST, and requesting that ACDT be shown, only +9h will be displayed.

This is especially critical in timezones that relatively differ from each other by only 30 minutes, as the clock widget will show no difference in timezones, represented as 0h (for example, ACDT GMT+10:30 and AEDT GMT+11:00).

Solution

This fix changes how the difference is calculated to account for both minutes, and hours.

Due to the change, the text shown for relative timezone differences also had to be changed, as the previous formatting was not appropriate for showing both minutes and hours. A similar format to the original was tested, which resulted in strings such as +12h30m or +12h 30m, both of which I deemed looked a bit strange. As such, I made a formatting change to instead use a standard +-HH:MM across the board (ie: +12:30).

oliver-mitchell commented 3 weeks ago

Thanks for contributing! I see what you mean about +12h30m and +12h 30m looking odd, both looked a bit "too much". I think the diff text isn't all that important hence the deemphasized color and why I had it rounded to the hour, though I agree it is misleading for some timezones. I reverted it to how it looked initially but now if the difference is less than an hour it shows the minutes and if it's an hour and some minutes it has a ~ suffix. You can now also hover over the text to see the exact difference which should clear things up. Here's what that looks like:

image

@svilenmarkov my pedantic-nesss would looove to have the full time listed, but I appreciate the simpler format. Is this something that I could put a PR in to add a config item that would determine the formatting? I think a lot of people would also appreciate the option to have [+-]HH:MM formatting, as I do use it primarily for the diff text