summaryrefslogtreecommitdiff
path: root/src/timestamp.rs
blob: 86dfa2ab5cb71040aa4d9cb352e544dc55b868f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

use std::ops::{Add, Sub};

#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub struct Timestamp(pub i64);

impl Add<i64> for Timestamp {
    type Output = Self;
    fn add(self, other: i64) -> Self {
        Self(self.0 + other)
    }
}

impl Sub<i64> for Timestamp {
    type Output = Self;
    fn sub(self, other: i64) -> Self {
        Self(self.0 - other)
    }
}

impl Sub<Self> for Timestamp {
    type Output = i64;
    fn sub(self, other: Self) -> i64 {
        self.0 - other.0
    }
}