grafana / oncall

Developer-friendly incident response with brilliant Slack integration
GNU Affero General Public License v3.0
3.38k stars 262 forks source link

mobile app doesn't render timezones with non-hourly offsets properly + inconsistency #2750

Closed Dieterbe closed 11 months ago

Dieterbe commented 12 months ago

What went wrong?

alert group page uses 'UTC+${latestAlertAt.dateTime.timeZoneOffset.inHours}',

chronological shift view uses:

    final tzOffset = clock.now().timeZoneOffset.inHours;
        'UTC ${tzOffset >= 0 ? '+' : '-'}${tzOffset.abs()}',

I see 3 issues here:

1) it's inconsistent wrt the spacing between UTC and the +- 2) first version renders negative offsets incorrectly 3) both versions will round offsets that are not hourly. (for examples of such timezones, go to https://en.wikipedia.org/wiki/List_of_tz_database_time_zones and search for ':30')

I was trying to write a test case for this using https://pub.dev/packages/timezone (note: already a transitive depedency) but couldn't get it to work.

For zero offsets, I'm also not sure if 'UTC+0' is all that useful, might be better to just say 'UTC' in this case (unlike GMT, UTC is not a timezone, so users shouldn't mistakenly interpret this to mean that "their timezone is UTC", only that it's equivalent)

How do we reproduce it?

see above

Grafana OnCall Version

latest app

Product Area

Mobile App

Grafana OnCall Platform?

None

User's Browser?

No response

Anything else to add?

no

Dieterbe commented 12 months ago

omg that wikipedia shows a bunch of other interesting timezones with various minute and even second offsets!

90°W to 0°
−06:00−05:00−04:30−04:00−03:30−03:00−02:30−02:00−01:00−00:44−00:25:21 0° to 90°E
+00:00+00:20+00:30+01:00+01:24+01:30+02:00+02:30+03:00+03:30+04:00+04:30+04:51+05:00+05:30+05:40+05:45

image

Dieterbe commented 11 months ago

@raphael-batte any idea how this is handled in grafana or in our other products? any code i could copy?