Skip to content

Commit

Permalink
Title-case lookout names
Browse files Browse the repository at this point in the history
  • Loading branch information
mileswwatkins committed Nov 25, 2023
1 parent ae2dde5 commit 4c4b487
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { parse, format } from "date-fns";
import { startCase } from "lodash";

const parseAvailabilityDate = (dateString) =>
parse(dateString, "yyyy-MM-dd", new Date());
Expand All @@ -9,16 +10,26 @@ const reformatDate = (dateString) => {
};

const formatFacilityName = (name) => {
return (
name
// A few sites have ` RENTAL` at the end of their names,
// which is redundant
.replace(/ RENTAL$/, "")
.replace("MTN.", "MOUNTAIN")
.replace("MT.", "MOUNT")
// There are a few remaining periods that don't make sense
.replace(". ", " ")
);
const cleanedName = name
// A few sites have ` RENTAL` at the end of their names,
// which is redundant
.replace(/ RENTAL$/i, "")
// Remove the parentheticals
.replace(/ \(.+\)$/, "")
.replace(/MTN(?=[\. ])/, "MOUNTAIN")
.replace(/MT\./, "MOUNT")
// There are a few remaining periods that don't make sense
.replace(". ", " ");

let casedName =
cleanedName === cleanedName.toUpperCase()
? startCase(cleanedName.toLowerCase())
: cleanedName;
if (casedName.startsWith("Mc")) {
casedName = "Mc" + casedName[2].toUpperCase() + casedName.slice(3);
}

return casedName;
};

const isLikelyClosed = (availability) =>
Expand Down

0 comments on commit 4c4b487

Please sign in to comment.