pub(crate) mod bazi;
pub(crate) mod calendar;
pub(crate) mod jie_table;
pub(crate) mod lunar_table;
pub(crate) mod ziwei;
pub(crate) const STEMS: [&str; 10] = [
"jia", "yi", "bing", "ding", "wu", "ji", "geng", "xin", "ren", "gui",
];
pub(crate) const BRANCHES: [&str; 12] = [
"zi", "chou", "yin", "mao", "chen", "si", "wu", "wei", "shen", "you", "xu", "hai",
];
pub(crate) const ANIMALS: [&str; 12] = [
"rat", "ox", "tiger", "rabbit", "dragon", "snake", "horse", "goat", "monkey", "rooster", "dog",
"pig",
];
pub(crate) const ELEMENTS: [&str; 5] = ["wood", "fire", "earth", "metal", "water"];
const BRANCH_ELEMENTS: [usize; 12] = [4, 2, 0, 0, 2, 1, 1, 2, 3, 3, 2, 4];
pub(crate) fn stem_element(stem: usize) -> usize {
stem / 2
}
pub(crate) fn branch_element(branch: usize) -> usize {
BRANCH_ELEMENTS[branch]
}
pub(crate) fn polarity(index: usize) -> &'static str {
if index % 2 == 0 {
"yang"
} else {
"yin"
}
}
pub(crate) fn cycle_index(stem: usize, branch: usize) -> usize {
(6 * stem as i64 - 5 * branch as i64).rem_euclid(60) as usize
}
pub(crate) fn year_cycle_index(year: i32) -> usize {
(i64::from(year) - 4).rem_euclid(60) as usize
}