1
use crate::model::component::time_zone::TimeZoneComponentBuilder;
2
use crate::model::component::{
3
    add_comment, add_date_time_start, add_recurrence_date, add_recurrence_rule,
4
    impl_other_component_properties, CalendarComponent,
5
};
6
use crate::model::impl_component_access;
7
use crate::model::property::{
8
    AddComponentProperty, ComponentProperty, IanaComponentPropertyBuilder,
9
    TimeZoneNamePropertyBuilder, TimeZoneOffset, TimeZoneOffsetFromPropertyBuilder,
10
    TimeZoneOffsetToPropertyBuilder, XComponentPropertyBuilder,
11
};
12

            
13
#[derive(Debug, PartialEq)]
14
pub struct DaylightComponent {
15
    pub(crate) properties: Vec<ComponentProperty>,
16
}
17

            
18
impl_component_access!(DaylightComponent);
19

            
20
impl DaylightComponent {
21
38
    pub(crate) fn new() -> Self {
22
38
        DaylightComponent {
23
38
            properties: Vec::new(),
24
38
        }
25
38
    }
26
}
27

            
28
impl Default for DaylightComponent {
29
    fn default() -> Self {
30
        Self::new()
31
    }
32
}
33

            
34
pub struct DaylightComponentBuilder {
35
    owner: TimeZoneComponentBuilder,
36
    inner: DaylightComponent,
37
}
38

            
39
impl DaylightComponentBuilder {
40
12
    pub(crate) fn new(owner: TimeZoneComponentBuilder) -> Self {
41
12
        DaylightComponentBuilder {
42
12
            owner,
43
12
            inner: DaylightComponent {
44
12
                properties: Vec::new(),
45
12
            },
46
12
        }
47
12
    }
48

            
49
    add_date_time_start!();
50

            
51
12
    pub fn add_time_zone_offset_to(
52
12
        self,
53
12
        offset: TimeZoneOffset,
54
12
    ) -> TimeZoneOffsetToPropertyBuilder<Self> {
55
12
        TimeZoneOffsetToPropertyBuilder::new(self, offset)
56
12
    }
57

            
58
12
    pub fn add_time_zone_offset_from(
59
12
        self,
60
12
        offset: TimeZoneOffset,
61
12
    ) -> TimeZoneOffsetFromPropertyBuilder<Self> {
62
12
        TimeZoneOffsetFromPropertyBuilder::new(self, offset)
63
12
    }
64

            
65
    add_recurrence_rule!();
66

            
67
    add_comment!();
68

            
69
    add_recurrence_date!();
70

            
71
12
    pub fn add_time_zone_name(self, value: &str) -> TimeZoneNamePropertyBuilder<Self> {
72
12
        TimeZoneNamePropertyBuilder::new(self, value.to_string())
73
12
    }
74

            
75
    impl_other_component_properties!(
76
        XComponentPropertyBuilder,
77
        IanaComponentPropertyBuilder,
78
        DaylightComponentBuilder
79
    );
80

            
81
12
    pub(crate) fn build(mut self) -> TimeZoneComponentBuilder {
82
12
        self.owner
83
12
            .inner
84
12
            .components
85
12
            .push(CalendarComponent::Daylight(self.inner));
86
12
        self.owner
87
12
    }
88
}
89

            
90
impl AddComponentProperty for DaylightComponentBuilder {
91
108
    fn add_property(&mut self, property: ComponentProperty) {
92
108
        self.inner.properties.push(property);
93
108
    }
94
}