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

History Best Days graph sending to the wrong date #2402

Open
Mindhral opened this issue May 3, 2024 · 1 comment
Open

History Best Days graph sending to the wrong date #2402

Mindhral opened this issue May 3, 2024 · 1 comment
Labels
good first issue kind/bug Something isn't working

Comments

@Mindhral
Copy link

Mindhral commented May 3, 2024

Describe the bug
I'm guessing this happens when we live east to the UTC line.
On the history page, if I click on one of the bars in the "Best Days" graph, I get sent to the day before the one I clicked.

To Reproduce
Steps to reproduce the behavior:

  1. Set your system timezone to UTC+1 (unless you're on another UTC+n)
  2. Go to your user history
  3. Click on any of the best days bars.
  4. You get sent to the day before the one you clicked (as in before in the calendar, not before on the graph)

Expected behavior
Arriving on the page for the day we clicked

Screenshots
If applicable, add screenshots to help explain your problem.

Environment
Checked on:

  • Windows 10 + Firefox
  • Android table + Firefox
  • Android phone + Samsung Browser

Additional context
All the other ways to get to a date on the page work (for me).
The timestamp used in the URL correspond to a different hour of the day depending on the widget we use:

  • "Go to date" button: 00:00:00
  • "History" graph: 10:00:00 (12:00:00 for GMT)
  • "Best days" graph: the day before 22:00:00 (midnight for GMT)
  • "Best days" links: 00:00:00

I'm guessing using the same conversion for the graphs as for the links would give a more consistent behavior?

@wescopeland wescopeland added kind/bug Something isn't working good first issue labels May 3, 2024
@sethxd
Copy link

sethxd commented May 7, 2024

It looks like we need to update two functions in history.blade.php to address this:

function selectHandlerBestDays(e) {
      if (chartBestDays.getSelection().length >= 1) {
        var dateAbbr = dataBestDays.getFormattedValue(chartBestDays.getSelection()[0].row, 0);
        var dateParsed = Date.parse(dateAbbr) / 1000;
        window.location = '/historyexamine.php?d=' + dateParsed + '&u=<?= $userPage ?>';
      }
    }
function selectHandlerScoreProgress(e) {
      if (chartScoreProgress.getSelection().length >= 1) {
        var dateFormatted = dataTotalScore.getFormattedValue(chartScoreProgress.getSelection()[0].row, 0);

        var d = new Date(Date.parse(dateFormatted));
        var dAdj = new Date(d.getTime() + 60000 * 60 * 12);	// Adjusted by 60000 (min) times 60 (hour) times 12 (middle of day)

        var nUnix = parseInt(dAdj.getTime() / 1000);

        window.location = '/historyexamine.php?d=' + nUnix + '&u=' + <?php echo "'$userPage'"; ?>;
      }
    }

I can take a look once I finished getting my local environment up and running.

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

No branches or pull requests

3 participants