use core::fmt;
use crate::angles::Longitude;
use crate::ayanamsa::Ayanamsa;
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum ZodiacMode {
Tropical,
Sidereal {
ayanamsa: Ayanamsa,
},
}
impl fmt::Display for ZodiacMode {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Tropical => f.write_str("Tropical"),
Self::Sidereal { ayanamsa } => write!(f, "Sidereal ({ayanamsa})"),
}
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum SiderealStarPlace {
#[default]
Mean,
Apparent,
}
impl fmt::Display for SiderealStarPlace {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(match self {
Self::Mean => "mean",
Self::Apparent => "apparent",
})
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
#[non_exhaustive]
pub enum ZodiacSign {
Aries,
Taurus,
Gemini,
Cancer,
Leo,
Virgo,
Libra,
Scorpio,
Sagittarius,
Capricorn,
Aquarius,
Pisces,
}
impl ZodiacSign {
pub fn from_longitude(longitude: Longitude) -> Self {
match (longitude.degrees() / 30.0).floor() as usize % 12 {
0 => Self::Aries,
1 => Self::Taurus,
2 => Self::Gemini,
3 => Self::Cancer,
4 => Self::Leo,
5 => Self::Virgo,
6 => Self::Libra,
7 => Self::Scorpio,
8 => Self::Sagittarius,
9 => Self::Capricorn,
10 => Self::Aquarius,
_ => Self::Pisces,
}
}
pub const fn name(self) -> &'static str {
match self {
Self::Aries => "Aries",
Self::Taurus => "Taurus",
Self::Gemini => "Gemini",
Self::Cancer => "Cancer",
Self::Leo => "Leo",
Self::Virgo => "Virgo",
Self::Libra => "Libra",
Self::Scorpio => "Scorpio",
Self::Sagittarius => "Sagittarius",
Self::Capricorn => "Capricorn",
Self::Aquarius => "Aquarius",
Self::Pisces => "Pisces",
}
}
}
impl fmt::Display for ZodiacSign {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.name())
}
}