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

Image date selection boxes not working correctly #13

Open
autronix opened this issue Feb 7, 2024 · 2 comments
Open

Image date selection boxes not working correctly #13

autronix opened this issue Feb 7, 2024 · 2 comments

Comments

@autronix
Copy link

autronix commented Feb 7, 2024

Hello,

I noticed that the pink date selection boxes are showing different dates than the dates the pictures were generated.

image

If I select the dates from the date picker manually, the images shows however, when I click on the pink boxes, it shows empty content most of the time, and the dates are incorrect compared to the folder names generated in the output directory.

image

Looking at the directory dates vs the pink boxes, it looks like the pink boxes dates are offset by one day.

After playing a bit with the code, I found out this was due to how JS processes dates, and how it uses UTC time by default, which was not matching my timezone (EST, UTC-5), hence the date discrepancy.

I made it work by adjusting the following two functions:

const goDate = (e) => {
  console.log("goDate("+e.target.value+")");
  // Changed the direct entry into Date with a split version of the date string broken by year, month, day
  let wd_sp = e.target.value.split("-"); // split date into its parts
  const day = new Date(parseInt(wd_sp[0]), parseInt(wd_sp[1])-1, parseInt(wd_sp[2])); // loading parts directly in Date object
  console.log("day="+day);
  day.setDate(day.getDate());
  console.log("day="+day);
  setDate(day);
}

and

function toggleCalendar() {
  if (!promiseAll) {
    new jBox('Notice', {
      content: "All logs and images are not processed. Please wait...",
      theme: 'TooltipDark',
      attributes: {x: "right", y: "bottom"},
      offset: { x: 20, y: 45 }
    });
    return;
  }

  if (workingDates.length>0) {
    let list="";
    for (let i=0; i<workingDates.length; i++) {
      let wd_sp = workingDates[i].split("-"); // Same principle, splitting date into its parts
      let dt=new Date(parseInt(wd_sp[0]), parseInt(wd_sp[1])-1, parseInt(wd_sp[2])); // loading parts directly in Date object
    list+="<div class='workingDate' onclick='loadDay("+i+")'>"+dt.toLocaleDateString()+" <span class='nbImages'>"+detailDates[workingDates[i]]+" <span>&#x1f4f7;</span></span></div>"
    }
    $("div#calendarList").html(list).toggle();
  }

  if (modeSearch) {
    $("div#calendarList").hide();
  }
}
@toutjavascript
Copy link
Owner

Hi,
Thanks for this work.
I will test and add it in next release

@toutjavascript
Copy link
Owner

Hi
New release is published with fix
Thanks for your help

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

No branches or pull requests

2 participants