History Best Days graph sending to the wrong date
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:
- Set your system timezone to UTC+1 (unless you're on another UTC+n)
- Go to your user history
- Click on any of the best days bars.
- 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?
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.