Warning Header (Closes #205) #394

Merged
snedadah merged 19 commits from warning-header into main 2022-02-22 23:29:55 -05:00
2 changed files with 4 additions and 6 deletions
Showing only changes of commit 598ffc20f9 - Show all commits

View File

@ -15,9 +15,6 @@ interface Warning {
function getCurrentWarning(): Warning | null {
const today = new Date();
const currentWarnings: Warning[] = warnings.filter((warning) => {
if (!warning.startDate || !warning.endDate) {
console.error("INVALID WARNING:", warning);
}
// convert dates to date objects in EST time zone
let startDate = parse(warning.startDate, DATE_FORMAT, new Date());
let endDate = parse(warning.endDate, DATE_FORMAT, new Date());
@ -28,8 +25,8 @@ function getCurrentWarning(): Warning | null {
isNaN(startDate.getTime()) || // this checks if the parsed date is not valid (eg. wrong format), since getLocalDateFromEST fails with invalid dates
isNaN(endDate.getTime())
) {
console.error("WARNING WITH INVALID DATES:", warning);
return false; // this warning is not valid, dont try to call getLocalDateFromEST
// this warning is not valid, dont try to call getLocalDateFromEST
snedadah marked this conversation as resolved
Review

Do we really need this comment here? I personally think the comment on line 25, along with the general structure of the code, are already sufficient to convey what is happening and why.

Do we really need this comment here? I personally think the comment on line 25, along with the general structure of the code, are already sufficient to convey what is happening and why.
throw new Error('WARNING WITH INVALID DATES: "' + warning.message + '"');
}
startDate = getLocalDateFromEST(startDate);
@ -43,6 +40,7 @@ function getCurrentWarning(): Warning | null {
});
if (currentWarnings.length > 1) {
// we should not throw here, since this could happen a date far after the push was made, and no one would know they site is down unless someone visits
console.error(
"ERROR: MORE THAN ONE WARNING SCHEDULED CURRENTLY! ",
currentWarnings

View File

@ -1,7 +1,7 @@
[
{
"startDate": "February 15 2022 00:00",
"endDate": "February 25 2022 18:00",
"endDate": "February 20 2022 18:00",
"message": "Warning: There will be a scheduled system maintenance on February 17 from 9pm to 12pm EST"
},
{