#![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]
}
const SEASON_TILE: [[&str; 6]; 4] = [
[
" * . *",
" . \\|/ .",
" *---- o ----*",
" . /|\\ .",
" * ' *",
" blossom",
],
[
" \\ | / ___",
" -- O -- /___\\",
" / | \\ |",
" ~~~~~~~~~~~~|~~~",
" |",
" beach",
],
[
" , & ,",
" & , & ,",
" , & , &",
" & , &",
" ~~~~~~~~~~~",
" leaves",
],
[
" _===_",
" (.o.o.)",
" ( >^< )",
" (( : : ))",
" * * * * *",
" snowman",
],
];
#[must_use]
pub fn season_tile(season_index: u8) -> &'static [&'static str; 6] {
&SEASON_TILE[(season_index as usize) % 4]
}
#[must_use]
pub fn season_tile_for(season: &str) -> &'static [&'static str; 6] {
let idx = match season {
"spring" => 0,
"summer" => 1,
"autumn" => 2,
_ => 3, };
season_tile(idx)
}
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
}