[][src]Function esbat::lunar_phase

pub fn lunar_phase<Tz: TimeZone>(t: DateTime<Tz>) -> f64

Calculates the lunar phase for a given moment.

This determines the difference in longitudes of the Sun and the Moon, in degrees, for the moment t. The result is clamped to 0° ≤ x < 360°.

The new moon is 0°, the first-quarter moon is 90°, the full moon is 180°, and the last-quarter moon is 270°.

use chrono::{DateTime, TimeZone, Utc};
use esbat::lunar_phase;

let t = Utc.ymd(2020, 10, 31).and_hms_milli(14, 48, 59, 300);
assert!((lunar_phase(t) - 180.0).abs() < 0.00001);