35 lines
744 B
Rust
35 lines
744 B
Rust
use chrono::{DateTime, Utc, Duration};
|
|
use serde::Serialize;
|
|
|
|
#[derive(Debug, Clone, PartialEq, Serialize)]
|
|
pub struct Entry {
|
|
pub id: u64,
|
|
pub note: Option<String>,
|
|
pub start: DateTime<Utc>,
|
|
pub end: Option<DateTime<Utc>>,
|
|
pub sheet: String,
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub struct Meta {
|
|
pub id: u64,
|
|
pub key: String,
|
|
pub value: String,
|
|
}
|
|
|
|
impl Entry {
|
|
#[cfg(test)]
|
|
pub fn new_sample(id: u64, start: DateTime<Utc>, end: Option<DateTime<Utc>>) -> Entry {
|
|
Entry {
|
|
id,
|
|
note: Some(format!("entry {}", id)),
|
|
start, end,
|
|
sheet: "default".into(),
|
|
}
|
|
}
|
|
|
|
pub fn timespan(&self) -> Option<Duration> {
|
|
self.end.map(|e| e - self.start)
|
|
}
|
|
}
|