Last active
December 4, 2020 21:52
-
-
Save azatoth/c8ba62572c7b46d9c502a829ac30d665 to your computer and use it in GitHub Desktop.
Current TFRs for SpaceX in Boca Chica
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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