use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize, Deserialize)]
pub enum DurationUnit {
Centuries,
Days,
Decades,
Hours,
Microseconds,
Millenia,
Milliseconds,
Minutes,
Months,
Nanoseconds,
Seconds,
Weeks,
WorkWeeks,
Years,
}
impl std::convert::From<&DurationUnit> for String {
fn from(duration_unit: &DurationUnit) -> Self {
match duration_unit {
DurationUnit::Centuries => Self::from("centuries"),
DurationUnit::Days => Self::from("days"),
DurationUnit::Decades => Self::from("decades"),
DurationUnit::Hours => Self::from("hours"),
DurationUnit::Microseconds => Self::from("microseconds"),
DurationUnit::Millenia => Self::from("millenia"),
DurationUnit::Milliseconds => Self::from("milliseconds"),
DurationUnit::Minutes => Self::from("minutes"),
DurationUnit::Months => Self::from("months"),
DurationUnit::Nanoseconds => Self::from("nanoseconds"),
DurationUnit::Seconds => Self::from("seconds"),
DurationUnit::Weeks => Self::from("weeks"),
DurationUnit::WorkWeeks => Self::from("work weeks"),
DurationUnit::Years => Self::from("years"),
} } }
impl std::default::Default for DurationUnit {
fn default() -> Self {
Self::Seconds
} }
impl std::fmt::Display for DurationUnit {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{}", String::from(self))
} }