diff options
Diffstat (limited to 'src/html_calendar.rs')
-rw-r--r-- | src/html_calendar.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/html_calendar.rs b/src/html_calendar.rs index b16b987..2902caa 100644 --- a/src/html_calendar.rs +++ b/src/html_calendar.rs @@ -1,4 +1,7 @@ +use std::io::prelude::*; +use std::fs::File; use std::collections::HashMap; +use std::path::Path; use chrono::{NaiveTime, Duration, Local}; use crate::task::*; @@ -7,7 +10,14 @@ pub enum CalendarPrivacy { Private, } -pub fn tasks_to_html(tasks: &Vec<Task>, privacy: CalendarPrivacy) -> String { +pub fn tasks_to_html_file(tasks: &Vec<Task>, privacy: CalendarPrivacy, file_name: &str) { + let html = tasks_to_html(tasks, privacy); + // https://riptutorial.com/rust/example/4276/write-in-a-file + let mut file = File::create(Path::new(file_name)).unwrap(); + writeln!(&mut file, "{}", html).unwrap(); +} + +fn tasks_to_html(tasks: &Vec<Task>, privacy: CalendarPrivacy) -> String { let public_tags = HashMap::from([ ("busy", "I will be genuinely busy, e.g., a meeting with others."), ("rough", "The nature of the event (e.g., a hike) makes it difficult to preduct the exact start/end times."), |