Skip to content

Instantly share code, notes, and snippets.

@azatoth
Last active December 4, 2020 21:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azatoth/c8ba62572c7b46d9c502a829ac30d665 to your computer and use it in GitHub Desktop.
Save azatoth/c8ba62572c7b46d9c502a829ac30d665 to your computer and use it in GitHub Desktop.
Current TFRs for SpaceX in Boca Chica
const fetch = require("node-fetch");
const date_fns = require("date-fns");
const date_fns_tz = require("date-fns-tz");
const indentString = require("indent-string");
const chalk = require("chalk");
const params = new URLSearchParams({
searchType: "0",
designatorsForLocation: "ZHU",
offset: "0",
notamsOnly: "false",
filters: "Keywords: Airspace-TFR",
});
const re = /BROWNSVILLE/;
const timeZone = "America/Chicago";
(async () => {
const response = await fetch(
"https://notams.aim.faa.gov/notamSearch/search",
{ method: "POST", body: params }
);
const json = await response.json();
const spaceXNotams = json.notamList.filter((notam) => {
return re.test(notam.traditionalMessage) && !notam.cancelledOrExpired;
});
for (const o of spaceXNotams) {
const startDateStr = mkZonedStr(o.startDate, timeZone);
const endDateStr = mkZonedStr(o.endDate, timeZone);
console.log(
chalk`{green.bold.underline ${startDateStr} → ${endDateStr}}:\n${indentString(
o.traditionalMessage,
4
)}`
);
}
})();
function mkZonedStr(date, timeZone) {
const parsed = date_fns.parse(date, "MM/dd/yyyy HHmm", new Date());
return date_fns_tz.format(
date_fns_tz.utcToZonedTime(parsed, timeZone),
"yyyy-MM-dd HH:mm zzz",
{ timeZone }
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment