forked from janek/mostr
feat: properly format tracked time
This commit is contained in:
parent
1b361355b0
commit
5723151cfb
|
@ -54,7 +54,7 @@ An active tag or state filter will also create new tasks with those correspondin
|
|||
- `path` - name including parent tasks
|
||||
- `rpath` - name including parent tasks up to active task
|
||||
- `time` - time tracked
|
||||
- `ttime` - time tracked including subtasks
|
||||
- `rtime` - time tracked including subtasks
|
||||
- TBI: `progress` - how many subtasks are complete
|
||||
- TBI: `progressp` - subtask completion in percent
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use std::collections::{BTreeSet, HashSet};
|
||||
use std::fmt;
|
||||
use std::ops::Div;
|
||||
|
||||
use nostr_sdk::{Event, EventBuilder, EventId, Kind, Tag, Timestamp};
|
||||
|
||||
|
@ -124,7 +125,7 @@ impl Task {
|
|||
"parentid" => self.parent_id().map(|i| i.to_string()),
|
||||
"state" => self.state().map(|s| s.to_string()),
|
||||
"name" => Some(self.event.content.clone()),
|
||||
"time" => Some(self.time_tracked().to_string()), // TODO: format properly
|
||||
"time" => Some(format!("{}m", self.time_tracked().div(60))),
|
||||
"tags" => self.tags.as_ref().map(|tags| {
|
||||
tags.iter()
|
||||
.map(|t| format!("{}", t.content().unwrap()))
|
||||
|
|
|
@ -37,7 +37,7 @@ impl Tasks {
|
|||
tasks: Default::default(),
|
||||
properties: vec![
|
||||
"state".into(),
|
||||
"ttime".into(),
|
||||
"rtime".into(),
|
||||
"rpath".into(),
|
||||
"tags".into(),
|
||||
"desc".into(),
|
||||
|
@ -192,7 +192,10 @@ impl Tasks {
|
|||
self.traverse_up_from(Some(task.event.id))
|
||||
.take_while(|t| Some(t.event.id) != self.position)
|
||||
),
|
||||
"ttime" => self.total_time_tracked(&task.event.id).to_string(),
|
||||
"rtime" => {
|
||||
let time = self.total_time_tracked(&task.event.id);
|
||||
format!("{:02}:{:02}", time / 3600, time / 60 % 60)
|
||||
},
|
||||
prop => task.get(prop).unwrap_or(String::new()),
|
||||
})
|
||||
.collect::<Vec<String>>()
|
||||
|
|
Loading…
Reference in New Issue