@openwaters/almanac 0.8.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/events.d.ts +2 -0
- package/dist/events.js +7 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -71,6 +71,8 @@ Migration guides for [SunCalc](docs/migrating-from-suncalc.md), [Astronomy Engin
|
|
|
71
71
|
|
|
72
72
|
Angles use degrees. All three ports provide `degreesToRadians(angle)` and `radiansToDegrees(angle)` for callers that use radians. These functions preserve sign and full turns without wrapping or changing the angle's origin; non-finite inputs and conversion overflow raise validation errors. Swift calls use `try`.
|
|
73
73
|
|
|
74
|
+
For an instantaneous day/night decision, `sunIsUp(time, observer, heightAboveGroundM = 0)` uses the same upper-limb convention as sunrise and sunset, including polar periods. See the [day/night recipe](docs/cookbook.md).
|
|
75
|
+
|
|
74
76
|
### JavaScript module loading
|
|
75
77
|
|
|
76
78
|
The npm package is ESM and has no separate CommonJS build. Use Node 22.12 or later for the Node examples; CI and release checks load the packed package on Node 22.12 and Node 24. Browser applications can import it through their ESM bundler.
|
|
@@ -198,7 +200,7 @@ print(try equationOfTime(today)) // sundial minus clock, minutes
|
|
|
198
200
|
|
|
199
201
|
### Kotlin/JVM and Android
|
|
200
202
|
|
|
201
|
-
The Kotlin library provides the same
|
|
203
|
+
The Kotlin library provides the same 38 functions and result fields, using `java.time.Instant` and immutable data classes. It targets JVM 8 and Android minSdk 26, builds with JDK 17, and has no runtime dependencies beyond the Kotlin standard library and platform APIs. Maven publication and a Kotlin benchmark runner are deferred; consume the source at a reviewed Git SHA as described in [`kotlin/README.md`](kotlin/README.md).
|
|
202
204
|
|
|
203
205
|
```kotlin
|
|
204
206
|
import io.openwaters.almanac.*
|
package/dist/events.d.ts
CHANGED
|
@@ -69,6 +69,8 @@ export declare function quantizedUt(ut: number): number;
|
|
|
69
69
|
export declare function assertReached(condition: boolean, what: string): void;
|
|
70
70
|
/** Wrap a hour-angle difference into (−180, 180]. */
|
|
71
71
|
export declare function angleOffset(diff: number): number;
|
|
72
|
+
/** Whether the Sun's upper limb is above the modeled horizon, using the sunrise/set convention. */
|
|
73
|
+
export declare function sunIsUp(time: Date, observer: Observer, heightAboveGroundM?: number): boolean;
|
|
72
74
|
/**
|
|
73
75
|
* Sun rise, set, the three twilights and upper transit within the half-open
|
|
74
76
|
* window `[startUtc, endUtc)`, sorted ascending.
|
package/dist/events.js
CHANGED
|
@@ -478,6 +478,13 @@ const MOON_LEVELS = [
|
|
|
478
478
|
function flatCycle(observer) {
|
|
479
479
|
return Math.abs(observer.latitudeDeg) >= FLAT_CYCLE_LATITUDE_DEG;
|
|
480
480
|
}
|
|
481
|
+
/** Whether the Sun's upper limb is above the modeled horizon, using the sunrise/set convention. */
|
|
482
|
+
export function sunIsUp(time, observer, heightAboveGroundM = 0) {
|
|
483
|
+
assertSupported(time);
|
|
484
|
+
const dip = horizonDip(observer, heightAboveGroundM);
|
|
485
|
+
const sample = sunSampler(observer, dip)(utDays(time));
|
|
486
|
+
return sample.altDeg > sample.riseSetAltDeg;
|
|
487
|
+
}
|
|
481
488
|
/**
|
|
482
489
|
* Sun rise, set, the three twilights and upper transit within the half-open
|
|
483
490
|
* window `[startUtc, endUtc)`, sorted ascending.
|
package/dist/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export { sunAltAz, moonAltAz, starAltAz } from './transforms.js';
|
|
|
15
15
|
export type { MoonIllumination, MoonOrientation } from './illumination.js';
|
|
16
16
|
export { moonIllumination, moonOrientation } from './illumination.js';
|
|
17
17
|
export type { SunEvent, SunEventKind, MoonEvent, MoonEventKind, MoonPhaseEvent, MoonPhaseName, PlanetEvent, PlanetEventKind, AltitudeEvent, AltitudeEventKind, TransitEvent, TransitEventKind } from './events.js';
|
|
18
|
-
export { sunEvents, moonEvents, searchMoonPhases, planetEvents, sunAltitudeEvents, sunTransits, moonTransits } from './events.js';
|
|
18
|
+
export { sunIsUp, sunEvents, moonEvents, searchMoonPhases, planetEvents, sunAltitudeEvents, sunTransits, moonTransits } from './events.js';
|
|
19
19
|
export type { LunarEclipse, LunarEclipseVisibility } from './eclipse.js';
|
|
20
20
|
export { nextLunarEclipse, previousLunarEclipse, lunarEclipses, lunarEclipseVisibility } from './eclipse.js';
|
|
21
21
|
export type { SolarEclipse, SolarEclipseKind, SolarEclipseSunAltitudes } from './solar.js';
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ export { seasons } from './seasons.js';
|
|
|
8
8
|
export { moonApsides } from './apsides.js';
|
|
9
9
|
export { sunAltAz, moonAltAz, starAltAz } from './transforms.js';
|
|
10
10
|
export { moonIllumination, moonOrientation } from './illumination.js';
|
|
11
|
-
export { sunEvents, moonEvents, searchMoonPhases, planetEvents, sunAltitudeEvents, sunTransits, moonTransits } from './events.js';
|
|
11
|
+
export { sunIsUp, sunEvents, moonEvents, searchMoonPhases, planetEvents, sunAltitudeEvents, sunTransits, moonTransits } from './events.js';
|
|
12
12
|
export { nextLunarEclipse, previousLunarEclipse, lunarEclipses, lunarEclipseVisibility } from './eclipse.js';
|
|
13
13
|
export { nextSolarEclipse, previousSolarEclipse, solarEclipses, solarObscuration } from './solar.js';
|
|
14
14
|
export { nextGlobalSolarEclipse, previousGlobalSolarEclipse, globalSolarEclipses, solarEclipseAxisPoint, solarEclipseCentralLine } from './globalSolar.js';
|