diff --git a/demo/nodejs/equator_of_date.js b/demo/nodejs/equator_of_date.js index b65fa2e2..69333733 100644 --- a/demo/nodejs/equator_of_date.js +++ b/demo/nodejs/equator_of_date.js @@ -6,14 +6,15 @@ */ const UsageText = ` -USAGE: node equator_of_date.js yyyy-mm-ddThh:mm:ssZ ra dec +USAGE: node equator_of_date.js ra dec [yyyy-mm-ddThh:mm:ssZ] Converts J2000 equatorial coordinates to equator-of-date coordinates. -yyyy-mm-ddThh:mm:ssZ = The date and time in UTC. ra = J2000 Right ascension in sidereal hours (0 .. 24). dec = J2000 Declination in degrees (-90 .. +90). +yyyy-mm-ddThh:mm:ssZ = Optional date and time in UTC. +(If omitted, the current date and time are used.) This program prints out the right ascension and declination of the same point in the sky, but expressed in the Earth's @@ -41,14 +42,16 @@ function ParseDate(text) { } function Demo() { - if (process.argv.length !== 5) { + if (process.argv.length < 4 || process.argv.length > 5) { console.log(UsageText); process.exit(1); } else { // Parse the command line arguments. - const time = Astronomy.MakeTime(ParseDate(process.argv[2])); - const ra = ParseNumber("RA", process.argv[3], 0, 24); - const dec = ParseNumber("DEC", process.argv[4], -90, +90); + const ra = ParseNumber("RA", process.argv[2], 0, 24); + const dec = ParseNumber("DEC", process.argv[3], -90, +90); + const date = (process.argv.length > 4) ? ParseDate(process.argv[4]) : new Date(); + const time = Astronomy.MakeTime(date); + console.log(`time = ${time}`); // Create a rotation matrix that converts J2000 equatorial (EQJ) // orientation to equator-of-date (EQD) orientation. diff --git a/demo/nodejs/test/equator_of_date_correct.txt b/demo/nodejs/test/equator_of_date_correct.txt index 75225b89..1aeffa88 100644 --- a/demo/nodejs/test/equator_of_date_correct.txt +++ b/demo/nodejs/test/equator_of_date_correct.txt @@ -1 +1,2 @@ +time = 2021-07-06T00:00:00.000Z Equator-of-date coordinates: RA=12.0181, DEC=44.8820 diff --git a/demo/nodejs/test/test b/demo/nodejs/test/test index abc04e29..f4adb176 100755 --- a/demo/nodejs/test/test +++ b/demo/nodejs/test/test @@ -12,7 +12,7 @@ node equatorial.js 38.1256 -89.5544 215.7 23.5 2021-03-27T18:45:00Z > test/equat diff test/equatorial.txt test/equatorial_correct.txt || Fail "Error comparing equatorial.js output." echo "Testing example: equator_of_date.js" -node equator_of_date.js 2021-07-06T00:00:00Z 12 45 > test/equator_of_date.txt || Fail "Error testing equator_of_date.js" +node equator_of_date.js 12 45 2021-07-06T00:00:00Z > test/equator_of_date.txt || Fail "Error testing equator_of_date.js" diff test/equator_of_date.txt test/equator_of_date_correct.txt || Fail "Error comparing equator_of_date.js output." echo "Testing example: camera.js"