diff --git a/docs/src/tasks.md b/docs/src/tasks.md index eb6756e22..c2a1258ba 100644 --- a/docs/src/tasks.md +++ b/docs/src/tasks.md @@ -33,6 +33,7 @@ The following keys, and key formats, are defined: * `start` - the most recent time at which this task was started (a task with no `start` key is not active) * `tag_` - indicates this task has tag `` (value is an empty string) * `wait` - indicates the time before which this task should be hidden, as it is not actionable +* `entry` - the time at which the task was created * `annotation_` - value is an annotation created at the given time The following are not yet implemented: diff --git a/taskchampion/src/replica.rs b/taskchampion/src/replica.rs index 17b058184..e7862dab5 100644 --- a/taskchampion/src/replica.rs +++ b/taskchampion/src/replica.rs @@ -108,6 +108,7 @@ impl Replica { let mut task = self.create_task(uuid)?.into_mut(self); task.set_description(description)?; task.set_status(status)?; + task.set_entry(Utc::now())?; trace!("task {} created", uuid); Ok(task.into_immut()) } @@ -238,7 +239,7 @@ mod tests { .. } = op { - if property == "modified" { + if property == "modified" || property == "entry" { if value.is_some() { value = Some("just-now".into()); } @@ -287,6 +288,13 @@ mod tests { value: Some("pending".into()), timestamp: now, }, + ReplicaOp::Update { + uuid: t.get_uuid(), + property: "entry".into(), + old_value: None, + value: Some("just-now".into()), + timestamp: now, + }, ReplicaOp::Update { uuid: t.get_uuid(), property: "modified".into(), diff --git a/taskchampion/src/task/task.rs b/taskchampion/src/task/task.rs index 9771bc3d0..452c85e82 100644 --- a/taskchampion/src/task/task.rs +++ b/taskchampion/src/task/task.rs @@ -57,6 +57,7 @@ enum Prop { Start, Status, Wait, + Entry, } #[allow(clippy::ptr_arg)] @@ -284,6 +285,10 @@ impl<'r> TaskMut<'r> { self.set_string(Prop::Description.as_ref(), Some(description)) } + pub(crate) fn set_entry(&mut self, entry: DateTime) -> anyhow::Result<()> { + self.set_timestamp(Prop::Entry.as_ref(), Some(entry)) + } + pub fn set_wait(&mut self, wait: Option>) -> anyhow::Result<()> { self.set_timestamp(Prop::Wait.as_ref(), wait) }