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
//! Export `Org` struct to various formats.

pub mod html;
pub mod org;

pub use html::{DefaultHtmlHandler, HtmlHandler};
pub use org::{DefaultOrgHandler, OrgHandler};

use std::io::{Error, Write};

use crate::elements::Datetime;

pub(crate) fn write_datetime<W: Write>(
    mut w: W,
    start: &str,
    datetime: &Datetime,
    end: &str,
) -> Result<(), Error> {
    write!(w, "{}", start)?;
    write!(
        w,
        "{}-{:02}-{:02} {}",
        datetime.year, datetime.month, datetime.day, datetime.dayname
    )?;
    if let (Some(hour), Some(minute)) = (datetime.hour, datetime.minute) {
        write!(w, " {:02}:{:02}", hour, minute)?;
    }
    write!(w, "{}", end)
}