use derive_more::Display;
use crate::macros::impl_traits;
#[repr(u8)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "bincode", derive(bincode::Encode, bincode::Decode))]
#[derive(Copy,Clone,Debug,Default,PartialEq,PartialOrd,Eq,Ord,Hash)]
#[derive(Display)]
pub enum DaysInYear {
#[default]
ThreeSixFive,
ThreeSixSix,
}
impl_traits!{ DaysInYear => u16 |
u8,u16,u32,u64,u128,usize |
i8,i16,i32,i64,i128,isize
}
impl DaysInYear {
#[inline]
pub const fn inner(self) -> u16 {
match self {
Self::ThreeSixFive => 365,
Self::ThreeSixSix => 366,
}
}
#[inline]
pub const fn is_365(self) -> bool {
match self {
Self::ThreeSixFive => true,
Self::ThreeSixSix => false,
}
}
#[inline]
pub const fn is_366(self) -> bool {
match self {
Self::ThreeSixFive => false,
Self::ThreeSixSix => true,
}
}
#[inline]
pub const fn as_str(self) -> &'static str {
match self {
Self::ThreeSixFive => "ThreeSixFive",
Self::ThreeSixSix => "ThreeSixSix",
}
}
#[inline]
pub const fn as_str_num(self) -> &'static str {
match self {
Self::ThreeSixFive => "365",
Self::ThreeSixSix => "366",
}
}
#[inline]
pub const fn as_str_lower(self) -> &'static str {
match self {
Self::ThreeSixFive => "threesixfive",
Self::ThreeSixSix => "threesixsix",
}
}
#[inline]
pub const fn as_str_upper(self) -> &'static str {
match self {
Self::ThreeSixFive => "THREESIXFIVE",
Self::ThreeSixSix => "THREESIXSIX",
}
}
}