chinese_format/gregorian/date/
week_format.rs1use crate::{Chinese, ChineseFormat, Variant};
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
5pub enum WeekFormat {
6 XingQi,
8
9 Zhou,
11
12 LiBai,
14}
15
16impl Default for WeekFormat {
18 fn default() -> Self {
19 Self::XingQi
20 }
21}
22
23impl ChineseFormat for WeekFormat {
25 fn to_chinese(&self, variant: Variant) -> Chinese {
26 match self {
27 Self::XingQi => "星期".to_chinese(variant),
28 Self::Zhou => "周".to_chinese(variant),
29 Self::LiBai => ("礼拜", "禮拜").to_chinese(variant),
30 }
31 }
32}
33
34#[cfg(test)]
35mod tests {
36 use super::*;
37 use pretty_assertions::assert_eq;
38
39 #[test]
40 fn format_xingqi() {
41 assert_eq!(WeekFormat::XingQi.to_chinese(Variant::Simplified), "星期");
42 assert_eq!(WeekFormat::XingQi.to_chinese(Variant::Traditional), "星期");
43 }
44
45 #[test]
46 fn format_zhou() {
47 assert_eq!(WeekFormat::Zhou.to_chinese(Variant::Simplified), "周");
48 assert_eq!(WeekFormat::Zhou.to_chinese(Variant::Traditional), "周");
49 }
50
51 #[test]
52 fn format_libai() {
53 assert_eq!(WeekFormat::LiBai.to_chinese(Variant::Simplified), "礼拜");
54 assert_eq!(WeekFormat::LiBai.to_chinese(Variant::Traditional), "禮拜");
55 }
56
57 #[test]
58 fn default_value() {
59 assert_eq!(
60 WeekFormat::default().to_chinese(Variant::Simplified),
61 "星期"
62 );
63 assert_eq!(
64 WeekFormat::default().to_chinese(Variant::Traditional),
65 "星期"
66 );
67 }
68}