diff --git a/docs/src/tasks.md b/docs/src/tasks.md index b3285af88..ba303fb66 100644 --- a/docs/src/tasks.md +++ b/docs/src/tasks.md @@ -40,6 +40,7 @@ The following keys, and key formats, are defined: * `end` - if present, the time at which this task was completed or deleted (note that this key may not agree with `status`: it may be present for a pending task, or absent for a deleted or completed task) * `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 af94f72ba..4b7ed565f 100644 --- a/taskchampion/src/replica.rs +++ b/taskchampion/src/replica.rs @@ -108,6 +108,7 @@ impl Replica { let mut task = Task::new(uuid, taskmap).into_mut(self); task.set_description(description)?; task.set_status(status)?; + task.set_entry(Utc::now())?; Ok(task.into_immut()) } @@ -228,7 +229,9 @@ mod tests { .. } = op { - if property == "modified" || property == "end" { + // rewrite automatically-created dates to "just-now" for ease + // of testing + if property == "modified" || property == "end" || property == "entry" { if value.is_some() { value = Some("just-now".into()); } @@ -277,6 +280,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 e151f88d5..4b20cf60d 100644 --- a/taskchampion/src/task/task.rs +++ b/taskchampion/src/task/task.rs @@ -58,6 +58,7 @@ enum Prop { Status, Wait, End, + Entry, } #[allow(clippy::ptr_arg)] @@ -292,6 +293,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) }