From 7c2581efa286676c54315baa42d58b4060e4c825 Mon Sep 17 00:00:00 2001 From: Alexander Metzger Date: Thu, 4 Apr 2024 22:23:12 -0700 Subject: [PATCH 1/2] remove awkward 1000 in date logic --- public/admin.js | 16 ++++++++-------- public/calendar.js | 4 ++-- public/components/CircleLoader.js | 2 +- public/components/Table.js | 17 ++++++----------- public/groups.js | 6 +++--- public/scanner.js | 6 +++--- public/stats.js | 29 +++++++++++------------------ public/util/selectors.js | 4 ++-- server/Attendance.js | 12 +++++------- server/Event.js | 10 +++++----- 10 files changed, 46 insertions(+), 60 deletions(-) diff --git a/public/admin.js b/public/admin.js index 4f9394a..2aeb0a5 100644 --- a/public/admin.js +++ b/public/admin.js @@ -217,8 +217,8 @@ document.getElementById('submitevent').addEventListener('click', () => { const starttime = document.getElementById('starttime').value; const enddate = document.getElementById('enddate').value; const endtime = document.getElementById('endtime').value; - const starttimestamp = new Date(startdate + 'T' + starttime).getTime() / 1000; - const endtimestamp = new Date(enddate + 'T' + endtime).getTime() / 1000; + const starttimestamp = new Date(startdate + 'T' + starttime).getTime(); + const endtimestamp = new Date(enddate + 'T' + endtime).getTime(); const isRepeating = document.getElementById('repeat').checked; const allTags = document.getElementById('all-tags'); @@ -242,7 +242,7 @@ document.getElementById('submitevent').addEventListener('click', () => { if (isRepeating) { const frequency = document.getElementById('frequency').value.toLowerCase(); const interval = document.getElementById('interval').value; - const timezoneOffsetMS = new Date().getTimezoneOffset() * 60 * 1000; + const timezoneOffsetMS = new Date().getTimezoneOffset() * 60_000; let daysoftheweek = []; let counter = 0; if (interval < 1) { @@ -322,8 +322,8 @@ function getEventData() { GET(`/businesses/${getBusinessId()}/events/${getEventId()}`).then(res => res.json().then(eventinfo => { tagHTMLString(eventinfo.tag); - var startDate = new Date(eventinfo.starttimestamp * 1000); - var endDate = new Date(eventinfo.endtimestamp * 1000); + var startDate = new Date(+eventinfo.starttimestamp); + var endDate = new Date(+eventinfo.endtimestamp); document.getElementById('eventdetails').innerHTML = /* html */ `
-

ⓘ  ${ +

ⓘ  ${ tips[randomTip] }

diff --git a/public/components/Table.js b/public/components/Table.js index 816e963..2d6feaf 100644 --- a/public/components/Table.js +++ b/public/components/Table.js @@ -164,8 +164,8 @@ export class Table extends Component { } // Event headers for (let i = 0; i < events.length; i++) { - var startDate = new Date(events[i].starttimestamp * 1000); - var endDate = new Date(events[i].endtimestamp * 1000); + var startDate = new Date(+events[i].starttimestamp); + var endDate = new Date(+events[i].endtimestamp); let eventName = events[i].name || '[Unnamed]'; html += `