Initial Commit
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
use chrono::{DateTime, Utc};
|
||||
|
||||
/// Compute Julian Date from a UTC datetime.
|
||||
pub fn julian_date(dt: DateTime<Utc>) -> f64 {
|
||||
let unix_seconds = dt.timestamp() as f64;
|
||||
// J2000.0 epoch is 2000-01-01 12:00:00 UTC = Unix 946728000
|
||||
// JD of Unix epoch 0 = 2440587.5
|
||||
unix_seconds / 86400.0 + 2440587.5
|
||||
}
|
||||
|
||||
/// Compute Local Sidereal Time in degrees [0, 360).
|
||||
/// Uses IAU formula via Julian Date and observer longitude.
|
||||
pub fn local_sidereal_time(jd: f64, lon_deg: f64) -> f64 {
|
||||
// Days since J2000.0
|
||||
let d = jd - 2451545.0;
|
||||
// Greenwich Mean Sidereal Time in degrees
|
||||
let gmst_deg = 280.46061837 + 360.98564736629 * d;
|
||||
let lst = (gmst_deg + lon_deg).rem_euclid(360.0);
|
||||
lst
|
||||
}
|
||||
Reference in New Issue
Block a user