Rewrite to chatty but functional API.
This commit is contained in:
@@ -1,27 +1,20 @@
|
||||
use std::fmt::Display;
|
||||
|
||||
use chrono::{DateTime, Local};
|
||||
use gamenight_api_client_rs::models;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Gamenight {
|
||||
pub id: Uuid,
|
||||
pub name: String,
|
||||
pub start_time: DateTime<Local>
|
||||
pub start_time: DateTime<Local>,
|
||||
pub owner_id: Uuid,
|
||||
}
|
||||
|
||||
impl From<models::Gamenight> for Gamenight {
|
||||
fn from(value: models::Gamenight) -> Self {
|
||||
Self {
|
||||
name: value.name,
|
||||
start_time: DateTime::parse_from_rfc3339(&value.datetime).unwrap().into()
|
||||
}
|
||||
}
|
||||
}
|
||||
impl Display for Gamenight {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
writeln!(f, r#"
|
||||
write!(f, r#"
|
||||
Name: {}
|
||||
When: {}
|
||||
"#, self.name, self.start_time.format("%d-%m-%Y %H:%M"))
|
||||
When: {}"#, self.name, self.start_time.format("%d-%m-%Y %H:%M"))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user