From c9ee9d9a27d825f2848115d65bffb4d723762bbb Mon Sep 17 00:00:00 2001 From: bel Date: Mon, 10 Nov 2025 23:48:48 -0700 Subject: [PATCH] like this --- pttodoest/src/main.rs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/pttodoest/src/main.rs b/pttodoest/src/main.rs index d9f1138..c51042a 100755 --- a/pttodoest/src/main.rs +++ b/pttodoest/src/main.rs @@ -158,12 +158,28 @@ impl File { } #[derive(Debug, Clone, Serialize, Deserialize)] -struct Delta(json_patch::Patch); +struct Delta{ + ts: u64, + patch: json_patch::Patch, +} #[derive(Debug, Clone, Serialize, Deserialize)] -struct TaskAt { +struct TaskTs { task: Task, - at: usize, + ts: u64, +} + +impl Delta { + fn new(patch: json_patch::Patch, ts: u64) -> TaskTs { + Delta{ + patch: patch, + ts: ts, + } + } + + fn now(patch: json_patch::Patch) -> Delta { + Self::new(patch, std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_secs().try_into().unwrap()) + } } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]