Struct calendrical_calculations::astronomy::Location
source · pub struct Location {
pub latitude: f64,
pub longitude: f64,
pub elevation: f64,
pub zone: f64,
}
Expand description
A Location on the Earth given as a latitude, longitude, elevation, and standard time zone. Latitude is given in degrees from -90 to 90, longitude in degrees from -180 to 180, elevation in meters, and zone as a UTC offset in fractional days (ex. UTC+1 would have zone = 1.0 / 24.0)
Fields§
§latitude: f64
latitude from -90 to 90
longitude: f64
longitude from -180 to 180
elevation: f64
elevation in meters
zone: f64
UTC timezone offset in fractional days (1 hr = 1.0 / 24.0 day)
Implementations§
source§impl Location
impl Location
sourcepub fn try_new(
latitude: f64,
longitude: f64,
elevation: f64,
zone: f64,
) -> Result<Location, LocationOutOfBoundsError>
pub fn try_new( latitude: f64, longitude: f64, elevation: f64, zone: f64, ) -> Result<Location, LocationOutOfBoundsError>
Create a location; latitude is from -90 to 90, and longitude is from -180 to 180; attempting to create a location outside of these bounds will result in a LocationOutOfBoundsError.
sourcepub const fn new_unchecked(
latitude: f64,
longitude: f64,
elevation: f64,
zone: f64,
) -> Location
pub const fn new_unchecked( latitude: f64, longitude: f64, elevation: f64, zone: f64, ) -> Location
Create a new Location without checking for bounds
sourcepub fn zone_from_longitude(longitude: f64) -> f64
pub fn zone_from_longitude(longitude: f64) -> f64
Convert a longitude into a mean time zone; this yields the difference in Moment given a longitude e.g. a longitude of 90 degrees is 0.25 (90 / 360) days ahead of a location with a longitude of 0 degrees.
sourcepub fn standard_from_local(standard_time: Moment, location: Location) -> Moment
pub fn standard_from_local(standard_time: Moment, location: Location) -> Moment
Convert standard time to local mean time given a location and a time zone with given offset
Based on functions from Calendrical Calculations by Reingold & Dershowitz. Reference lisp code: https://github.com/EdReingold/calendar-code2/blob/9afc1f3/calendar.l#L3501-L3506
sourcepub fn universal_from_local(local_time: Moment, location: Location) -> Moment
pub fn universal_from_local(local_time: Moment, location: Location) -> Moment
Convert from local mean time to universal time given a location
Based on functions from Calendrical Calculations by Reingold & Dershowitz. Reference lisp code: https://github.com/EdReingold/calendar-code2/blob/9afc1f3/calendar.l#L3496-L3499
sourcepub fn local_from_universal(
universal_time: Moment,
location: Location,
) -> Moment
pub fn local_from_universal( universal_time: Moment, location: Location, ) -> Moment
Convert from universal time to local time given a location
Based on functions from Calendrical Calculations by Reingold & Dershowitz. Reference lisp code: https://github.com/EdReingold/calendar-code2/blob/9afc1f3/calendar.l#L3491-L3494
sourcepub fn universal_from_standard(
standard_moment: Moment,
location: Location,
) -> Moment
pub fn universal_from_standard( standard_moment: Moment, location: Location, ) -> Moment
Given a UTC-offset in hours and a Moment in standard time,
return the Moment in universal time from the time zone with the given offset.
The field utc_offset should be within the range of possible offsets given by
the constand fields MIN_UTC_OFFSET
and MAX_UTC_OFFSET
.
Based on functions from Calendrical Calculations by Reingold & Dershowitz. Reference lisp code: https://github.com/EdReingold/calendar-code2/blob/9afc1f3/calendar.l#L3479-L3483
sourcepub fn standard_from_universal(
standard_time: Moment,
location: Location,
) -> Moment
pub fn standard_from_universal( standard_time: Moment, location: Location, ) -> Moment
Given a Moment in standard time and UTC-offset in hours,
return the Moment in standard time from the time zone with the given offset.
The field utc_offset should be within the range of possible offsets given by
the constand fields MIN_UTC_OFFSET
and MAX_UTC_OFFSET
.
Based on functions from Calendrical Calculations by Reingold & Dershowitz. Reference lisp code: https://github.com/EdReingold/calendar-code2/blob/9afc1f3/calendar.l#L3473-L3477