zugferd_code_lists/zugferd_2_3_2/
date.rs

1#![allow(non_camel_case_types)]
2
3#[cfg_attr(feature = "specta", derive(specta::Type))]
4#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
5#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Hash)]
6pub enum Date {
7    /// CCYYMMDD
8    ///
9    /// Calendar date: C = Century ; Y = Year ; M = Month ; D = Day.
10    Ccyymmdd,
11    /// CCYYMMDDHHMMZHHMM
12    ///
13    /// Calendar date including time and time zone expressed in hours and minutes. ZHHMM = time zone given as offset from Coordinated Universal Time (UTC).
14    Ccyymmddhhmmzhhmm,
15}
16
17impl crate::Code for Date {
18    fn code(self) -> &'static str {
19        match self {
20            Date::Ccyymmdd => "102",
21            Date::Ccyymmddhhmmzhhmm => "205",
22        }
23    }
24}
25
26impl crate::Description for Date {
27    fn description(self) -> &'static str {
28        match self {
29            Date::Ccyymmdd => "CCYYMMDD",
30            Date::Ccyymmddhhmmzhhmm => "CCYYMMDDHHMMZHHMM",
31        }
32    }
33}
34
35impl crate::FromCode for Date {
36    fn from_code(code: &str) -> Option<Self>
37    where
38        Self: Sized,
39    {
40        match code {
41            "102" => Some(Date::Ccyymmdd),
42            "205" => Some(Date::Ccyymmddhhmmzhhmm),
43            _ => None,
44        }
45    }
46}