diff options
| author | u <@> | 2026-03-10 10:17:43 +0200 |
|---|---|---|
| committer | u <@> | 2026-03-10 10:17:43 +0200 |
| commit | 3b8d4c4f0d03d7e0951049611384c61d1d498f3a (patch) | |
| tree | f8688c8f756f7b4707db865325191fa7caaa02af /src/solar.rs | |
| parent | 45329d748b964748ba4f09b70500d81137aad487 (diff) | |
a
Diffstat (limited to 'src/solar.rs')
| -rw-r--r-- | src/solar.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/solar.rs b/src/solar.rs index af52afc..06cffb3 100644 --- a/src/solar.rs +++ b/src/solar.rs @@ -5,8 +5,7 @@ // based on https://prospertimes.neocities.org/solarterms.js use lazy_static::lazy_static; -use num::{cast, traits::AsPrimitive}; -use std::num::Wrapping as W; +use num::cast; use std::{ f64::consts::PI, mem::MaybeUninit, @@ -75,6 +74,7 @@ pub const TERMS: [Term; 24] = terms![ {"冬至", 270, 12, 19, 23}, ]; +// julian d8 fn compute_JD(mut y: f64, mut m: f64, d: f64) -> f64 { if m <= 2. { y -= 1.; @@ -107,6 +107,7 @@ fn compute_ang(jd: f64) -> f64 { Lapp } +#[inline(always)] fn bisect<T>( lo: &mut f64, hi: &mut f64, @@ -221,6 +222,9 @@ fn stday(i: usize, y: usize) -> f64 { lazy_static! { static ref GANZHIS: Vec<String> = { + const gan: [char; 10] = ['甲', '乙', '丙', '丁', '戊', '己', '庚', '辛', '壬', '癸']; + const zhi: [char; 12] = [ '子', '丑', '寅', '卯', '辰', '巳', '午', '未', '申', '酉', + '戌', '亥', ]; let mut tmp: Vec<String> = vec![]; tmp.reserve(60); (0..60).for_each(|i| { @@ -233,18 +237,14 @@ lazy_static! { tmp }; } -const gan: [char; 10] = - ['甲', '乙', '丙', '丁', '戊', '己', '庚', '辛', '壬', '癸']; -const zhi: [char; 12] = [ - '子', '丑', '寅', '卯', '辰', '巳', '午', '未', '申', '酉', '戌', '亥', -]; + pub fn ganzhi(i: usize) -> &'static str { &GANZHIS[i] } #[inline(always)] fn int(x: f64) -> usize { - x as usize + x as usize // x.as_int_unchecked() // wont work on wasm } lazy_static! { |
