#![cfg(feature = "lunisolar")]
pub const PHASE_GLYPH: [char; 8] = ['N', ')', ')', 'O', 'F', 'O', '(', '('];
const MOON_ART: [[&str; 7]; 8] = [
[
" . . . . .",
" . . . . . . .",
" . . . . . . . .",
" . . . . . . . .",
" . . . . . . . .",
" . . . . . . .",
" . . . . .",
],
[
" . . . . @",
" . . . . . @ @",
" . . . . . . @ @",
" . . . . . . @ @",
" . . . . . . @ @",
" . . . . . @ @",
" . . . . @",
],
[
" . . @ @ @",
" . . . @ @ @ @",
" . . . . @ @ @ @",
" . . . . @ @ @ @",
" . . . . @ @ @ @",
" . . . @ @ @ @",
" . . @ @ @",
],
[
" . @ @ @ @",
" . . @ @ @ @ @",
" . . @ @ @ @ @ @",
" . . @ @ @ @ @ @",
" . . @ @ @ @ @ @",
" . . @ @ @ @ @",
" . @ @ @ @",
],
[
" @ @ @ @ @",
" @ @ @ @ @ @ @",
" @ @ @ @ @ @ @ @",
" @ @ @ @ @ @ @ @",
" @ @ @ @ @ @ @ @",
" @ @ @ @ @ @ @",
" @ @ @ @ @",
],
[
" @ @ @ @ .",
" @ @ @ @ @ . .",
" @ @ @ @ @ @ . .",
" @ @ @ @ @ @ . .",
" @ @ @ @ @ @ . .",
" @ @ @ @ @ . .",
" @ @ @ @ .",
],
[
" @ @ . . .",
" @ @ @ @ . . .",
" @ @ @ @ . . . .",
" @ @ @ @ . . . .",
" @ @ @ @ . . . .",
" @ @ @ @ . . .",
" @ @ . . .",
],
[
" @ . . . .",
" @ @ . . . . .",
" @ @ . . . . . .",
" @ @ . . . . . .",
" @ @ . . . . . .",
" @ @ . . . . .",
" @ . . . .",
],
];
#[must_use]
pub fn moon_art(phase_index: u8) -> &'static [&'static str; 7] {
&MOON_ART[(phase_index as usize) % 8]
}
use crate::cal::{season_for, Hemisphere, SeasonMarker};
fn season_title(solar_longitude_deg: f64, hemisphere: Hemisphere) -> &'static str {
match season_for(solar_longitude_deg, hemisphere) {
"spring" => "Spring",
"summer" => "Summer",
"autumn" => "Autumn",
_ => "Winter",
}
}
#[must_use]
pub fn season_strip(year: i16, markers: &[SeasonMarker], hemisphere: Hemisphere) -> String {
use std::fmt::Write as _;
let hemi = match hemisphere {
Hemisphere::North => "N. hemisphere",
Hemisphere::South => "S. hemisphere",
};
let mut out = format!("{year} {hemi}\n");
for m in markers {
let date = m.instant_utc.split('T').next().unwrap_or(&m.instant_utc);
let season = season_title(m.solar_longitude_deg, hemisphere);
let _ = writeln!(
out,
" {season:<7} opens {date} ({} {:.0}deg)",
m.term_name, m.solar_longitude_deg
);
}
out
}