aboutsummaryrefslogtreecommitdiff
path: root/src/model
diff options
context:
space:
mode:
authorJoris2022-01-09 14:37:35 +0100
committerJoris2022-01-09 14:37:35 +0100
commitd0a9063631e71928484a698f6c585ebb3915e8a2 (patch)
tree9a5fc430684aea73877711dd3392b1845d4b9904 /src/model
parent5166efe517291f5c9fc6326f30651ef799d6db65 (diff)
Allow to update events
Diffstat (limited to 'src/model')
-rw-r--r--src/model/event.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/model/event.rs b/src/model/event.rs
index 27587bc..7ab0244 100644
--- a/src/model/event.rs
+++ b/src/model/event.rs
@@ -13,6 +13,16 @@ pub struct Event {
pub name: String,
}
+pub fn init(date: NaiveDate) -> Event {
+ Event {
+ id: Uuid::new_v4(),
+ date,
+ start: None,
+ end: None,
+ name: "".to_string(),
+ }
+}
+
impl Event {
pub fn pprint(&self) -> String {
let start = self.start.map(pprint_time).unwrap_or_default();
@@ -29,7 +39,7 @@ impl Event {
}
}
-fn pprint_time(t: NaiveTime) -> String {
+pub fn pprint_time(t: NaiveTime) -> String {
if t.minute() == 0 {
format!("{}h", t.hour())
} else {