This commit is contained in:
gallant 2022-10-24 09:32:22 -05:00
parent b0f1fe2c35
commit 4215da9c52
14 changed files with 3 additions and 1302 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
node_modules/
.git/
public/

12
node_modules/.package-lock.json generated vendored
View File

@ -1,12 +0,0 @@
{
"name": "site",
"lockfileVersion": 2,
"requires": true,
"packages": {
"node_modules/lunarphase-js": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/lunarphase-js/-/lunarphase-js-1.0.10.tgz",
"integrity": "sha512-+A+G3WzB2y+xcCfhVRLxbdOnTe/Ujmbx/ptS0cjUnb9zRAEfRpu6U3D1o+IaStpRu91++kFoVqOYKhyT1m3ywg=="
}
}
}

5
node_modules/lunarphase-js/LICENSE generated vendored
View File

@ -1,5 +0,0 @@
Copyright (c) 2021 Jason Sturges
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

197
node_modules/lunarphase-js/README.md generated vendored
View File

@ -1,197 +0,0 @@
# Lunar phase
Calculate phase of the moon using Julian date.
# Getting Started
To install, execute:
npm i lunarphase-js
Then, import into a project as:
```js
import { Moon } from "lunarphase-js";
```
# Usage
In the lunar calendar there are 8 phases each synodic month, which is the number of days to complete the cycle. This time between two identical syzygies is equivalent to 29.53059 Earth days.
Lunar phases, in order:
| Phase | Northern Hemisphere | Southern Hemisphere |
| --------------- | ------------------- | ------------------- |
| New | 🌑 | 🌑 |
| Waxing Crescent | 🌒 | 🌘 |
| First Quarter | 🌓 | 🌗 |
| Waxing Gibbous | 🌔 | 🌖 |
| Full | 🌕 | 🌕 |
| Waning Gibbous | 🌖 | 🌔 |
| Last Quarter | 🌗 | 🌓 |
| Waning Crescent | 🌘 | 🌒 |
## Julian Day
Convert to and from Gregorian Dates to Julian Days via the `JulianDay` module.
API Reference:
| Function | Output | Description |
| ---------- | ------------------------ | -------------------------- |
| fromDate() | 2459357.5380029744 | Convert date to Julian Day |
| toDate() | 2021-05-23T05:56:10.418Z | Convert Julian Day to date |
To convert a date to Julian Day:
```js
import { JulianDay } from "lunarphase-js";
const date = new Date();
const julian = JulianDay.fromDate(date);
```
To convert a Julian Day to a date:
```js
import { JulianDay } from "lunarphase-js";
const julian = 2459356.529302257;
const date = JulianDay.toDate(julian);
```
## Lunar Phases
API Reference:
| Function | Output | Description |
| ----------------- | ------------------- | ----------------------------------------------------- |
| lunarPhase() | Waxing Gibbous | Get lunar phase for a given date |
| lunarPhaseEmoji() | 🌖 | Get emoji of lunar phase for a given date |
| isWaxing() | true | Whether the moon is waxing |
| isWaning() | false | Whether the moon is waning |
| lunarAge() | 11.367344279004676 | Earth days since the last new moon |
| lunarAgePercent() | 0.38497186542446116 | Percentage through the lunar synodic month |
| lunarDistance() | 56.04166690080031 | Distance to the moon measured in units of Earth radii |
| lunationNumber() | 1217 | Brown Lunation Number (BLN) |
For a specific date, pass a date object to a function
```js
import { Moon } from "lunarphase-js";
const date = new Date();
const phase = Moon.lunarPhase(date);
```
Otherwise, current date will be used
```js
import { Moon } from "lunarphase-js";
const phase = Moon.lunarPhase();
```
### Lunar Phase
To get the current lunar phase from the `LunarPhase` enum (ex: "FULL")
```js
const phase = Moon.lunarPhase();
```
### Lunar Phase Emoji
To get the current lunar phase emoji from the `LunarEmoji` (ex: "🌕"):
```js
const phaseEmoji = Moon.lunarPhaseEmoji();
```
As phases are inverted between Northern and Southern Hemispheres, optionally pass a `Hemisphere` to the function:
```js
import { Moon } from "lunarphase-js";
import { Hemisphere } from "lunarphase-js";
const date = new Date();
Moon.lunarPhaseEmoji(date, Hemisphere.NORTHERN);
```
To get emoji for other lunar phases, pass a `LunarPhase` enum:
```js
const emoji = Moon.emojiForLunarPhase(Moon.LunarPhase.Full);
```
Optionally pass a `Hemisphere` to the function:
```js
import { Moon } from "lunarphase-js";
import { LunarPhase } from "lunarphase-js";
import { Hemisphere } from "lunarphase-js";
Moon.emojiForLunarPhase(LunarPhase.FIRST_QUARTER, Hemisphere.SOUTHERN);
```
### Waxing
Whether the moon is waxing (ex: false)
```js
const waxing = Moon.isWaxing();
```
### Waning
Whether the moon is waning (ex: true)
```js
const waning = Moon.isWaning();
```
### Lunar Age
Age in Earth days through the current lunar cycle, equivalent to 29.53059 Earth days, based on Mean Synodic Month, 2000 AD mean solar days.
| Phase | Start | Event | End |
| --------------- | -------------- | -------------- | -------------- |
| New | | 0 | 1.84566173161 |
| Waxing Crescent | 1.84566173161 | 3.69132346322 | 5.53698519483 |
| First Quarter | 5.53698519483 | 7.38264692644 | 9.22830865805 |
| Waxing Gibbous | 9.22830865805 | 11.07397038966 | 12.91963212127 |
| Full | 12.91963212127 | 14.76529385288 | 16.61095558449 |
| Waning Gibbous | 16.61095558449 | 18.4566173161 | 20.30227904771 |
| Last Quarter | 20.30227904771 | 22.14794077932 | 23.99360251093 |
| Waning Crescent | 23.99360251093 | 25.83926424254 | 27.68492597415 |
| New | 27.68492597415 | 29.53058770576 | |
To get the lunar age (ex: 16.54412413414952)
```js
const age = Moon.lunarAge();
```
### Lunar Age Percent
To get the percentage through the lunar cycle (ex: 0.5602368519132597)
```js
const agePercent = Moon.lunarAgePercent();
```
### Lunation Number
Brown Lunation Number (BLN), per Ernest William Brown's lunar theory, defining Lunation 1 as the first new moon of 1923 at approximately 02:41 UTC, January 17, 1923
```js
const lunationNumber = Moon.lunationNumber();
```
### Lunar Distance
Distance to the moon measured in units of Earth radii, with perigee at 56 and apogee at 63.8.
```js
const distance = Moon.lunarDistance();
```

View File

@ -1,352 +0,0 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.LunarPhase = {}));
})(this, (function (exports) { 'use strict';
/**
* Earth's hemispheres.
*
* @typedef {string} Hemisphere
* @enum {Hemisphere}
*/
const Hemisphere = {
NORTHERN: "Northern",
SOUTHERN: "Southern",
};
/**
* Enumeration of lunar phases as emoji
*
* @typedef {string} LunarEmoji
*/
const LunarEmoji = {
/**
* Enumeration of lunar phases as emoji for the Northern Hemisphere.
* @num {LunarPhase}
*/
NorthernHemisphere: {
NEW: "🌑",
WAXING_CRESCENT: "🌒",
FIRST_QUARTER: "🌓",
WAXING_GIBBOUS: "🌔",
FULL: "🌕",
WANING_GIBBOUS: "🌖",
LAST_QUARTER: "🌗",
WANING_CRESCENT: "🌘",
},
/**
* Enumeration of lunar phases as emoji for the Southern Hemisphere.
* @num {LunarPhase}
*/
SouthernHemisphere: {
NEW: "🌑",
WAXING_CRESCENT: "🌘",
FIRST_QUARTER: "🌗",
WAXING_GIBBOUS: "🌖",
FULL: "🌕",
WANING_GIBBOUS: "🌔",
LAST_QUARTER: "🌓",
WANING_CRESCENT: "🌒",
},
};
/**
* Lunar month, time between two successive syzygies of the
* same type: new moons or full moons
*
* @typedef {string} LunarMonth
* @enum {LunarMonth}
*/
const LunarMonth = {
ANOMALISTIC: "Anomalistic",
DRACONIC: "Draconic",
SIDEREAL: "Sidereal",
SYNODIC: "Synodic",
TROPICAL: "Tropical",
};
/**
* Enumeration of lunar phases
*
* @typedef {string} LunarPhase
* @enum {LunarPhase}
*/
const LunarPhase = {
NEW: "New",
WAXING_CRESCENT: "Waxing Crescent",
FIRST_QUARTER: "First Quarter",
WAXING_GIBBOUS: "Waxing Gibbous",
FULL: "Full",
WANING_GIBBOUS: "Waning Gibbous",
LAST_QUARTER: "Last Quarter",
WANING_CRESCENT: "Waning Crescent",
};
/**
* Units of measure
*
* @typedef {string} Unit
* @enum {Unit}
*/
const Unit = {
EARTH_RADII: "Earth Radii",
KILOMETERS: "km",
MILES: "m",
};
/**
* Timestamp epoch, January 1, 1970, in Julian Days.
* @type {number}
*/
const EPOCH = 2440587.5;
/**
* Lunation 1 as the first new moon of 1923 at approximately
* 02:41 UTC, January 17, 1923 per Ernest William Brown's lunar theory.
* @type {number}
*/
const LUNATION_BASE_JULIAN_DAY = 2423436.6115277777;
/**
* Length of one phase (1/8 of a synodic month) in Earth days.
* @type {number}
*/
const PHASE_LENGTH = 3.69132346322;
/**
* Orbital period of the Moon from perigee to apogee and back to perigee
* @type {number}
*/
const ANOMALISTIC_MONTH = 27.55454988;
/**
* Length of one synodic month - lunation, or days for the phases to complete a cycle.
* Time between two identical syzygies, equivalent of 29.53059 Earth days.
*
* Based on Mean Synodic Month, 2000 AD mean solar days.
* @type {number}
*/
const SYNODIC_MONTH = 29.53058770576;
var Time = /*#__PURE__*/Object.freeze({
__proto__: null,
EPOCH: EPOCH,
LUNATION_BASE_JULIAN_DAY: LUNATION_BASE_JULIAN_DAY,
PHASE_LENGTH: PHASE_LENGTH,
ANOMALISTIC_MONTH: ANOMALISTIC_MONTH,
SYNODIC_MONTH: SYNODIC_MONTH
});
/**
* Normalization utility for percentage calculations.
*
* @param {number} value Percent value.
* @returns {number} Normalized value
*/
const normalize = (value) => {
value -= Math.floor(value);
if (value < 0) {
value += 1;
}
return value;
};
/**
* Julian day from Gregorian date.
* @param {Date} date Gregorian date to convert to Julian day.
* @returns {number} Julian Day
*/
const fromDate = (date = new Date()) => {
const time = date.getTime();
return time / 86400000 - date.getTimezoneOffset() / 1440 + EPOCH;
};
/**
* Gregorian date from Julian day
* @param {number} julian Julian dat to convert to Gregorian date
* @returns {Date} Gregorian date
*/
const toDate = (julian) => {
let date = new Date();
date.setTime((julian - EPOCH + date.getTimezoneOffset() / 1440) * 86400000);
return date;
};
var JulianDay = /*#__PURE__*/Object.freeze({
__proto__: null,
fromDate: fromDate,
toDate: toDate
});
/**
* Moon's age, or Earth days since the last new moon.
*
* @param {Date} date Date used for calculation.
* @returns {number} Age of the moon, normalized within a 29.53059 Earth days calendar.
*/
const lunarAge = (date = new Date()) => {
const percent = lunarAgePercent(date);
return percent * SYNODIC_MONTH;
};
/**
* Percentage through the lunar synodic month.
*
* @param {Date} date Date used for calculation.
* @returns {number} Percentage through the lunar month.
*/
const lunarAgePercent = (date = new Date()) => {
return normalize((fromDate(date) - 2451550.1) / SYNODIC_MONTH);
};
/**
* Brown Lunation Number (BLN), per Ernest William Brown's lunar theory,
* defining Lunation 1 as the first new moon of 1923 at
* approximately 02:41 UTC, January 17, 1923.
*
* @param {Date} date Date used for calculation.
* @returns {number} Lunation Number
*/
const lunationNumber = (date = new Date()) => {
return Math.round((fromDate(date) - LUNATION_BASE_JULIAN_DAY) / SYNODIC_MONTH) + 1;
};
/**
* Distance to the moon measured in units of Earth radii, with
* perigee at 56 and apogee at 63.8.
*
* @param {Date} date Date used for calculation
* @returns {number} Distance to the moon in Earth radii
*/
const lunarDistance = (date = new Date()) => {
const julian = fromDate(date);
const agePercent = lunarAgePercent(date);
const radians = agePercent * 2 * Math.PI;
const percent = 2 * Math.PI * normalize((julian - 2451562.2) / ANOMALISTIC_MONTH);
return 60.4 - 3.3 * Math.cos(percent) - 0.6 * Math.cos(2 * radians - percent) - 0.5 * Math.cos(2 * radians);
};
/**
* Name of the lunar phase per date submitted.
*
* @param {Date} date Date used to calculate lunar phase.
* @returns {string} Name as string of the current lunar phase.
*/
const lunarPhase = (date = new Date()) => {
const age = lunarAge(date);
if (age < 1.84566173161) return LunarPhase.NEW;
else if (age < 5.53698519483) return LunarPhase.WAXING_CRESCENT;
else if (age < 9.22830865805) return LunarPhase.FIRST_QUARTER;
else if (age < 12.91963212127) return LunarPhase.WAXING_GIBBOUS;
else if (age < 16.61095558449) return LunarPhase.FULL;
else if (age < 20.30227904771) return LunarPhase.WANING_GIBBOUS;
else if (age < 23.99360251093) return LunarPhase.LAST_QUARTER;
else if (age < 27.68492597415) return LunarPhase.WANING_CRESCENT;
return LunarPhase.NEW;
};
/**
* Emoji of the lunar phase per date submitted.
*
* @param {Date} date Date used to calculate lunar phase.
* @param {Hemisphere} hemisphere Northern or Southern Hemisphere.
* @returns Emoji of the current lunar phase.
*/
const lunarPhaseEmoji = (date = new Date(), hemisphere = Hemisphere.NORTHERN) => {
const phase = lunarPhase(date);
return emojiForLunarPhase(phase, hemisphere);
};
/**
* Emoji for specified lunar phase.
*
* @param {LunarPhase} phase Lunar phase, per the LunarPhase enum
* @param {Hemisphere} hemisphere Northern or Southern Hemisphere.
* @returns {string} Emoji of the current lunar phase.
*/
const emojiForLunarPhase = (phase, hemisphere = Hemisphere.NORTHERN) => {
let emoji;
if (hemisphere === Hemisphere.SOUTHERN) {
emoji = LunarEmoji.SouthernHemisphere;
} else {
emoji = LunarEmoji.NorthernHemisphere;
}
switch (phase) {
case LunarPhase.WANING_CRESCENT:
return emoji["WANING_CRESCENT"];
case LunarPhase.LAST_QUARTER:
return emoji["LAST_QUARTER"];
case LunarPhase.WANING_GIBBOUS:
return emoji["WANING_GIBBOUS"];
case LunarPhase.FULL:
return emoji["FULL"];
case LunarPhase.WAXING_GIBBOUS:
return emoji["WAXING_GIBBOUS"];
case LunarPhase.FIRST_QUARTER:
return emoji["FIRST_QUARTER"];
case LunarPhase.WAXING_CRESCENT:
return emoji["WAXING_CRESCENT"];
default:
case LunarPhase.NEW:
return emoji["NEW"];
}
};
/**
* Whether the moon is currently waxing (growing).
*
* @param {Date} date Date used for calculation.
* @returns {boolean} True if moon is waxing.
*/
const isWaxing = (date = new Date()) => {
const age = lunarAge(date);
return age <= 14.765;
};
/**
* Whether the moon is currently waning (shrinking).
*
* @param {Date} date Date used for calculation.
* @returns {boolean} True if moon is waning.
*/
const isWaning = (date = new Date()) => {
const age = lunarAge(date);
return age > 14.765;
};
var Moon = /*#__PURE__*/Object.freeze({
__proto__: null,
lunarAge: lunarAge,
lunarAgePercent: lunarAgePercent,
lunationNumber: lunationNumber,
lunarDistance: lunarDistance,
lunarPhase: lunarPhase,
lunarPhaseEmoji: lunarPhaseEmoji,
emojiForLunarPhase: emojiForLunarPhase,
isWaxing: isWaxing,
isWaning: isWaning
});
exports.Hemisphere = Hemisphere;
exports.JulianDay = JulianDay;
exports.LunarEmoji = LunarEmoji;
exports.LunarMonth = LunarMonth;
exports.LunarPhase = LunarPhase;
exports.Moon = Moon;
exports.Time = Time;
exports.Unit = Unit;
Object.defineProperty(exports, '__esModule', { value: true });
}));
//# sourceMappingURL=lunarphase-js..js.map

File diff suppressed because one or more lines are too long

View File

@ -1,346 +0,0 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
/**
* Earth's hemispheres.
*
* @typedef {string} Hemisphere
* @enum {Hemisphere}
*/
const Hemisphere = {
NORTHERN: "Northern",
SOUTHERN: "Southern",
};
/**
* Enumeration of lunar phases as emoji
*
* @typedef {string} LunarEmoji
*/
const LunarEmoji = {
/**
* Enumeration of lunar phases as emoji for the Northern Hemisphere.
* @num {LunarPhase}
*/
NorthernHemisphere: {
NEW: "🌑",
WAXING_CRESCENT: "🌒",
FIRST_QUARTER: "🌓",
WAXING_GIBBOUS: "🌔",
FULL: "🌕",
WANING_GIBBOUS: "🌖",
LAST_QUARTER: "🌗",
WANING_CRESCENT: "🌘",
},
/**
* Enumeration of lunar phases as emoji for the Southern Hemisphere.
* @num {LunarPhase}
*/
SouthernHemisphere: {
NEW: "🌑",
WAXING_CRESCENT: "🌘",
FIRST_QUARTER: "🌗",
WAXING_GIBBOUS: "🌖",
FULL: "🌕",
WANING_GIBBOUS: "🌔",
LAST_QUARTER: "🌓",
WANING_CRESCENT: "🌒",
},
};
/**
* Lunar month, time between two successive syzygies of the
* same type: new moons or full moons
*
* @typedef {string} LunarMonth
* @enum {LunarMonth}
*/
const LunarMonth = {
ANOMALISTIC: "Anomalistic",
DRACONIC: "Draconic",
SIDEREAL: "Sidereal",
SYNODIC: "Synodic",
TROPICAL: "Tropical",
};
/**
* Enumeration of lunar phases
*
* @typedef {string} LunarPhase
* @enum {LunarPhase}
*/
const LunarPhase = {
NEW: "New",
WAXING_CRESCENT: "Waxing Crescent",
FIRST_QUARTER: "First Quarter",
WAXING_GIBBOUS: "Waxing Gibbous",
FULL: "Full",
WANING_GIBBOUS: "Waning Gibbous",
LAST_QUARTER: "Last Quarter",
WANING_CRESCENT: "Waning Crescent",
};
/**
* Units of measure
*
* @typedef {string} Unit
* @enum {Unit}
*/
const Unit = {
EARTH_RADII: "Earth Radii",
KILOMETERS: "km",
MILES: "m",
};
/**
* Timestamp epoch, January 1, 1970, in Julian Days.
* @type {number}
*/
const EPOCH = 2440587.5;
/**
* Lunation 1 as the first new moon of 1923 at approximately
* 02:41 UTC, January 17, 1923 per Ernest William Brown's lunar theory.
* @type {number}
*/
const LUNATION_BASE_JULIAN_DAY = 2423436.6115277777;
/**
* Length of one phase (1/8 of a synodic month) in Earth days.
* @type {number}
*/
const PHASE_LENGTH = 3.69132346322;
/**
* Orbital period of the Moon from perigee to apogee and back to perigee
* @type {number}
*/
const ANOMALISTIC_MONTH = 27.55454988;
/**
* Length of one synodic month - lunation, or days for the phases to complete a cycle.
* Time between two identical syzygies, equivalent of 29.53059 Earth days.
*
* Based on Mean Synodic Month, 2000 AD mean solar days.
* @type {number}
*/
const SYNODIC_MONTH = 29.53058770576;
var Time = /*#__PURE__*/Object.freeze({
__proto__: null,
EPOCH: EPOCH,
LUNATION_BASE_JULIAN_DAY: LUNATION_BASE_JULIAN_DAY,
PHASE_LENGTH: PHASE_LENGTH,
ANOMALISTIC_MONTH: ANOMALISTIC_MONTH,
SYNODIC_MONTH: SYNODIC_MONTH
});
/**
* Normalization utility for percentage calculations.
*
* @param {number} value Percent value.
* @returns {number} Normalized value
*/
const normalize = (value) => {
value -= Math.floor(value);
if (value < 0) {
value += 1;
}
return value;
};
/**
* Julian day from Gregorian date.
* @param {Date} date Gregorian date to convert to Julian day.
* @returns {number} Julian Day
*/
const fromDate = (date = new Date()) => {
const time = date.getTime();
return time / 86400000 - date.getTimezoneOffset() / 1440 + EPOCH;
};
/**
* Gregorian date from Julian day
* @param {number} julian Julian dat to convert to Gregorian date
* @returns {Date} Gregorian date
*/
const toDate = (julian) => {
let date = new Date();
date.setTime((julian - EPOCH + date.getTimezoneOffset() / 1440) * 86400000);
return date;
};
var JulianDay = /*#__PURE__*/Object.freeze({
__proto__: null,
fromDate: fromDate,
toDate: toDate
});
/**
* Moon's age, or Earth days since the last new moon.
*
* @param {Date} date Date used for calculation.
* @returns {number} Age of the moon, normalized within a 29.53059 Earth days calendar.
*/
const lunarAge = (date = new Date()) => {
const percent = lunarAgePercent(date);
return percent * SYNODIC_MONTH;
};
/**
* Percentage through the lunar synodic month.
*
* @param {Date} date Date used for calculation.
* @returns {number} Percentage through the lunar month.
*/
const lunarAgePercent = (date = new Date()) => {
return normalize((fromDate(date) - 2451550.1) / SYNODIC_MONTH);
};
/**
* Brown Lunation Number (BLN), per Ernest William Brown's lunar theory,
* defining Lunation 1 as the first new moon of 1923 at
* approximately 02:41 UTC, January 17, 1923.
*
* @param {Date} date Date used for calculation.
* @returns {number} Lunation Number
*/
const lunationNumber = (date = new Date()) => {
return Math.round((fromDate(date) - LUNATION_BASE_JULIAN_DAY) / SYNODIC_MONTH) + 1;
};
/**
* Distance to the moon measured in units of Earth radii, with
* perigee at 56 and apogee at 63.8.
*
* @param {Date} date Date used for calculation
* @returns {number} Distance to the moon in Earth radii
*/
const lunarDistance = (date = new Date()) => {
const julian = fromDate(date);
const agePercent = lunarAgePercent(date);
const radians = agePercent * 2 * Math.PI;
const percent = 2 * Math.PI * normalize((julian - 2451562.2) / ANOMALISTIC_MONTH);
return 60.4 - 3.3 * Math.cos(percent) - 0.6 * Math.cos(2 * radians - percent) - 0.5 * Math.cos(2 * radians);
};
/**
* Name of the lunar phase per date submitted.
*
* @param {Date} date Date used to calculate lunar phase.
* @returns {string} Name as string of the current lunar phase.
*/
const lunarPhase = (date = new Date()) => {
const age = lunarAge(date);
if (age < 1.84566173161) return LunarPhase.NEW;
else if (age < 5.53698519483) return LunarPhase.WAXING_CRESCENT;
else if (age < 9.22830865805) return LunarPhase.FIRST_QUARTER;
else if (age < 12.91963212127) return LunarPhase.WAXING_GIBBOUS;
else if (age < 16.61095558449) return LunarPhase.FULL;
else if (age < 20.30227904771) return LunarPhase.WANING_GIBBOUS;
else if (age < 23.99360251093) return LunarPhase.LAST_QUARTER;
else if (age < 27.68492597415) return LunarPhase.WANING_CRESCENT;
return LunarPhase.NEW;
};
/**
* Emoji of the lunar phase per date submitted.
*
* @param {Date} date Date used to calculate lunar phase.
* @param {Hemisphere} hemisphere Northern or Southern Hemisphere.
* @returns Emoji of the current lunar phase.
*/
const lunarPhaseEmoji = (date = new Date(), hemisphere = Hemisphere.NORTHERN) => {
const phase = lunarPhase(date);
return emojiForLunarPhase(phase, hemisphere);
};
/**
* Emoji for specified lunar phase.
*
* @param {LunarPhase} phase Lunar phase, per the LunarPhase enum
* @param {Hemisphere} hemisphere Northern or Southern Hemisphere.
* @returns {string} Emoji of the current lunar phase.
*/
const emojiForLunarPhase = (phase, hemisphere = Hemisphere.NORTHERN) => {
let emoji;
if (hemisphere === Hemisphere.SOUTHERN) {
emoji = LunarEmoji.SouthernHemisphere;
} else {
emoji = LunarEmoji.NorthernHemisphere;
}
switch (phase) {
case LunarPhase.WANING_CRESCENT:
return emoji["WANING_CRESCENT"];
case LunarPhase.LAST_QUARTER:
return emoji["LAST_QUARTER"];
case LunarPhase.WANING_GIBBOUS:
return emoji["WANING_GIBBOUS"];
case LunarPhase.FULL:
return emoji["FULL"];
case LunarPhase.WAXING_GIBBOUS:
return emoji["WAXING_GIBBOUS"];
case LunarPhase.FIRST_QUARTER:
return emoji["FIRST_QUARTER"];
case LunarPhase.WAXING_CRESCENT:
return emoji["WAXING_CRESCENT"];
default:
case LunarPhase.NEW:
return emoji["NEW"];
}
};
/**
* Whether the moon is currently waxing (growing).
*
* @param {Date} date Date used for calculation.
* @returns {boolean} True if moon is waxing.
*/
const isWaxing = (date = new Date()) => {
const age = lunarAge(date);
return age <= 14.765;
};
/**
* Whether the moon is currently waning (shrinking).
*
* @param {Date} date Date used for calculation.
* @returns {boolean} True if moon is waning.
*/
const isWaning = (date = new Date()) => {
const age = lunarAge(date);
return age > 14.765;
};
var Moon = /*#__PURE__*/Object.freeze({
__proto__: null,
lunarAge: lunarAge,
lunarAgePercent: lunarAgePercent,
lunationNumber: lunationNumber,
lunarDistance: lunarDistance,
lunarPhase: lunarPhase,
lunarPhaseEmoji: lunarPhaseEmoji,
emojiForLunarPhase: emojiForLunarPhase,
isWaxing: isWaxing,
isWaning: isWaning
});
exports.Hemisphere = Hemisphere;
exports.JulianDay = JulianDay;
exports.LunarEmoji = LunarEmoji;
exports.LunarMonth = LunarMonth;
exports.LunarPhase = LunarPhase;
exports.Moon = Moon;
exports.Time = Time;
exports.Unit = Unit;
//# sourceMappingURL=lunarphase-js.js.map

File diff suppressed because one or more lines are too long

View File

@ -1,335 +0,0 @@
/**
* Earth's hemispheres.
*
* @typedef {string} Hemisphere
* @enum {Hemisphere}
*/
const Hemisphere = {
NORTHERN: "Northern",
SOUTHERN: "Southern",
};
/**
* Enumeration of lunar phases as emoji
*
* @typedef {string} LunarEmoji
*/
const LunarEmoji = {
/**
* Enumeration of lunar phases as emoji for the Northern Hemisphere.
* @num {LunarPhase}
*/
NorthernHemisphere: {
NEW: "🌑",
WAXING_CRESCENT: "🌒",
FIRST_QUARTER: "🌓",
WAXING_GIBBOUS: "🌔",
FULL: "🌕",
WANING_GIBBOUS: "🌖",
LAST_QUARTER: "🌗",
WANING_CRESCENT: "🌘",
},
/**
* Enumeration of lunar phases as emoji for the Southern Hemisphere.
* @num {LunarPhase}
*/
SouthernHemisphere: {
NEW: "🌑",
WAXING_CRESCENT: "🌘",
FIRST_QUARTER: "🌗",
WAXING_GIBBOUS: "🌖",
FULL: "🌕",
WANING_GIBBOUS: "🌔",
LAST_QUARTER: "🌓",
WANING_CRESCENT: "🌒",
},
};
/**
* Lunar month, time between two successive syzygies of the
* same type: new moons or full moons
*
* @typedef {string} LunarMonth
* @enum {LunarMonth}
*/
const LunarMonth = {
ANOMALISTIC: "Anomalistic",
DRACONIC: "Draconic",
SIDEREAL: "Sidereal",
SYNODIC: "Synodic",
TROPICAL: "Tropical",
};
/**
* Enumeration of lunar phases
*
* @typedef {string} LunarPhase
* @enum {LunarPhase}
*/
const LunarPhase = {
NEW: "New",
WAXING_CRESCENT: "Waxing Crescent",
FIRST_QUARTER: "First Quarter",
WAXING_GIBBOUS: "Waxing Gibbous",
FULL: "Full",
WANING_GIBBOUS: "Waning Gibbous",
LAST_QUARTER: "Last Quarter",
WANING_CRESCENT: "Waning Crescent",
};
/**
* Units of measure
*
* @typedef {string} Unit
* @enum {Unit}
*/
const Unit = {
EARTH_RADII: "Earth Radii",
KILOMETERS: "km",
MILES: "m",
};
/**
* Timestamp epoch, January 1, 1970, in Julian Days.
* @type {number}
*/
const EPOCH = 2440587.5;
/**
* Lunation 1 as the first new moon of 1923 at approximately
* 02:41 UTC, January 17, 1923 per Ernest William Brown's lunar theory.
* @type {number}
*/
const LUNATION_BASE_JULIAN_DAY = 2423436.6115277777;
/**
* Length of one phase (1/8 of a synodic month) in Earth days.
* @type {number}
*/
const PHASE_LENGTH = 3.69132346322;
/**
* Orbital period of the Moon from perigee to apogee and back to perigee
* @type {number}
*/
const ANOMALISTIC_MONTH = 27.55454988;
/**
* Length of one synodic month - lunation, or days for the phases to complete a cycle.
* Time between two identical syzygies, equivalent of 29.53059 Earth days.
*
* Based on Mean Synodic Month, 2000 AD mean solar days.
* @type {number}
*/
const SYNODIC_MONTH = 29.53058770576;
var Time = /*#__PURE__*/Object.freeze({
__proto__: null,
EPOCH: EPOCH,
LUNATION_BASE_JULIAN_DAY: LUNATION_BASE_JULIAN_DAY,
PHASE_LENGTH: PHASE_LENGTH,
ANOMALISTIC_MONTH: ANOMALISTIC_MONTH,
SYNODIC_MONTH: SYNODIC_MONTH
});
/**
* Normalization utility for percentage calculations.
*
* @param {number} value Percent value.
* @returns {number} Normalized value
*/
const normalize = (value) => {
value -= Math.floor(value);
if (value < 0) {
value += 1;
}
return value;
};
/**
* Julian day from Gregorian date.
* @param {Date} date Gregorian date to convert to Julian day.
* @returns {number} Julian Day
*/
const fromDate = (date = new Date()) => {
const time = date.getTime();
return time / 86400000 - date.getTimezoneOffset() / 1440 + EPOCH;
};
/**
* Gregorian date from Julian day
* @param {number} julian Julian dat to convert to Gregorian date
* @returns {Date} Gregorian date
*/
const toDate = (julian) => {
let date = new Date();
date.setTime((julian - EPOCH + date.getTimezoneOffset() / 1440) * 86400000);
return date;
};
var JulianDay = /*#__PURE__*/Object.freeze({
__proto__: null,
fromDate: fromDate,
toDate: toDate
});
/**
* Moon's age, or Earth days since the last new moon.
*
* @param {Date} date Date used for calculation.
* @returns {number} Age of the moon, normalized within a 29.53059 Earth days calendar.
*/
const lunarAge = (date = new Date()) => {
const percent = lunarAgePercent(date);
return percent * SYNODIC_MONTH;
};
/**
* Percentage through the lunar synodic month.
*
* @param {Date} date Date used for calculation.
* @returns {number} Percentage through the lunar month.
*/
const lunarAgePercent = (date = new Date()) => {
return normalize((fromDate(date) - 2451550.1) / SYNODIC_MONTH);
};
/**
* Brown Lunation Number (BLN), per Ernest William Brown's lunar theory,
* defining Lunation 1 as the first new moon of 1923 at
* approximately 02:41 UTC, January 17, 1923.
*
* @param {Date} date Date used for calculation.
* @returns {number} Lunation Number
*/
const lunationNumber = (date = new Date()) => {
return Math.round((fromDate(date) - LUNATION_BASE_JULIAN_DAY) / SYNODIC_MONTH) + 1;
};
/**
* Distance to the moon measured in units of Earth radii, with
* perigee at 56 and apogee at 63.8.
*
* @param {Date} date Date used for calculation
* @returns {number} Distance to the moon in Earth radii
*/
const lunarDistance = (date = new Date()) => {
const julian = fromDate(date);
const agePercent = lunarAgePercent(date);
const radians = agePercent * 2 * Math.PI;
const percent = 2 * Math.PI * normalize((julian - 2451562.2) / ANOMALISTIC_MONTH);
return 60.4 - 3.3 * Math.cos(percent) - 0.6 * Math.cos(2 * radians - percent) - 0.5 * Math.cos(2 * radians);
};
/**
* Name of the lunar phase per date submitted.
*
* @param {Date} date Date used to calculate lunar phase.
* @returns {string} Name as string of the current lunar phase.
*/
const lunarPhase = (date = new Date()) => {
const age = lunarAge(date);
if (age < 1.84566173161) return LunarPhase.NEW;
else if (age < 5.53698519483) return LunarPhase.WAXING_CRESCENT;
else if (age < 9.22830865805) return LunarPhase.FIRST_QUARTER;
else if (age < 12.91963212127) return LunarPhase.WAXING_GIBBOUS;
else if (age < 16.61095558449) return LunarPhase.FULL;
else if (age < 20.30227904771) return LunarPhase.WANING_GIBBOUS;
else if (age < 23.99360251093) return LunarPhase.LAST_QUARTER;
else if (age < 27.68492597415) return LunarPhase.WANING_CRESCENT;
return LunarPhase.NEW;
};
/**
* Emoji of the lunar phase per date submitted.
*
* @param {Date} date Date used to calculate lunar phase.
* @param {Hemisphere} hemisphere Northern or Southern Hemisphere.
* @returns Emoji of the current lunar phase.
*/
const lunarPhaseEmoji = (date = new Date(), hemisphere = Hemisphere.NORTHERN) => {
const phase = lunarPhase(date);
return emojiForLunarPhase(phase, hemisphere);
};
/**
* Emoji for specified lunar phase.
*
* @param {LunarPhase} phase Lunar phase, per the LunarPhase enum
* @param {Hemisphere} hemisphere Northern or Southern Hemisphere.
* @returns {string} Emoji of the current lunar phase.
*/
const emojiForLunarPhase = (phase, hemisphere = Hemisphere.NORTHERN) => {
let emoji;
if (hemisphere === Hemisphere.SOUTHERN) {
emoji = LunarEmoji.SouthernHemisphere;
} else {
emoji = LunarEmoji.NorthernHemisphere;
}
switch (phase) {
case LunarPhase.WANING_CRESCENT:
return emoji["WANING_CRESCENT"];
case LunarPhase.LAST_QUARTER:
return emoji["LAST_QUARTER"];
case LunarPhase.WANING_GIBBOUS:
return emoji["WANING_GIBBOUS"];
case LunarPhase.FULL:
return emoji["FULL"];
case LunarPhase.WAXING_GIBBOUS:
return emoji["WAXING_GIBBOUS"];
case LunarPhase.FIRST_QUARTER:
return emoji["FIRST_QUARTER"];
case LunarPhase.WAXING_CRESCENT:
return emoji["WAXING_CRESCENT"];
default:
case LunarPhase.NEW:
return emoji["NEW"];
}
};
/**
* Whether the moon is currently waxing (growing).
*
* @param {Date} date Date used for calculation.
* @returns {boolean} True if moon is waxing.
*/
const isWaxing = (date = new Date()) => {
const age = lunarAge(date);
return age <= 14.765;
};
/**
* Whether the moon is currently waning (shrinking).
*
* @param {Date} date Date used for calculation.
* @returns {boolean} True if moon is waning.
*/
const isWaning = (date = new Date()) => {
const age = lunarAge(date);
return age > 14.765;
};
var Moon = /*#__PURE__*/Object.freeze({
__proto__: null,
lunarAge: lunarAge,
lunarAgePercent: lunarAgePercent,
lunationNumber: lunationNumber,
lunarDistance: lunarDistance,
lunarPhase: lunarPhase,
lunarPhaseEmoji: lunarPhaseEmoji,
emojiForLunarPhase: emojiForLunarPhase,
isWaxing: isWaxing,
isWaning: isWaning
});
export { Hemisphere, JulianDay, LunarEmoji, LunarMonth, LunarPhase, Moon, Time, Unit };
//# sourceMappingURL=lunarphase-js.js.map

File diff suppressed because one or more lines are too long

View File

@ -1,48 +0,0 @@
{
"name": "lunarphase-js",
"version": "1.0.10",
"description": "Calculate phase of the moon using Julian date",
"author": "Jason Sturges <jason@jsonsturges.com> (https://jasonsturges.com)",
"homepage": "https://jasonsturges.github.io/lunarphase-js/",
"repository": {
"type": "git",
"url": "https://github.com/jasonsturges/lunarphase-js"
},
"license": "ISC",
"keywords": [
"astronomy",
"moon",
"lunar",
"phase"
],
"main": "dist/cjs/lunarphase-js.js",
"module": "dist/esm/lunarphase-js.js",
"browser": "dist/browser/lunarphase-js..js",
"files": [
"dist"
],
"scripts": {
"dev": "rollup -c -w",
"build": "rollup -c",
"prebuild:types": "rimraf ./build",
"build:types": "tsc -p ./tsconfig.json --outDir build && api-extractor run",
"predoc:jsdoc": "rimraf ./docs",
"docs:jsdoc": "jsdoc -r src/*s -R README.md -d ./docs",
"predoc:typedoc": "rimraf ./docs",
"docs:typedoc": "typedoc src --out docs",
"clean": "rimraf ./build ./dist ./docs",
"test": "echo \"Error: no test specified\" && exit 1"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.19.4",
"@rollup/plugin-commonjs": "^21.0.1",
"@rollup/plugin-node-resolve": "^13.1.3",
"eslint": "^8.9.0",
"jsdoc": "^3.6.10",
"prettier": "^2.5.1",
"rimraf": "^3.0.2",
"rollup": "^2.67.2",
"typedoc": "^0.22.11",
"typescript": "^4.5.5"
}
}

View File

@ -1,3 +0,0 @@
import * as Moon from 'lunarphase-js';
const phase = Moon.getLunarPhase();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

View File

@ -1 +0,0 @@
@import url("https://cdn.jsdelivr.net/npm/@xz/fonts@1/serve/cascadia-code.min.css");.container{margin:auto;width:75%;padding:12%}body{background-image:url("siteBackground.png");color:#d9d7d6;font-family:'Cascadia Code', sans-serif;font-size:100%}body{outline-style:solid;outline-width:2px;outline-color:#8CD7AA;outline-offset:-50px;padding:0 0.7em 0}hr{border-top:2px solid #DF5B61;border-radius:2px}li{list-style-type:"\03BB";list-style-position:outside;color:#78B892;padding-left:10px}img{height:20%;width:20%}div{width:50%}a{font-size:100%}a:link{color:#E9967E}a:visited{color:#BC83E3}a:hover{color:hotpink}a:active{color:blue}.title{font-size:170%}