Exercise Tracker timezone offset problem in date property test

I’m wondering if anyone else has seen any timezone offset related problems in the date property of logs test in the updated exercise tracker tests. I ran the new tests against a passing project and noticed the new checks on the log property formats and was surprised that the project was failing the checks on the date since I was already using Date().toDateString() (well, it’s equivalent in Ruby), the format was correct, and it really was a string. After some debugging, I realized that I was working within the offset of my time zone and midnight and that could be causing date confusion.

To eliminate as many problems on my end as possible, I ran the example project against the tests and it also failed the date property test. I ran the tests again this morning, when the dates should be the same outside of the time zone offset, and all tests pass with my project and the example project.

the only I have seen is this, but is on a different project:

Now that you mention it, I think there was some discussion or comments in the code regarding the difficulty in asserting times are equal given the problems with different time zones on different machines and their various misconfigurations. My project also implements the timeserver API (separate route/controller) and passes those similar tests, but they are all using UTC.

I just verified that both my project and the example passed the test before 7 PM CDT and failed right after 7 PM CDT, so it is an offset problem. I even double checked my system time and it all appeared correct. I assume that the test is generating this part of the expected response

date: new Date().toDateString()

in the browser using the browser’s time zone (CDT for me) which gets compared with the API’s version which is generated in UTC on repl.it, and so the test fails for offset hours a day (5 for me). I’ve replicated it in both recent firefox and chrome.

Now to just determine if I have caused the offset problem or if the problem lies elsewhere.

1 Like

Spot on mate! However, my project passed after 7 PM CDT, and kept failing before that, without any changes to the code. No idea why it was the other way around for me.

Very strange. If others are having similar results, it’s less likely we have all had similar mistakes. Since it fails before 7 PM CDT, when does it start failing (my guess is 1 PM or 2 PM). Do you happen to have any other time related strangeness on your system, especially with time zones or weird times in UTC?

In case of such occurrences in future projects, I installed Google Chrome Timezone extension into my browser, since the test requires UTC timezone and not the system time.

I’ve seen that, but I don’t use it. I’m either too stubborn or too idealistic and I think that the test should work as long as the time is configured correctly on all the systems involved. Of course, I also realize that time zones are not an easy problem.

if you can open an issue on GitHub if there is not one already and explain the issue

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.