@openwaters/almanac 0.8.1 → 0.10.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 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.
@@ -155,8 +157,10 @@ const crossings = sunEvents(today, tomorrow, viewer, eyeHeightM);
155
157
 
156
158
  ### Swift
157
159
 
160
+ Requires a Swift 6 or newer toolchain.
161
+
158
162
  ```swift
159
- .package(url: "https://github.com/openwatersio/almanac.git", exact: "0.8.0")
163
+ .package(url: "https://github.com/openwatersio/almanac.git", exact: "0.10.0")
160
164
  ```
161
165
 
162
166
  ```swift
@@ -198,7 +202,7 @@ print(try equationOfTime(today)) // sundial minus clock, minutes
198
202
 
199
203
  ### Kotlin/JVM and Android
200
204
 
201
- The Kotlin library provides the same 37 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).
205
+ 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
206
 
203
207
  ```kotlin
204
208
  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';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openwaters/almanac",
3
- "version": "0.8.1",
3
+ "version": "0.10.0",
4
4
  "description": "Offline astronomy: Sun, Moon and planet positions, apparent horizon, rise/set, phases and eclipses.",
5
5
  "license": "MIT",
6
6
  "repository": {