rust-zmanim 0.2.1

Rust Zmanim Library
Documentation
//! Geolocation struct, with some math for [local mean
//! time](crate::astronomical_calculator::local_mean_time)
use crate::util::math_helper::HOUR_MINUTES;
use jiff::tz::TimeZone;

#[derive(Debug, Clone, PartialEq)]
/// A struct that contains location information such as latitude and longitude
/// required for astronomical calculations. The elevation field may be ignored
/// by calculations that do not account for elevation.
pub struct GeoLocation {
    /// The latitude in the World Geodetic System, or degrees North of the
    /// Equator
    pub latitude: f64,
    /// The longitude in the World Geodetic System, or degrees East of the IERS
    /// Reference Meridian
    pub longitude: f64,
    /// The elevation in meters above sea level
    pub elevation: f64,
    /// The location's time zone
    pub timezone: TimeZone,
}
impl GeoLocation {
    /// Returns the location's local mean time offset from UTC in hours. The
    /// globe is split into 360°, with 15° per hour of the day. For a
    /// location that is at a longitude evenly divisible by 15 (`longitude
    /// % 15 == 0`), at solar noon (with adjustment for the equation of time)
    /// the sun should be directly overhead, so a user who is 1° west of
    /// this will have noon at 4 minutes after standard time noon, and
    /// conversely, a user who is 1° east of the 15° longitude will have
    /// noon at 11:56 AM. Lakewood, N.J., whose longitude is -74.222, is 0.778
    /// away from the closest multiple of 15 at -75°. This is multiplied by
    /// 4 to yield 3 minutes and 7 seconds earlier than standard time. The
    /// offset returned does not account for the daylight saving time offset
    /// since this struct is unaware of dates.
    #[must_use]
    pub fn local_mean_time_offset(&self) -> f64 {
        (self.longitude * 4.0) / HOUR_MINUTES
    }
}