astronomy-bundle
Version:
Bundle for astronomical calculations such as position of moon, sun and planets, sunrise, sunset or solar eclipses. Most of the calculations are based on Jean Meeus 'Astronomical Algorithms' book and the VSOP87 theory.
66 lines (65 loc) • 2.29 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const calculations_1 = require("../time/calculations");
const math_1 = require("../utils/math");
class TimeOfInterest {
constructor(time) {
this.time = time;
this.jd = 0.0;
this.T = 0.0;
this.jd = calculations_1.timeCalc.time2julianDay(time);
this.T = calculations_1.timeCalc.julianDay2julianCenturiesJ2000(this.jd);
}
getTime() {
return this.time;
}
getString() {
const { year, month, day, hour, min, sec } = this.time;
return `${year}-${(0, math_1.pad)(month, 2)}-${(0, math_1.pad)(day, 2)} ${(0, math_1.pad)(hour, 2)}:${(0, math_1.pad)(min, 2)}:${(0, math_1.pad)(sec, 2)}`;
}
getDate() {
const { year, month, day, hour, min, sec } = this.time;
return new Date(Date.UTC(year, month - 1, day, hour, min, sec));
}
getDecimalYear() {
return calculations_1.timeCalc.getDecimalYear(this.time);
}
getDayOfYear() {
return calculations_1.timeCalc.getDayOfYear(this.time);
}
getDayOfWeek() {
return calculations_1.timeCalc.getDayOfWeek(this.time);
}
isLeapYear() {
return calculations_1.timeCalc.isLeapYear(this.time.year);
}
getJulianDay() {
return this.jd;
}
getJulianDay0() {
return calculations_1.timeCalc.julianDay2julianDay0(this.jd);
}
getJulianCenturiesJ2000() {
return this.T;
}
getJulianMillenniaJ2000() {
return calculations_1.timeCalc.julianDay2julianMillenniaJ2000(this.jd);
}
getGreenwichMeanSiderealTime() {
return calculations_1.timeCalc.getGreenwichMeanSiderealTime(this.T);
}
getGreenwichApparentSiderealTime() {
return calculations_1.timeCalc.getGreenwichApparentSiderealTime(this.T);
}
getLocalMeanSiderealTime(location) {
return calculations_1.timeCalc.getLocalMeanSiderealTime(this.T, location.lon);
}
getLocalApparentSiderealTime(location) {
return calculations_1.timeCalc.getLocalApparentSiderealTime(this.T, location.lon);
}
getDeltaT() {
const { year, month } = this.time;
return calculations_1.timeCalc.getDeltaT(year, month);
}
}
exports.default = TimeOfInterest;