mirror of
https://github.com/kdheepak/taskwarrior-tui.git
synced 2025-08-24 14:36:42 +02:00
Merge pull request #385 from kdheepak/add-more-date-support
Add more date column support
This commit is contained in:
commit
ab667105ca
2 changed files with 31 additions and 2 deletions
|
@ -1110,7 +1110,7 @@ impl TaskwarriorTui {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i, header) in headers.iter().enumerate() {
|
for (i, header) in headers.iter().enumerate() {
|
||||||
if header == "ID" || header == "Name" {
|
if i == 0 {
|
||||||
// always give ID a couple of extra for indicator
|
// always give ID a couple of extra for indicator
|
||||||
widths[i] += self.config.uda_selection_indicator.as_str().width();
|
widths[i] += self.config.uda_selection_indicator.as_str().width();
|
||||||
// if let TableMode::MultipleSelection = self.task_table_state.mode() {
|
// if let TableMode::MultipleSelection = self.task_table_state.mode() {
|
||||||
|
|
|
@ -8,6 +8,14 @@ use task_hookrs::uda::UDAValue;
|
||||||
use unicode_truncate::UnicodeTruncateStr;
|
use unicode_truncate::UnicodeTruncateStr;
|
||||||
use unicode_width::UnicodeWidthStr;
|
use unicode_width::UnicodeWidthStr;
|
||||||
|
|
||||||
|
pub fn format_date_time(dt: NaiveDateTime) -> String {
|
||||||
|
dt.format("%Y-%m-%d %H:%M:%S").to_string()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn format_date(dt: NaiveDateTime) -> String {
|
||||||
|
dt.format("%Y-%m-%d").to_string()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn vague_format_date_time(from_dt: NaiveDateTime, to_dt: NaiveDateTime) -> String {
|
pub fn vague_format_date_time(from_dt: NaiveDateTime, to_dt: NaiveDateTime) -> String {
|
||||||
let mut seconds = (to_dt - from_dt).num_seconds();
|
let mut seconds = (to_dt - from_dt).num_seconds();
|
||||||
let minus: &str;
|
let minus: &str;
|
||||||
|
@ -216,18 +224,39 @@ impl TaskReportTable {
|
||||||
Some(v) => vague_format_date_time(Local::now().naive_utc(), NaiveDateTime::new(v.date(), v.time())),
|
Some(v) => vague_format_date_time(Local::now().naive_utc(), NaiveDateTime::new(v.date(), v.time())),
|
||||||
None => "".to_string(),
|
None => "".to_string(),
|
||||||
},
|
},
|
||||||
"until" | "until.remaining" => match task.until() {
|
"due" => match task.due() {
|
||||||
|
Some(v) => format_date(NaiveDateTime::new(v.date(), v.time())),
|
||||||
|
None => "".to_string(),
|
||||||
|
},
|
||||||
|
"until.remaining" => match task.until() {
|
||||||
Some(v) => vague_format_date_time(Local::now().naive_utc(), NaiveDateTime::new(v.date(), v.time())),
|
Some(v) => vague_format_date_time(Local::now().naive_utc(), NaiveDateTime::new(v.date(), v.time())),
|
||||||
None => "".to_string(),
|
None => "".to_string(),
|
||||||
},
|
},
|
||||||
|
"until" => match task.until() {
|
||||||
|
Some(v) => format_date(NaiveDateTime::new(v.date(), v.time())),
|
||||||
|
None => "".to_string(),
|
||||||
|
},
|
||||||
"entry.age" => vague_format_date_time(
|
"entry.age" => vague_format_date_time(
|
||||||
NaiveDateTime::new(task.entry().date(), task.entry().time()),
|
NaiveDateTime::new(task.entry().date(), task.entry().time()),
|
||||||
Local::now().naive_utc(),
|
Local::now().naive_utc(),
|
||||||
),
|
),
|
||||||
|
"entry" => format_date(NaiveDateTime::new(task.entry().date(), task.entry().time())),
|
||||||
"start.age" => match task.start() {
|
"start.age" => match task.start() {
|
||||||
Some(v) => vague_format_date_time(NaiveDateTime::new(v.date(), v.time()), Local::now().naive_utc()),
|
Some(v) => vague_format_date_time(NaiveDateTime::new(v.date(), v.time()), Local::now().naive_utc()),
|
||||||
None => "".to_string(),
|
None => "".to_string(),
|
||||||
},
|
},
|
||||||
|
"start" => match task.start() {
|
||||||
|
Some(v) => format_date(NaiveDateTime::new(v.date(), v.time())),
|
||||||
|
None => "".to_string(),
|
||||||
|
},
|
||||||
|
"end.age" => match task.end() {
|
||||||
|
Some(v) => vague_format_date_time(NaiveDateTime::new(v.date(), v.time()), Local::now().naive_utc()),
|
||||||
|
None => "".to_string(),
|
||||||
|
},
|
||||||
|
"end" => match task.end() {
|
||||||
|
Some(v) => format_date(NaiveDateTime::new(v.date(), v.time())),
|
||||||
|
None => "".to_string(),
|
||||||
|
},
|
||||||
"status.short" => task.status().to_string().chars().next().unwrap().to_string(),
|
"status.short" => task.status().to_string().chars().next().unwrap().to_string(),
|
||||||
"status" => task.status().to_string(),
|
"status" => task.status().to_string(),
|
||||||
"priority" => match task.priority() {
|
"priority" => match task.priority() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue