Skip to main content

calendar_core/
auspiciousness.rs

1//! Auspiciousness system for Indonesian calendars
2//!
3//! This module defines the activity types and auspiciousness levels
4//! used across various Indonesian calendar systems.
5
6use alloc::string::String;
7
8/// Activities that can be evaluated for auspiciousness
9///
10/// These represent common activities in Indonesian culture that
11/// may be scheduled based on calendar auspiciousness.
12#[non_exhaustive]
13#[derive(Debug, Clone, PartialEq, Eq, Hash)]
14pub enum Activity {
15    /// Marriage ceremonies
16    Marriage,
17    /// Building construction
18    Building,
19    /// Travel or journeys
20    Travel,
21    /// Business ventures
22    Business,
23    /// Agricultural activities
24    Agriculture,
25    /// Religious ceremonies
26    ReligiousCeremony,
27    /// Naming ceremonies
28    Naming,
29    /// Moving to new house
30    MovingHouse,
31    /// Starting education
32    Education,
33    /// Medical treatments
34    Medical,
35    /// Custom activity with description
36    Custom(String),
37}
38
39impl Activity {
40    /// Get a human-readable description of the activity
41    #[must_use]
42    pub fn description(&self) -> &str {
43        match self {
44            Self::Marriage => "Marriage ceremonies and weddings",
45            Self::Building => "Building construction and foundation laying",
46            Self::Travel => "Travel and journeys",
47            Self::Business => "Business ventures and commerce",
48            Self::Agriculture => "Agricultural activities and planting",
49            Self::ReligiousCeremony => "Religious ceremonies and rituals",
50            Self::Naming => "Naming ceremonies for children",
51            Self::MovingHouse => "Moving to a new house or residence",
52            Self::Education => "Starting education or learning",
53            Self::Medical => "Medical treatments and procedures",
54            Self::Custom(desc) => desc,
55        }
56    }
57}
58
59/// Auspiciousness levels for calendar days
60///
61/// These levels indicate how favorable a day is for various activities
62/// in Indonesian cultural traditions.
63#[non_exhaustive]
64#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
65pub enum AuspiciousnessLevel {
66    /// Extremely auspicious - very favorable
67    VeryAuspicious,
68    /// Auspicious - favorable
69    Auspicious,
70    /// Neutral - neither favorable nor unfavorable
71    Neutral,
72    /// Inauspicious - unfavorable
73    Inauspicious,
74    /// Very inauspicious - very unfavorable
75    VeryInauspicious,
76}
77
78impl AuspiciousnessLevel {
79    /// Get a human-readable description of the level
80    #[must_use]
81    pub const fn description(&self) -> &'static str {
82        match self {
83            Self::VeryAuspicious => "Very auspicious - extremely favorable",
84            Self::Auspicious => "Auspicious - favorable",
85            Self::Neutral => "Neutral - neither favorable nor unfavorable",
86            Self::Inauspicious => "Inauspicious - unfavorable",
87            Self::VeryInauspicious => "Very inauspicious - very unfavorable",
88        }
89    }
90
91    /// Check if the level is auspicious (favorable)
92    #[must_use]
93    pub const fn is_auspicious(self) -> bool {
94        matches!(self, Self::Auspicious | Self::VeryAuspicious)
95    }
96
97    /// Check if the level is very auspicious
98    #[must_use]
99    pub const fn is_very_auspicious(self) -> bool {
100        matches!(self, Self::VeryAuspicious)
101    }
102
103    /// Check if the level is inauspicious (unfavorable)
104    #[must_use]
105    pub const fn is_inauspicious(self) -> bool {
106        matches!(self, Self::Inauspicious | Self::VeryInauspicious)
107    }
108
109    /// Check if the level is very inauspicious
110    #[must_use]
111    pub const fn is_very_inauspicious(self) -> bool {
112        matches!(self, Self::VeryInauspicious)
113    }
114
115    /// Check if the level is neutral
116    #[must_use]
117    pub const fn is_neutral(self) -> bool {
118        matches!(self, Self::Neutral)
119    }
120}
121
122impl core::fmt::Display for Activity {
123    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
124        write!(f, "{}", self.description())
125    }
126}
127
128impl core::fmt::Display for AuspiciousnessLevel {
129    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
130        write!(f, "{}", self.description())
131    }
132}