punch_clock/
event.rs

1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3
4/// Represents a (possibly ongoing) period of time tracking, with its associated metadata.
5#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
6pub struct Event {
7    /// The start of a time-tracking period.
8    pub start: DateTime<Utc>,
9    /// The end of a time-tracking period.
10    pub stop: Option<DateTime<Utc>>,
11}
12
13impl Event {
14    /// Create a new event starting at the given time.
15    pub fn new(start: DateTime<Utc>) -> Self {
16        Event { start, stop: None }
17    }
18}