From 4a9dca9ffccb087135c6e2d0eebae45cd567036d Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Thu, 3 Nov 2022 17:45:27 +0200 Subject: Corrected typo, added 1h30min waiting time before the foods are updated You never know if the city's servers don't get updated instantly, so it might not be a good idea to ask for the foods at (at worst) 1 ms after 00:00 at monday. --- Functions/dateFuncs.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'Functions/dateFuncs.js') diff --git a/Functions/dateFuncs.js b/Functions/dateFuncs.js index 55a9372..340b46e 100644 --- a/Functions/dateFuncs.js +++ b/Functions/dateFuncs.js @@ -46,9 +46,10 @@ function run_at_monday_mornings(func) { days_to_elapse = 8 - weekday; ms_to_elapse = ms_in_h * ( days_to_elapse * 24/*hours in a day*/ - - hour // removes unneccessary hours so that we update it at 0 am - ) + 1 /*+1 so that we know that it won't be exactly midnight - and possibly sunday. idk if this actually is needed.*/; + - hour + 1.5 // removes unneccessary hours so that we update it at 1:30 am + // 1:30 just in case the foods aren't updated instantly to the city's + // servers. + ); setTimeout(() => run_at_monday_mornings(func), ms_to_elapse); -- cgit v1.2.3 From d10272298acb4d6e07fb5b73dd7af06d653afd7b Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Fri, 18 Nov 2022 18:27:40 +0200 Subject: Updated exam/vacation/etc notifications. Now they don't block the search field, which is more user friendly. They also appear only if the date searched for matches the notification, not if the current date matches the notification. --- Functions/dateFuncs.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Functions/dateFuncs.js') diff --git a/Functions/dateFuncs.js b/Functions/dateFuncs.js index 340b46e..caec1c9 100644 --- a/Functions/dateFuncs.js +++ b/Functions/dateFuncs.js @@ -5,14 +5,14 @@ function stringToDate(s) { } const isBetweenDates = (date, date1, date2) => { - date = approxDate(date); - date1 = approxDate(date1); - date2 = approxDate(date2); + date = floorDate(date); + date1 = floorDate(date1); + date2 = floorDate(date2); return ((date.getTime() >= date1.getTime()) && (date.getTime() <= date2.getTime())); }; -function approxDate(d) +function floorDate(d) { return new Date(`${d.getFullYear()}-${(d.getMonth() + 1).toString().padStart(2, "0")}-${d.getDate().toString().padStart(2, "0")}`); } -- cgit v1.2.3