lostcarpark / conclar

ConClár Programme Guide in ReactJS
MIT License
11 stars 12 forks source link

Timezone select #98

Closed lostcarpark closed 2 years ago

lostcarpark commented 2 years ago

This change is mainly about timezones and time handling. The biggest UI change is the addition of a Settings page. This moves the Show Local Time and 12 Hour Time off the Program page, and adds the ability to select the local timezone to display. It also completes move to Temporal API for time handling and calculations. Internally all times are stored as Temporal.ZonedDateTime. This vastly simplifies calculations such as checking if during convention. This should resolve issues #87 and #97.

mcdemarco commented 2 years ago

I ran this on the branch, where there was no default selected for the settings radio button "Show Local Time" in Chrome (101.0.4951.64 on MacOS 10.14.6). In my case, the behavior indicates it's set to "Never show" behind the scenes somewhere, but I think "Display if differs from convention time" is a better default.

Firefox opened a cached version of my previous ConClar build. When I reloaded, I did get a default setting for "Show Local Time": "Display if differs from convention time". My Firefox still displays my timezone as UTC rather than the correct one (America/New_York).

When I select the correct time zone, it appears in the selection list as (GMT-4:00) Eastern Time (EDT), but on the Programme page it instead shows as America/Detroit. Selecting the timezone manually in Chrome also changes it from America/New_York to America/Detroit. This behavior is somewhat confusing, but only when you're messing with the manual setting so probably not a major concern.

Except for the missing default setting in some situations, this all seems to be behaving as intended.

lostcarpark commented 2 years ago

I ran this on the branch, where there was no default selected for the settings radio button "Show Local Time" in Chrome (101.0.4951.64 on MacOS 10.14.6). In my case, the behavior indicates it's set to "Never show" behind the scenes somewhere, but I think "Display if differs from convention time" is a better default.

Firefox opened a cached version of my previous ConClar build. When I reloaded, I did get a default setting for "Show Local Time": "Display if differs from convention time". My Firefox still displays my timezone as UTC rather than the correct one (America/New_York).

I have been holding off merging this because I hadn't managed to replicate this issue, but I was sure it was a problem.

I figured it out at last! The problem was that before this change ConClár stored a boolian indicator for show local time, but now there are three options so it stores a label. I had written code to convert the old true/false to the equivalent label, but at the point of comparison, it was a string rather than a bool, so the comparison didn't match. I've now corrected this, but also added a check against valid values, and if it doesn't match a valid option, will always default to "show if different".