diff --git a/src/constants/Time.ts b/src/constants/Time.ts index 8d54343..94ce1a5 100644 --- a/src/constants/Time.ts +++ b/src/constants/Time.ts @@ -1,6 +1,6 @@ export module Time { /** - * Timestamp epoch, January 1, 1970. + * Timestamp epoch, January 1, 1970, in Julian Days. */ export const epoch: number = 2440587.5; diff --git a/src/model/JulianDay.ts b/src/model/JulianDay.ts index 3504c3c..d4d47e1 100644 --- a/src/model/JulianDay.ts +++ b/src/model/JulianDay.ts @@ -1,3 +1,5 @@ +import { Time } from "../constants/Time"; + export module JulianDay { /** * Julian day from Gregorian date. @@ -5,7 +7,7 @@ export module JulianDay { */ export const fromDate = (date: Date = new Date()): number => { const time = date.getTime(); - return time / 86400000 - date.getTimezoneOffset() / 1440 + 2440587.5; + return time / 86400000 - date.getTimezoneOffset() / 1440 + Time.epoch; }; /** @@ -14,7 +16,7 @@ export module JulianDay { */ export const toDate = (julian: number): Date => { let date = new Date(); - date.setTime((julian - 2440587.5 + date.getTimezoneOffset() / 1440) * 86400000); + date.setTime((julian - Time.epoch + date.getTimezoneOffset() / 1440) * 86400000); return date; }; } diff --git a/src/model/Moon.ts b/src/model/Moon.ts index ea6f2e5..99aaef5 100644 --- a/src/model/Moon.ts +++ b/src/model/Moon.ts @@ -6,7 +6,7 @@ import { Time } from "../constants/Time"; export module Moon { /** - * Moon's age, or days since the last new moon. + * Moon's age, or Earth days since the last new moon. * * @param date - Date used for calculation. * @returns Age of the moon, normalized within a 29.53059 Earth days calendar.