8000 Image date selection boxes not working correctly · Issue #13 · toutjavascript/Fooocus-Log-Viewer · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Image date selection boxes not working correctly #13
Open
@autronix

Description

@autronix

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' >"+dt.toLocaleDateString()+" <span class='nbImages'>"+detailDates[workingDates[i]]+" <span>&#x1f4f7;</span></span></div>"
    }
    $("div#calendarList").html(list).toggle();
  }

  if (modeSearch) {
    $("div#calendarList").hide();
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0