From 3b8d4c4f0d03d7e0951049611384c61d1d498f3a Mon Sep 17 00:00:00 2001 From: u <@> Date: Tue, 10 Mar 2026 10:17:43 +0200 Subject: a --- src/solar.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/solar.rs') 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( lo: &mut f64, hi: &mut f64, @@ -221,6 +222,9 @@ fn stday(i: usize, y: usize) -> f64 { lazy_static! { static ref GANZHIS: Vec = { + const gan: [char; 10] = ['甲', '乙', '丙', '丁', '戊', '己', '庚', '辛', '壬', '癸']; + const zhi: [char; 12] = [ '子', '丑', '寅', '卯', '辰', '巳', '午', '未', '申', '酉', + '戌', '亥', ]; let mut tmp: Vec = 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! { -- cgit v1.2.3