pub struct Location {
pub(crate) latitude: f64,
pub(crate) longitude: f64,
pub(crate) elevation: f64,
pub(crate) utc_offset: 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: f64latitude from -90 to 90
longitude: f64longitude from -180 to 180
elevation: f64elevation in meters
utc_offset: f64UTC timezone offset in fractional days (1 hr = 1.0 / 24.0 day), within the range (-12.0 / 24.0) to (14.0 / 24.0)
Implementations§
Source§impl Location
impl Location
Sourcepub fn try_new(
latitude: f64,
longitude: f64,
elevation: f64,
utc_offset: f64,
) -> Result<Location, LocationOutOfBoundsError>
pub fn try_new( latitude: f64, longitude: f64, elevation: f64, utc_offset: f64, ) -> Result<Location, LocationOutOfBoundsError>
Create a location; latitude is from -90 to 90, longitude is from -180 to 180,
and utc_offset is from (-12.0 / 24.0) to (14.0 / 24.0);
attempting to create a location outside of these bounds will result in a LocationOutOfBoundsError.
Sourcepub(crate) fn zone_from_longitude(longitude: f64) -> f64
pub(crate) 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(crate) fn standard_from_local(
standard_time: Moment,
location: Location,
) -> Moment
pub(crate) 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(crate) fn universal_from_local(
local_time: Moment,
location: Location,
) -> Moment
pub(crate) 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(crate) fn local_from_universal(
universal_time: Moment,
location: Location,
) -> Moment
pub(crate) 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(crate) fn universal_from_standard(
standard_moment: Moment,
location: Location,
) -> Moment
pub(crate) 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(crate) fn standard_from_universal(
standard_time: Moment,
location: Location,
) -> Moment
pub(crate) 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