| 1 | //! # Time, Date, and Angle Handling |
| 2 | //! |
| 3 | //! This module contains functions for the handling and conversion of Times, Dates, and Angles. |
| 4 | //! |
| 5 | //! This data can be represented in two types: |
| 6 | //! - The [`Angle`] type, which represents anything modulo arithmetic should be used to handle |
| 7 | //! - The [`Date`] type, which represents an instant in continuous time |
| 8 | //! |
| 9 | //! ```rust |
| 10 | //! # use pracstro::*; |
| 11 | //! time::Date::from_calendar(2024, 06, 30, time::Angle::from_clock(16, 30, 0.0)).julian(); // Gets the julian date at 2024-06-30T16:30:00Z |
| 12 | //! ``` |
| 13 | |
| 14 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::f64rust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/::constsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/consts/::{PIrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/consts/PI., TAUrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/consts/TAU.}; |
| 15 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/; |
| 16 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::{Addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#, Divrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#, Mulrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#, Subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#}; |
| 17 | |
| 18 | /** |
| 19 | Angles and Time are the most prominent use for this type |
| 20 | |
| 21 | | Property | To Method | From Method | |
| 22 | |-------------------|-------------------------|------------------------------| |
| 23 | | Degrees (Decimal) | [`Angle::degrees()`] | [`Angle::from_degrees()`] | |
| 24 | | Radians | [`Angle::radians()`] | [`Angle::from_radians()`] | |
| 25 | | Turns (\[0,1\]) | [`Angle::turns()`] | [`Angle::from_turns()`] | |
| 26 | | Hours (Decimal) | [`Angle::decimal()`] | [`Angle::from_decimal()`] | |
| 27 | | Clock Time | [`Angle::clock()`] | [`Angle::from_clock()`] | |
| 28 | | Degrees (DMS) | [`Angle::degminsec()`] | [`Angle::from_degminsec()`] | |
| 29 | | Sine | [`Angle::sin()`] | [`Angle::asin()`] | |
| 30 | | Cosine | [`Angle::cos()`] | [`Angle::acos()`] | |
| 31 | | Tangent | [`Angle::tan()`] | [`Angle::atan2()`] | |
| 32 | |
| 33 | Additional Methods: |
| 34 | * Latitude displaying: [`Angle::to_latitude()`] |
| 35 | * Inverse of angle: [`Angle::inverse()`] |
| 36 | * GST Correction: [`Angle::gst()`] and [`Angle::ungst()`] |
| 37 | * Approx. Atmosphereic Refraction: [`Angle::refract()`] and [`Angle::refractdelta()`] |
| 38 | */ |
| 39 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:)] |
| 40 | pub struct Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#(f64); |
| 41 | impl Anglerust-analyzer cargo pracstro 1.1.1 time/Angle# { |
| 42 | /// Returns the angle as radians. |
| 43 | /// |
| 44 | /// This is the only function that should directly access the fields of the type. |
| 45 | /// ``` |
| 46 | /// # use pracstro::time::Angle; |
| 47 | /// Angle::from_degrees(180.0).radians(); // Pi |
| 48 | /// ``` |
| 49 | pub const fn radiansrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]radians().(self) -> f64 { |
| 50 | self.0rust-analyzer cargo pracstro 1.1.1 time/Angle#0. |
| 51 | } |
| 52 | /// Constructs a angle from radians, reducing it to the range of \[0, 2*PI\]. |
| 53 | /// |
| 54 | /// This is the one of the two only functions that directly access [`Angle`]. |
| 55 | /// Reduction to the desired range is done with Least Positive Residue instead of the remainder operator. |
| 56 | /// ``` |
| 57 | /// # use pracstro::time::Angle; |
| 58 | /// Angle::from_radians(std::f64::consts::PI).degrees(); // 180.0 |
| 59 | /// ``` |
| 60 | pub const fn from_radiansrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_radians().(x: f64) -> Selfrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle] { |
| 61 | const fn lprrust-analyzer cargo pracstro 1.1.1 time/lpr().(x: f64, y: f64) -> f64 { |
| 62 | let z = x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Rem<Self>`]rem().y; |
| 63 | z rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().if z rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().0.0 { y } else { 0.0 } |
| 64 | } |
| 65 | Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#(lprrust-analyzer cargo pracstro 1.1.1 time/lpr().(x, TAUrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/consts/TAU.)) |
| 66 | } |
| 67 | /// Converts angles internally so that formatting them as latitudes makes sense |
| 68 | /// |
| 69 | /// This should be used directly in conjunction with a formatting function. |
| 70 | /// The main use case for this is in coordinate handling where angles of latitude can be negative. |
| 71 | /// This is the only other function that should be able to directly access [`Angle`] than [`Angle::from_radians()`]. |
| 72 | /// ``` |
| 73 | /// # use pracstro::time::Angle; |
| 74 | /// Angle::from_degrees(-25.0).degrees(); // 335.0 |
| 75 | /// Angle::from_degrees(-25.0).to_latitude().degrees(); // -25.0 |
| 76 | /// ``` |
| 77 | pub const fn to_latituderust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]to_latitude().(self) -> Selfrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle] { |
| 78 | match self.radiansrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]radians().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]gt().PIrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/consts/PI. { |
| 79 | true => Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#(self.radiansrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]radians().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().TAUrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/consts/TAU.), |
| 80 | false => self, |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | /// Returns the angle as fractional degrees. |
| 85 | /// |
| 86 | /// A wrapper around [`f64::to_degrees()`] |
| 87 | /// |
| 88 | /// ``` |
| 89 | /// # use pracstro::time::Angle; |
| 90 | /// Angle::from_degrees(-25.0).degrees(); // 335.0 |
| 91 | /// ``` |
| 92 | pub const fn degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]degrees().(self) -> f64 { |
| 93 | self.radiansrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]radians().().to_degreesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]to_degrees().() |
| 94 | } |
| 95 | /// Constructs an angle from fractional degrees. |
| 96 | /// |
| 97 | /// A wrapper around [`f64::to_radians()`] |
| 98 | /// |
| 99 | /// ``` |
| 100 | /// # use pracstro::time::Angle; |
| 101 | /// Angle::from_degrees(-25.0).degrees(); // 335.0 |
| 102 | /// ``` |
| 103 | pub const fn from_degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degrees().(x: f64) -> Selfrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle] { |
| 104 | Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_radiansrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_radians().(x.to_radiansrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]to_radians().()) |
| 105 | } |
| 106 | |
| 107 | /// Returns the angle in the range between 0 and 1 (i.e. turns) |
| 108 | /// |
| 109 | /// Used in the calculation for the illuminated fraction of planets |
| 110 | pub const fn turnsrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]turns().(self) -> f64 { |
| 111 | self.radiansrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]radians().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().TAUrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/consts/TAU. |
| 112 | } |
| 113 | /// Constructs an angle from a value between 0 and 1 |
| 114 | /// |
| 115 | /// Used in the calculation for the illuminated fraction of planets |
| 116 | pub const fn from_turnsrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_turns().(x: f64) -> Selfrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle] { |
| 117 | Selfrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]::from_radiansrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_radians().(x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().TAUrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/consts/TAU.) |
| 118 | } |
| 119 | |
| 120 | /// Returns the angle in fractional number of hours |
| 121 | /// |
| 122 | /// A wrapper around [`Angle::degrees()`] and one division by 15. Since one hour is 15 degrees of rotation |
| 123 | /// ``` |
| 124 | /// # use pracstro::time::Angle; |
| 125 | /// Angle::from_degrees(120.0).decimal(); // 8.0 |
| 126 | /// ``` |
| 127 | pub const fn decimalrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]decimal().(self) -> f64 { |
| 128 | self.degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]degrees().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().15.0 // 1 hour <-> 15 degrees, 360/24 = 15 |
| 129 | } |
| 130 | /// Constructs an angle from a fractional number of hours |
| 131 | /// |
| 132 | /// A wrapper around [`Angle::from_degrees()`] and one multiplication by 15. Since one hour is 15 degrees of rotation |
| 133 | /// ``` |
| 134 | /// # use pracstro::time::Angle; |
| 135 | /// Angle::from_decimal(8.0).degrees(); // 120.00 |
| 136 | /// ``` |
| 137 | pub const fn from_decimalrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_decimal().(x: f64) -> Selfrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle] { |
| 138 | Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degrees().(x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().15.0) |
| 139 | } |
| 140 | |
| 141 | /// Returns (Hour, Minute, Second) of a time/angle |
| 142 | /// |
| 143 | /// Used in hour-angle displays for some coordinate systems, and in times. |
| 144 | /// ``` |
| 145 | /// # use pracstro::time::Angle; |
| 146 | /// Angle::from_decimal(8.0).clock(); // (8, 0, 0.0) |
| 147 | /// ``` |
| 148 | pub fn clockrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]clock().(self) -> (u8, u8, f64) { |
| 149 | let y = self.decimalrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]decimal().(); |
| 150 | ( |
| 151 | y.truncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]trunc().() as u8, |
| 152 | (y.fractrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]fract().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().60.0).truncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]trunc().() as u8, |
| 153 | (y.fractrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]fract().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().60.0).fractrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]fract().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().60.0, |
| 154 | ) |
| 155 | } |
| 156 | /// Constructs an angle out of an hour, minute, and second |
| 157 | /// |
| 158 | /// Used in hour-angle displays for some coordinate systems, and in times. |
| 159 | /// ``` |
| 160 | /// use pracstro::time::Angle; |
| 161 | /// Angle::from_clock(8, 0, 0.0).decimal(); // 8.0 |
| 162 | /// ``` |
| 163 | pub const fn from_clockrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_clock().(h: u8, m: u8, s: f64) -> Selfrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle] { |
| 164 | Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_decimalrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_decimal().((h as f64) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().(((m as f64) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().(s rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().60.0)) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().60.0)) |
| 165 | } |
| 166 | |
| 167 | /// Converts an angle to a degree with arcminutes and arcseconds |
| 168 | pub fn degminsecrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]degminsec().(self) -> (i16, u8, f64) { |
| 169 | let y = self.degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]degrees().(); |
| 170 | ( |
| 171 | y.truncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]trunc().() as i16, |
| 172 | (y.fractrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]fract().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().60.0).truncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]trunc().() as u8, |
| 173 | (y.fractrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]fract().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().60.0).fractrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]fract().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().60.0, |
| 174 | ) |
| 175 | } |
| 176 | /// Identical to from_clock in math |
| 177 | pub const fn from_degminsecrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degminsec().(d: i16, m: u8, s: f64) -> Selfrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle] { |
| 178 | Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degrees().((d as f64) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().(((m as f64) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().(s rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().60.0)) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().60.0)) |
| 179 | } |
| 180 | |
| 181 | /// Handles the discontinuity created by the orbit of the earth as compared to its rotation. |
| 182 | /// |
| 183 | /// Algorithm from Practical Astronomy with Your Calculator, although similar algorithms exist in other sources |
| 184 | pub fn gstrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]gst().(self, date: Daterust-analyzer cargo pracstro 1.1.1 time/Date#) -> Selfrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle] { |
| 185 | let t = date.centuriesrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]centuries().(); |
| 186 | Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_decimalrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_decimal().( |
| 187 | 6.697374558 |
| 188 | +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().(2400.051336 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().t) |
| 189 | +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().(0.000025862 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().(t rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().t)) |
| 190 | +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().(self.decimalrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]decimal().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().1.002737909), |
| 191 | ) |
| 192 | } |
| 193 | /// Handles the discontinuity created by the orbit of the earth as compared to its rotation. |
| 194 | /// |
| 195 | /// Algorithm from Practical Astronomy with Your Calculator, although similar algorithms exist in other sources |
| 196 | pub fn ungstrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]ungst().(self, date: Daterust-analyzer cargo pracstro 1.1.1 time/Date#) -> Selfrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle] { |
| 197 | let t = date.centuriesrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]centuries().(); |
| 198 | let t0 = Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_decimalrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_decimal().(6.697374558 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().(2400.051336 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().t) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().(0.000025862 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().(t rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().t))); |
| 199 | (self rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Sub<Self>`]sub().-rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Sub<Self>`]sub(). rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Sub<Self>`]sub().t0) rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Mul<f64>`]mul().*rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Mul<f64>`]mul(). rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Mul<f64>`]mul().0.9972695663 |
| 200 | } |
| 201 | |
| 202 | /// Sine of Angle |
| 203 | pub fn sinrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]sin().(self) -> f64 { |
| 204 | self.radiansrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]radians().().sinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]sin().() |
| 205 | } |
| 206 | /// Cosine of Angle |
| 207 | pub fn cosrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]cos().(self) -> f64 { |
| 208 | self.radiansrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]radians().().cosrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]cos().() |
| 209 | } |
| 210 | /// Tangent of Angle |
| 211 | pub fn tanrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]tan().(self) -> f64 { |
| 212 | self.radiansrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]radians().().tanrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]tan().() |
| 213 | } |
| 214 | /// Angle from Arcsine |
| 215 | pub fn asinrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]asin().(x: f64) -> Selfrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle] { |
| 216 | Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_radiansrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_radians().(x.asinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]asin().()) |
| 217 | } |
| 218 | /// Angle from Arccosine |
| 219 | pub fn acosrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]acos().(x: f64) -> Selfrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle] { |
| 220 | Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_radiansrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_radians().(x.acosrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]acos().()) |
| 221 | } |
| 222 | /// Angle from 2-argument Arctangent |
| 223 | pub fn atan2rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]atan2().(x: f64, y: f64) -> Selfrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle] { |
| 224 | Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_radiansrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_radians().(x.atan2rust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]atan2().(y)) |
| 225 | } |
| 226 | /// Reverses the angle |
| 227 | pub fn inverserust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]inverse().(self) -> Selfrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle] { |
| 228 | Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_radiansrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_radians().(TAUrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/consts/TAU. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().self.radiansrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]radians().()) |
| 229 | } |
| 230 | |
| 231 | /// Calculates the approximate atmospheric refraction |
| 232 | /// |
| 233 | /// In reality, this is an complex calculation dependent on factors such as temperature and pressure. But it can be |
| 234 | /// Approximated to a reasonable extent assuming some factors. |
| 235 | /// |
| 236 | /// From <https://www.celestialprogramming.com/snippets/atmosphericrefraction.html> |
| 237 | pub fn refractdeltarust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]refractdelta().(self) -> Selfrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle] { |
| 238 | Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degminsecrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degminsec().( |
| 239 | 0, |
| 240 | 0, |
| 241 | (1.02 |
| 242 | /rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().(self.degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]degrees().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().(10.3 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().(self.degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]degrees().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().5.11))) |
| 243 | .to_radiansrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]to_radians().() |
| 244 | .tanrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]tan().()) |
| 245 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().60.0, |
| 246 | ) |
| 247 | } |
| 248 | /// Accounts for atmospheric refraction |
| 249 | /// |
| 250 | /// This does not calculate refraction on altitudes under the horizon |
| 251 | /// |
| 252 | /// This should only be used on the altitude value of a horizontal coordinate. |
| 253 | pub fn refractrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]refract().(self) -> Selfrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle] { |
| 254 | if self.to_latituderust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]to_latitude().().degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]degrees().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]gt().0.0 { |
| 255 | self rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Add<Self>`]add().+rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Add<Self>`]add(). rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Add<Self>`]add().self.refractdeltarust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]refractdelta().() |
| 256 | } else { |
| 257 | self |
| 258 | } |
| 259 | } |
| 260 | } |
| 261 | /// Used in testing |
| 262 | impl fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for Anglerust-analyzer cargo pracstro 1.1.1 time/Angle# { |
| 263 | fn fmtrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][Debug]fmt().(&self, f: &mut fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 264 | let (d, m, s) = self.degminsecrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]degminsec().(); |
| 265 | // Hubble has a resolution of 0.1", this is more than sufficent |
| 266 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "{}°{}'{:.2}\"", d, m, s) |
| 267 | } |
| 268 | } |
| 269 | /// Does not check if arcseconds are equal |
| 270 | impl PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# for Anglerust-analyzer cargo pracstro 1.1.1 time/Angle# { |
| 271 | fn eqrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`PartialEq<Self>`]eq().(&self, other: &Selfrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`PartialEq<Self>`]) -> bool { |
| 272 | let (d, m, _) = self.degminsecrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]degminsec().(); |
| 273 | let (d2, m2, _) = other.degminsecrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]degminsec().(); |
| 274 | d rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().d2 && m rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().m2 |
| 275 | } |
| 276 | } |
| 277 | impl Addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#<Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#> for Anglerust-analyzer cargo pracstro 1.1.1 time/Angle# { |
| 278 | type Outputrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Add<Self>`]Output# = Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#; |
| 279 | /// Addition, For timezones and LST |
| 280 | fn addrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Add<Self>`]add().(self, x: Selfrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Add<Self>`]) -> Selfrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Add<Self>`] { |
| 281 | Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_radiansrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_radians().(self.radiansrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]radians().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().x.radiansrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]radians().()) |
| 282 | } |
| 283 | } |
| 284 | impl Subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#<Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#> for Anglerust-analyzer cargo pracstro 1.1.1 time/Angle# { |
| 285 | type Outputrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Sub<Self>`]Output# = Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#; |
| 286 | /// Subtraction, For timezones and LST |
| 287 | fn subrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Sub<Self>`]sub().(self, x: Selfrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Sub<Self>`]) -> Selfrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Sub<Self>`] { |
| 288 | Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_radiansrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_radians().(self.radiansrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]radians().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().x.radiansrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]radians().()) |
| 289 | } |
| 290 | } |
| 291 | impl Mulrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#<f64> for Anglerust-analyzer cargo pracstro 1.1.1 time/Angle# { |
| 292 | type Outputrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Mul<f64>`]Output# = Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#; |
| 293 | /// Multiplication |
| 294 | fn mulrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Mul<f64>`]mul().(self, x: f64) -> Selfrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Mul<f64>`] { |
| 295 | Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_radiansrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_radians().(self.radiansrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]radians().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().x) |
| 296 | } |
| 297 | } |
| 298 | impl Divrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#<f64> for Anglerust-analyzer cargo pracstro 1.1.1 time/Angle# { |
| 299 | type Outputrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Div<f64>`]Output# = Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#; |
| 300 | /// Multiplication |
| 301 | fn divrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Div<f64>`]div().(self, x: f64) -> Selfrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Div<f64>`] { |
| 302 | Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_radiansrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_radians().(self.radiansrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]radians().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().x) |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | /** |
| 307 | Continuous Instant in Time |
| 308 | |
| 309 | | Property | To Method | From Method | |
| 310 | |-------------------|-----------------------|----------------------------| |
| 311 | | Julian Day | [`Date::julian()`] | [`Date::from_julian()`] | |
| 312 | | Calendar | [`Date::calendar()`] | [`Date::from_calendar()`] | |
| 313 | | Unix Time | [`Date::unix()`] | [`Date::from_unix()`] | |
| 314 | | Date/Time | [`Date::time()`] | [`Date::from_time()`] | |
| 315 | |
| 316 | Additional Methods |
| 317 | * Get the current time: [`Date::now()`] |
| 318 | * Julian Centuries since J2000: [`Date::centuries()`] |
| 319 | */ |
| 320 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:)] |
| 321 | pub struct Daterust-analyzer cargo pracstro 1.1.1 time/Date#(f64); |
| 322 | impl Daterust-analyzer cargo pracstro 1.1.1 time/Date# { |
| 323 | /// Returns time as Julian Days |
| 324 | /// |
| 325 | /// Direct interface to type |
| 326 | /// |
| 327 | /// This is the only function that should directly read the fields of the type |
| 328 | pub const fn julianrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]julian().(self) -> f64 { |
| 329 | self.0rust-analyzer cargo pracstro 1.1.1 time/Date#0. |
| 330 | } |
| 331 | /// Constructs time from Julian Days |
| 332 | /// |
| 333 | /// Direct interface to type |
| 334 | /// |
| 335 | /// This is the only function that should directly write the fields of the type |
| 336 | pub const fn from_julianrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]from_julian().(x: f64) -> Selfrust-analyzer cargo pracstro 1.1.1 time/impl#[Date] { |
| 337 | Daterust-analyzer cargo pracstro 1.1.1 time/Date#(x) |
| 338 | } |
| 339 | |
| 340 | /// Returns Julian Centuries since 1900. |
| 341 | /// |
| 342 | /// Used heavily in astronomical estimation of things that change slowly |
| 343 | pub const fn centuriesrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]centuries().(self) -> f64 { |
| 344 | (self.julianrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]julian().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().2451545.0) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().36525.0 |
| 345 | } |
| 346 | |
| 347 | /// Returns Year, Month, Day (time is Angle::from_decimal(day.fract())) |
| 348 | /// |
| 349 | /// Algorithm from Practical Astronomy with Your Calculator, Although similar algorithms exist in other sources |
| 350 | pub fn calendarrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]calendar().(self) -> (i64, u8, u8, Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#) { |
| 351 | let j = self.julianrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]julian().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().0.5; |
| 352 | let (i, f) = (j.truncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]trunc().(), j.fractrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]fract().()); |
| 353 | |
| 354 | let b = if i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]gt().2_299_160.0 { |
| 355 | let a = ((i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().1867216.25) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().36524.25).truncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]trunc().(); |
| 356 | i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().1.0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().a rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().(a rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().4.0).truncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]trunc().() |
| 357 | } else { |
| 358 | i |
| 359 | } rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().1524.0; |
| 360 | |
| 361 | let d = ((b rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().122.2) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().365.25).truncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]trunc().(); |
| 362 | let e = (365.25 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().d).truncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]trunc().(); |
| 363 | let g = ((b rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().e) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().30.6001).truncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]trunc().(); |
| 364 | |
| 365 | let m = if g rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().13.5 { g rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().1.0 } else { g rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().13.0 }; |
| 366 | let y = if m rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]gt().2.5 { d rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().4716.0 } else { d rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().4715.0 }; |
| 367 | let d = b rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().e rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().f rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().(30.6001 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().g).truncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]trunc().(); |
| 368 | |
| 369 | (y as i64, m as u8, d as u8, Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_turnsrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_turns().(d.fractrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]fract().())) |
| 370 | } |
| 371 | /// Takes Year, Month, and Day |
| 372 | /// |
| 373 | /// Algorithm from Practical Astronomy with Your Calculator, although similar algorithms exist in other sources |
| 374 | pub fn from_calendarrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]from_calendar().(y: i64, m: u8, day: u8, t: Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#) -> Selfrust-analyzer cargo pracstro 1.1.1 time/impl#[Date] { |
| 375 | let (year, month) = if m rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]lt().3 { (y rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub().1, m rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Add<Self>`]add().12) } else { (y, m) }; |
| 376 | |
| 377 | Daterust-analyzer cargo pracstro 1.1.1 time/Date#::from_julianrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]from_julian().( |
| 378 | if year rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialOrd<Self>`]ge().1582 { |
| 379 | 2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub().(year rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Div<Self>`]div().100) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Add<Self>`]add().(year rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Div<Self>`]div().400) |
| 380 | } else { |
| 381 | 0 |
| 382 | } as f64 |
| 383 | +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().(365.25 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().year as f64 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().if year rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialOrd<Self>`]lt().0 { 0.75 } else { 0.0 }).truncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]trunc().() |
| 384 | +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().(30.6001 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().(month rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Add<Self>`]add().1) as f64).truncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]trunc().() |
| 385 | +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().day as f64 |
| 386 | +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().t.turnsrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]turns().() |
| 387 | +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().1_720_994.5, |
| 388 | ) |
| 389 | } |
| 390 | /// Gets the time of day in a current calendar date |
| 391 | pub fn timerust-analyzer cargo pracstro 1.1.1 time/impl#[Date]time().(self) -> Anglerust-analyzer cargo pracstro 1.1.1 time/Angle# { |
| 392 | self.calendarrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]calendar().().3 |
| 393 | } |
| 394 | /// Constructs a date out of a date and a time. |
| 395 | pub fn from_timerust-analyzer cargo pracstro 1.1.1 time/impl#[Date]from_time().(d: Selfrust-analyzer cargo pracstro 1.1.1 time/impl#[Date], t: Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#) -> Selfrust-analyzer cargo pracstro 1.1.1 time/impl#[Date] { |
| 396 | let (y, m, d, _) = d.calendarrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]calendar().(); |
| 397 | Selfrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]::from_calendarrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]from_calendar().(y, m, d, t) |
| 398 | } |
| 399 | |
| 400 | /// Interface for unix time, Does not correct for the 1582 Julain/Gregorian split |
| 401 | pub const fn unixrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]unix().(self) -> f64 { |
| 402 | (self.julianrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]julian().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().2440587.5) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().86400.0 |
| 403 | } |
| 404 | /// Interface for unix time, Does not correct for the 1582 Julain/Gregorian split |
| 405 | pub const fn from_unixrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]from_unix().(t: f64) -> Selfrust-analyzer cargo pracstro 1.1.1 time/impl#[Date] { |
| 406 | Daterust-analyzer cargo pracstro 1.1.1 time/Date#::from_julianrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]from_julian().((t rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().86400.0) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().2440587.5) |
| 407 | } |
| 408 | |
| 409 | /// Gets the current date |
| 410 | /// |
| 411 | /// Since this function relies on SystemTime and duration_since, it does not work for dates before 1970. |
| 412 | pub fn nowrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]now().() -> Selfrust-analyzer cargo pracstro 1.1.1 time/impl#[Date] { |
| 413 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::timerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/::{SystemTimerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/SystemTime#, UNIX_EPOCHrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/UNIX_EPOCH.}; |
| 414 | let now = SystemTimerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/SystemTime#::nowrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[SystemTime]now().() |
| 415 | .duration_sincerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[SystemTime]duration_since().(UNIX_EPOCHrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/UNIX_EPOCH.) |
| 416 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Expected pre-1970-01-01 date") |
| 417 | .as_secsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]as_secs().() as f64; |
| 418 | Daterust-analyzer cargo pracstro 1.1.1 time/Date#::from_unixrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]from_unix().(now) |
| 419 | } |
| 420 | } |
| 421 | |
| 422 | /// Calculate the date of Easter |
| 423 | pub fn easterrust-analyzer cargo pracstro 1.1.1 time/easter().(year: i32) -> (i32, i32) { |
| 424 | let a = year rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Rem<Self>`]rem().19; |
| 425 | let (b, c) = (year rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Div<Self>`]div().100, year rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Rem<Self>`]rem().100); |
| 426 | let d = b rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Div<Self>`]div().4; |
| 427 | let g = (b rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().(b rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().8) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Div<Self>`]div().25 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().1) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Div<Self>`]div().3; |
| 428 | let h = ((19 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().a) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().b rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().d rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().g rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().15) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Rem<Self>`]rem().30; |
| 429 | let l = (32 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().(2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().b rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Rem<Self>`]rem().4) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().(2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Div<Self>`]div().4) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().h rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Rem<Self>`]rem().4) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Rem<Self>`]rem().7; |
| 430 | let m = (a rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().(11 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().h) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().(22 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().l)) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Div<Self>`]div().451; |
| 431 | let n = (h rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().l rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().(7 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().m) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().114) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Div<Self>`]div().31; |
| 432 | let p = (h rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().l rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().(7 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().m) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().114) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Rem<Self>`]rem().31; |
| 433 | (n, p rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().1) |
| 434 | } |
| 435 | |
| 436 | /// Time at epoch J2000 |
| 437 | pub const J2000rust-analyzer cargo pracstro 1.1.1 time/J2000.: Daterust-analyzer cargo pracstro 1.1.1 time/Date# = Daterust-analyzer cargo pracstro 1.1.1 time/Date#::from_julianrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]from_julian().(2451545.0); |
| 438 | |
| 439 | #[cfg(test)] |
| 440 | mod testsrust-analyzer cargo pracstro 1.1.1 time/tests/ { |
| 441 | use superrust-analyzer cargo pracstro 1.1.1 time/::*; |
| 442 | |
| 443 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 444 | fn test_julianrust-analyzer cargo pracstro 1.1.1 time/tests/test_julian().() { |
| 445 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 446 | Daterust-analyzer cargo pracstro 1.1.1 time/Date#::from_julianrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]from_julian().(2_446_113.75), |
| 447 | Daterust-analyzer cargo pracstro 1.1.1 time/Date#::from_calendarrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]from_calendar().(1985, 2, 17, Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_decimalrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_decimal().(6.0)) |
| 448 | ); |
| 449 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 450 | Daterust-analyzer cargo pracstro 1.1.1 time/Date#::from_julianrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]from_julian().(2_446_113.75).calendarrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]calendar().(), |
| 451 | (1985, 2, 17, Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_decimalrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_decimal().(6.0)) |
| 452 | ); |
| 453 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 454 | Daterust-analyzer cargo pracstro 1.1.1 time/Date#::from_calendarrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]from_calendar().(1967, 04, 12, Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_turnsrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_turns().(0.6)) |
| 455 | .timerust-analyzer cargo pracstro 1.1.1 time/impl#[Date]time().() |
| 456 | .decimalrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]decimal().(), |
| 457 | 14.400000002235174 |
| 458 | ); |
| 459 | } |
| 460 | |
| 461 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 462 | fn test_calendarrust-analyzer cargo pracstro 1.1.1 time/tests/test_calendar().() { |
| 463 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 464 | Daterust-analyzer cargo pracstro 1.1.1 time/Date#::from_calendarrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]from_calendar().(1000, 10, 20, Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::defaultrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][Default]default().()).calendarrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]calendar().(), |
| 465 | (1000, 10, 20, Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::defaultrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][Default]default().()) |
| 466 | ); |
| 467 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 468 | Daterust-analyzer cargo pracstro 1.1.1 time/Date#::from_calendarrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]from_calendar().(1000, 14, 20, Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::defaultrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][Default]default().()).calendarrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]calendar().(), |
| 469 | (1001, 2, 20, Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::defaultrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][Default]default().()) |
| 470 | ); |
| 471 | } |
| 472 | |
| 473 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 474 | fn test_decimalhrsrust-analyzer cargo pracstro 1.1.1 time/tests/test_decimalhrs().() { |
| 475 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 476 | Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_clockrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_clock().(18, 31, 27.0), |
| 477 | Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_decimalrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_decimal().(18.52417) |
| 478 | ); |
| 479 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_decimalrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_decimal().(11.75), Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_clockrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_clock().(11, 45, 0.0)); |
| 480 | } |
| 481 | |
| 482 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 483 | fn test_gstrust-analyzer cargo pracstro 1.1.1 time/tests/test_gst().() { |
| 484 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 485 | Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_clockrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_clock().(14, 36, 51.6).gstrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]gst().(Daterust-analyzer cargo pracstro 1.1.1 time/Date#::from_julianrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]from_julian().(2_444_351.5)), |
| 486 | Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_clockrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_clock().(4, 40, 5.23) |
| 487 | ); |
| 488 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 489 | Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_clockrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_clock().(4, 40, 5.23).ungstrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]ungst().(Daterust-analyzer cargo pracstro 1.1.1 time/Date#::from_julianrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]from_julian().(2_444_351.5)), |
| 490 | Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_clockrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_clock().(14, 36, 51.6) |
| 491 | ); |
| 492 | } |
| 493 | |
| 494 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 495 | fn test_latirust-analyzer cargo pracstro 1.1.1 time/tests/test_lati().() { |
| 496 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 497 | Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degrees().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().25.0).to_latituderust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]to_latitude().().degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]degrees().(), |
| 498 | -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().25.00000000000002 // God I hate floating point |
| 499 | ); |
| 500 | } |
| 501 | |
| 502 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 503 | fn test_turnrust-analyzer cargo pracstro 1.1.1 time/tests/test_turn().() { |
| 504 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_turnsrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_turns().(0.5), Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degrees().(180.0)); |
| 505 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degrees().(180.0), Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_turnsrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_turns().(0.5)); |
| 506 | } |
| 507 | |
| 508 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 509 | fn test_easterrust-analyzer cargo pracstro 1.1.1 time/tests/test_easter().() { |
| 510 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(easterrust-analyzer cargo pracstro 1.1.1 time/easter().(2000), (4, 23)); |
| 511 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(easterrust-analyzer cargo pracstro 1.1.1 time/easter().(2024), (3, 31)); |
| 512 | } |
| 513 | |
| 514 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 515 | fn test_refractrust-analyzer cargo pracstro 1.1.1 time/tests/test_refract().() { |
| 516 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 517 | Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degrees().(25.0).refractdeltarust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]refractdelta().(), |
| 518 | Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degminsecrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degminsec().(0, 2, 9.2) |
| 519 | ); |
| 520 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 521 | Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degrees().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().25.0).refractrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]refract().(), |
| 522 | Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degminsecrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degminsec().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().25, 0, 0.0) |
| 523 | ); |
| 524 | } |
| 525 | } |