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

Move forward by one not working #3

Closed
anchepiece opened this issue Oct 27, 2020 · 7 comments
Closed

Move forward by one not working #3

anchepiece opened this issue Oct 27, 2020 · 7 comments
Labels
bug Something isn't working

Comments

@anchepiece
Copy link

Hi 👋,

Thanks for creating and open sourcing this case study.

I ran into a discrepancy between the forward and backward date movement using the left and right controls. What is seen that clicking the backward button will move the date back 2 days, while clicking forward has no effect.

The most likely reason is that the seek event listener is not applying a full day of movement once the updated date set with t.setDate(t.getDate() + e.detail) gets formatted with formatDateId.

A simple change like this in TodoStore may be enough to address this case.
var t = new Date(state.at + ' 00:00:00');

@morris morris added the bug Something isn't working label Oct 27, 2020
@morris
Copy link
Owner

morris commented Oct 27, 2020

I will take a look! Would you mind sharing the browser you used?

@coder543
Copy link

macOS Chrome, same issue

@anchepiece
Copy link
Author

This was replicated in both firefox 82.0 (64-bit) and chrome Version 88.0.4292.2 (Official Build) dev (64-bit)

@jcoussard
Copy link

It happens to me too. @anchepiece idea of adding ' 00:00:00' works for me. The backward button also moves by 2 days instead of one. It happens because the seek event calculations don't handle timezone properly.
Everyone living on the left side of the Greenwich meridian is affected by this bug! It isn't browser related.

// Assuming state.at is 2020-10-27 and e.detail is 1
var t = new Date(state.at);
// t is Wed Oct 26 2020 00:00:00 GMT-0400 (Eastern Daylight Time)
t.setDate(t.getDate() + e.detail); // 26 + 1 = 27

dispatch({
  at: VT.formatDateId(t), // 2020-10-27
});

Clicking forward yields the original date. Clicking backward goes back 2 days.

@morris morris closed this as completed in dc2ecea Oct 28, 2020
@morris
Copy link
Owner

morris commented Oct 28, 2020

Ahh I should have asked for time zones. Thanks for reporting this, figuring out the cause and providing the fix! Hope it's fine now. I'll add you to the contributor file or section if that's alright :)

@jcoussard
Copy link

I confirm it is fixed, all navigation buttons work as intended now.

@anchepiece
Copy link
Author

Glad its working for others too! Thanks again for sharing this project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants