~ruther/simple-clock

ref: 9a82d5eec0c6de36140bb72311230a4a12d7a9ae simple-clock/source/src/display_view/date_display_view.rs -rw-r--r-- 853 bytes
9a82d5ee — František Boháček chore(src): move source to source/ folder 1 year, 8 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use crate::clock_display::DisplayPart;

use super::DisplayView;

pub struct DateDisplayView;

impl DateDisplayView {
    pub fn new() -> Self {
        Self
    }
}

impl Default for DateDisplayView {
    fn default() -> Self {
        Self::new()
    }
}

impl DisplayView for DateDisplayView {
    fn update_display(
        &mut self,
        state: &crate::clock_state::ClockState,
        display: &mut crate::clock_display::ClockDisplay,
    ) -> Result<(), super::DisplayViewError> {
        let calendar = state.calendar();

        display.show_ordinal(DisplayPart::SideDisplay1, calendar.day() as u32, true)?;
        display.show_ordinal(DisplayPart::SideDisplay2, calendar.month() as u32, true)?;
        display.show_number(DisplayPart::MainDisplay, calendar.year() as u32, false)?;
        display.set_colon(false);
        Ok(())
    }
}
Do not follow this link