Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix time range selector timezones #6

Merged
merged 4 commits into from
Apr 12, 2021

Conversation

neonnoon
Copy link
Contributor

This PR removes all uses of date-fns-tz (except from test code). In my opinion, date-fns-tz actually complicates things significantly. From a time range point of view, there are no timezones, there's a start and end timestamp. So, the timezone only becomes relevant for display.

Intl.DateTimeFormat [1] handles this well. In my opinion, date-fns-tz can be useful to handle string to timestamp if a timezone is involved, i.e., figuring out the timestamp of "17 Mar 11:05".

If I understood things right, there's actually three timezones involved, local time, utc, and zoned time. Having the browser (or the tests) run in Europe/Zurich looks correct, using GMT though shows the discrepancy.

[1] https://caniuse.com/?search=DateTimeFormat

@neonnoon neonnoon self-assigned this Mar 17, 2021
@neonnoon
Copy link
Contributor Author

neonnoon commented Mar 17, 2021

Before, correct when browser is in CET (start of next interval is end of previous):
before-cet-cest before-cet-cet

Before, incorrect when browser time is in GMT (one hour missing in DST crossing):
(edit: and "now" time is quite off as well)
before-gmt-cest before-gmt-cet

After, issue is fixed when browser time is in GMT (start of next interval is end of previous):
after-gmt-cest after-gmt-cet

For completeness sake, correct behaviour also when browser is in CET:
after-cet-cest after-cet-cet

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@neonnoon
Copy link
Contributor Author

neonnoon commented Mar 17, 2021

Updated node from 12 to 14. v12 did not yet contain full ICU support by default, see:
nodejs/node#19214

@justmejulian , @sosostris , you might wanna check this on your internal builds as well?

@nicholas-os
Copy link

Thank you Mezzo!

@neonnoon
Copy link
Contributor Author

neonnoon commented Apr 5, 2021

Thanks for the review, @nicholas-os . @justmejulian , do you also wanna have a quick look?

@neonnoon
Copy link
Contributor Author

Discussed with @sosostris , @justmejulian & Thomas, merging now.

@neonnoon neonnoon merged commit f8c8f67 into main Apr 12, 2021
@neonnoon neonnoon deleted the bugfix/time-range-selector-timezones branch April 12, 2021 11:42
Copy link
Contributor

@Sakai-san Sakai-san left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can do destructuring here :

const TimeRangeNavigationBar = (props) => {

const TimeRangeNavigationBar = ({from, lowerBound}) => {

Copy link
Contributor

@justmejulian justmejulian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks loads cleaner and fixes the failing tests. Thanks!

@sosostris
Copy link
Contributor

@neonnoon I merged all the changes to local repo and somehow the tests were failing due to formatting (the values are all correct), like this:

Expected: "01.11.2020, 01:59 - 02.11.2020, 00:59"
Received: "11/01/2020, 01:59 AM - 11/02/2020, 12:59 AM"

But the tests are all passing here, so it's super weird. Checked a bit together with @Sakai-san and we found that the implementation of the method Intl.DateTimeFormat seems to vary with machine-os-language-set-up, e.g. there are similar issues reported here https://stackoverflow.com/questions/52797070/intl-datetimeformat-with-format-options-doesnt-work-for-it-ch

I will create a ticket to follow up with this. It would be nice to unify all the display to be one format :)

@neonnoon
Copy link
Contributor Author

Ah.. I had the same issue.

See build result: See https://github.com/open-ch/pyrene/runs/2129628724
Fixed for Github like so: fa79374
Also mentioned further up in this thread: #6 (comment)

You might have to check the bamboo build agents.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants