Improve logging

This commit is contained in:
Maks Snegov 2024-04-14 21:51:19 -07:00
parent 8b14b4b2e4
commit e7d22d78a3

View File

@ -14,7 +14,10 @@ function sendPostRequest(data) {
function checkDate() { function checkDate() {
const targetElement = document.querySelector('.swal2-html-container'); const targetElement = document.querySelector('.swal2-html-container');
// Get current time
const currentTime = new Date();
const formattedTime = currentTime.toISOString();
if (targetElement) { if (targetElement) {
const availabilitySpan = targetElement.querySelector('span[style="color: lightgreen;"]'); const availabilitySpan = targetElement.querySelector('span[style="color: lightgreen;"]');
const appointmentSpan = targetElement.querySelector('span[style="color: orange"]'); const appointmentSpan = targetElement.querySelector('span[style="color: orange"]');
@ -25,9 +28,10 @@ function checkDate() {
if (date_avail && date_booked) { if (date_avail && date_booked) {
const date_avail_date = new Date(date_avail); const date_avail_date = new Date(date_avail);
const date_booked_date = new Date(date_booked); const date_booked_date = new Date(date_booked);
console.log(`${formattedTime}: available date ${date_avail}; booked on ${date_booked}`);
// Compare the dates // Compare the dates
if (date_avail_date < date_booked_date) { if (date_avail_date > date_booked_date) {
const message = `available date ${date_avail}; booked on ${date_booked}`; const message = `available date ${date_avail}; booked on ${date_booked}`;
sendPostRequest(message); sendPostRequest(message);
} }