feat: make dates readable to a human being
This commit is contained in:
parent
71a6841d22
commit
4c1e6e861d
5 changed files with 39 additions and 9 deletions
|
|
@ -94,3 +94,6 @@
|
||||||
{"description":"touch filtered: point out tasks matching a non-editing filtered command","entry":"20230831T090935Z","modified":"20230831T090935Z","status":"pending","uuid":"c5835e89-fd7d-45bf-82ed-b38cd0d56b43","tags":["feat"]}
|
{"description":"touch filtered: point out tasks matching a non-editing filtered command","entry":"20230831T090935Z","modified":"20230831T090935Z","status":"pending","uuid":"c5835e89-fd7d-45bf-82ed-b38cd0d56b43","tags":["feat"]}
|
||||||
{"description":"touch filtered: point out tasks matching a non-editing filtered command","entry":"20230831T090935Z","modified":"20230831T090942Z","start":"20230831T090942Z","status":"pending","uuid":"c5835e89-fd7d-45bf-82ed-b38cd0d56b43","tags":["feat"]}
|
{"description":"touch filtered: point out tasks matching a non-editing filtered command","entry":"20230831T090935Z","modified":"20230831T090942Z","start":"20230831T090942Z","status":"pending","uuid":"c5835e89-fd7d-45bf-82ed-b38cd0d56b43","tags":["feat"]}
|
||||||
{"description":"touch filtered: point out tasks matching a non-editing filtered command","end":"20230831T091433Z","entry":"20230831T090935Z","modified":"20230831T091433Z","status":"completed","uuid":"c5835e89-fd7d-45bf-82ed-b38cd0d56b43","tags":["feat"]}
|
{"description":"touch filtered: point out tasks matching a non-editing filtered command","end":"20230831T091433Z","entry":"20230831T090935Z","modified":"20230831T091433Z","status":"completed","uuid":"c5835e89-fd7d-45bf-82ed-b38cd0d56b43","tags":["feat"]}
|
||||||
|
{"description":"humanize dates: make dates readable to a human being","entry":"20230831T092044Z","modified":"20230831T092044Z","status":"pending","uuid":"ea4fd6c8-f7d0-4b85-af26-feeb2b196f29","tags":["feat"]}
|
||||||
|
{"description":"humanize dates: make dates readable to a human being","entry":"20230831T092044Z","modified":"20230831T092056Z","start":"20230831T092056Z","status":"pending","uuid":"ea4fd6c8-f7d0-4b85-af26-feeb2b196f29","tags":["feat"]}
|
||||||
|
{"description":"humanize dates: make dates readable to a human being","end":"20230831T094605Z","entry":"20230831T092044Z","modified":"20230831T094605Z","status":"completed","uuid":"ea4fd6c8-f7d0-4b85-af26-feeb2b196f29","tags":["feat"]}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
[description:"humanize dates: make dates readable to a human being" end:"1693475165" entry:"1693473644" modified:"1693475165" status:"completed" tags:"feat" tags_feat:"x" uuid:"ea4fd6c8-f7d0-4b85-af26-feeb2b196f29"]
|
||||||
[description:"touch filtered: point out tasks matching a non-editing filtered command" end:"1693473273" entry:"1693472975" modified:"1693473273" status:"completed" tags:"feat" tags_feat:"x" uuid:"c5835e89-fd7d-45bf-82ed-b38cd0d56b43"]
|
[description:"touch filtered: point out tasks matching a non-editing filtered command" end:"1693473273" entry:"1693472975" modified:"1693473273" status:"completed" tags:"feat" tags_feat:"x" uuid:"c5835e89-fd7d-45bf-82ed-b38cd0d56b43"]
|
||||||
[description:"theme config: use taskwarrior theme config and extends from there." end:"1693324188" entry:"1692471868" modified:"1693324188" priority:"H" status:"completed" tags:"feat,themes" tags_feat:"x" tags_themes:"x" uuid:"6b248843-1b11-487b-85e8-a96e668f6772"]
|
[description:"theme config: use taskwarrior theme config and extends from there." end:"1693324188" entry:"1692471868" modified:"1693324188" priority:"H" status:"completed" tags:"feat,themes" tags_feat:"x" tags_themes:"x" uuid:"6b248843-1b11-487b-85e8-a96e668f6772"]
|
||||||
[description:"hide grouped fields: when &open;sub&close;grouping, hide the grouped field from the task display" end:"1693323123" entry:"1693322866" modified:"1693323123" priority:"M" status:"completed" tags:"feat" tags_feat:"x" uuid:"ec74a19f-8ab3-4911-b8d8-3b79a593a5d3"]
|
[description:"hide grouped fields: when &open;sub&close;grouping, hide the grouped field from the task display" end:"1693323123" entry:"1693322866" modified:"1693323123" priority:"M" status:"completed" tags:"feat" tags_feat:"x" uuid:"ec74a19f-8ab3-4911-b8d8-3b79a593a5d3"]
|
||||||
|
|
|
||||||
|
|
@ -347,3 +347,14 @@ time 1693473273
|
||||||
old [description:"touch filtered: point out tasks matching a non-editing filtered command" entry:"1693472975" modified:"1693472982" start:"1693472982" status:"pending" tags:"feat" tags_feat:"x" uuid:"c5835e89-fd7d-45bf-82ed-b38cd0d56b43"]
|
old [description:"touch filtered: point out tasks matching a non-editing filtered command" entry:"1693472975" modified:"1693472982" start:"1693472982" status:"pending" tags:"feat" tags_feat:"x" uuid:"c5835e89-fd7d-45bf-82ed-b38cd0d56b43"]
|
||||||
new [description:"touch filtered: point out tasks matching a non-editing filtered command" end:"1693473273" entry:"1693472975" modified:"1693473273" status:"completed" tags:"feat" tags_feat:"x" uuid:"c5835e89-fd7d-45bf-82ed-b38cd0d56b43"]
|
new [description:"touch filtered: point out tasks matching a non-editing filtered command" end:"1693473273" entry:"1693472975" modified:"1693473273" status:"completed" tags:"feat" tags_feat:"x" uuid:"c5835e89-fd7d-45bf-82ed-b38cd0d56b43"]
|
||||||
---
|
---
|
||||||
|
time 1693473644
|
||||||
|
new [description:"humanize dates: make dates readable to a human being" entry:"1693473644" modified:"1693473644" status:"pending" tags:"feat" tags_feat:"x" uuid:"ea4fd6c8-f7d0-4b85-af26-feeb2b196f29"]
|
||||||
|
---
|
||||||
|
time 1693473656
|
||||||
|
old [description:"humanize dates: make dates readable to a human being" entry:"1693473644" modified:"1693473644" status:"pending" tags:"feat" tags_feat:"x" uuid:"ea4fd6c8-f7d0-4b85-af26-feeb2b196f29"]
|
||||||
|
new [description:"humanize dates: make dates readable to a human being" entry:"1693473644" modified:"1693473656" start:"1693473656" status:"pending" tags:"feat" tags_feat:"x" uuid:"ea4fd6c8-f7d0-4b85-af26-feeb2b196f29"]
|
||||||
|
---
|
||||||
|
time 1693475165
|
||||||
|
old [description:"humanize dates: make dates readable to a human being" entry:"1693473644" modified:"1693473656" start:"1693473656" status:"pending" tags:"feat" tags_feat:"x" uuid:"ea4fd6c8-f7d0-4b85-af26-feeb2b196f29"]
|
||||||
|
new [description:"humanize dates: make dates readable to a human being" end:"1693475165" entry:"1693473644" modified:"1693475165" status:"completed" tags:"feat" tags_feat:"x" uuid:"ea4fd6c8-f7d0-4b85-af26-feeb2b196f29"]
|
||||||
|
---
|
||||||
|
|
|
||||||
|
|
@ -29,3 +29,5 @@ color.tags.feat=rgb00aaff
|
||||||
color.tags.bug=rgb00ccff
|
color.tags.bug=rgb00ccff
|
||||||
|
|
||||||
color.project=rgb8877ff
|
color.project=rgb8877ff
|
||||||
|
|
||||||
|
color.due=rgbff8888
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@ import json
|
||||||
import queue
|
import queue
|
||||||
import pathlib
|
import pathlib
|
||||||
import textwrap
|
import textwrap
|
||||||
|
import datetime
|
||||||
|
import humanize
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
import rich
|
import rich
|
||||||
|
|
@ -69,6 +71,11 @@ class Widget:
|
||||||
def rtext(self, val, swatch, prefix = "color.", end="\n"):
|
def rtext(self, val, swatch, prefix = "color.", end="\n"):
|
||||||
return rich.text.Text(val, style=self.swatch_of(swatch, val, prefix), end=end)
|
return rich.text.Text(val, style=self.swatch_of(swatch, val, prefix), end=end)
|
||||||
|
|
||||||
|
def rdate(self, date, swatch, prefix = "color.", end="\n"):
|
||||||
|
dt = datetime.datetime.strptime(date, "%Y%m%dT%H%M%SZ")
|
||||||
|
hd = humanize.naturaltime(datetime.datetime.now() - dt)
|
||||||
|
return self.rtext(hd, swatch, prefix, end)
|
||||||
|
|
||||||
|
|
||||||
class Tasker(Widget):
|
class Tasker(Widget):
|
||||||
def __init__(self, config, show_only, order = None, group = None, touched = []):
|
def __init__(self, config, show_only, order = None, group = None, touched = []):
|
||||||
|
|
@ -157,7 +164,10 @@ class task:
|
||||||
val = task[key]
|
val = task[key]
|
||||||
segment = f"{key}: "
|
segment = f"{key}: "
|
||||||
if type(val) == str:
|
if type(val) == str:
|
||||||
segments.append( self.rtext(segment+val, f"{key}") )
|
if key in [ "due", "end", "entry", "modified", "scheduled", "start", "until", "wait"]:
|
||||||
|
segments.append( self.rtext(segment, key) + self.rdate(val, key) )
|
||||||
|
else:
|
||||||
|
segments.append( self.rtext(segment+val, key) )
|
||||||
elif type(val) == list:
|
elif type(val) == list:
|
||||||
# FIXME Columns does not fit.
|
# FIXME Columns does not fit.
|
||||||
# g = Columns([f"+{t}" for t in val], expand = False)
|
# g = Columns([f"+{t}" for t in val], expand = False)
|
||||||
|
|
@ -165,14 +175,14 @@ class task:
|
||||||
for t in val:
|
for t in val:
|
||||||
lst.append( \
|
lst.append( \
|
||||||
self.rtext(self.tag_icons[0], "tags.ends") + \
|
self.rtext(self.tag_icons[0], "tags.ends") + \
|
||||||
self.rtext(t, f"{key}") + \
|
self.rtext(t, key) + \
|
||||||
self.rtext(self.tag_icons[1], "tags.ends") \
|
self.rtext(self.tag_icons[1], "tags.ends") \
|
||||||
)
|
)
|
||||||
g = rich.console.Group(*lst, fit = True)
|
g = rich.console.Group(*lst, fit = True)
|
||||||
# g = rich.console.Group(*[rich.text.Text(f"{self.tag_icons[0]}{t}{self.tag_icons[1]}", style=f"color.{key}") for t in val], fit = True)
|
# g = rich.console.Group(*[rich.text.Text(f"{self.tag_icons[0]}{t}{self.tag_icons[1]}", style=f"color.{key}") for t in val], fit = True)
|
||||||
segments.append(g)
|
segments.append(g)
|
||||||
else:
|
else:
|
||||||
segments.append(self.rtext(segment+str(val), f"{key}"))
|
segments.append(self.rtext(segment+str(val), key))
|
||||||
|
|
||||||
# FIXME Columns does not fit.
|
# FIXME Columns does not fit.
|
||||||
# cols = Columns(segments)
|
# cols = Columns(segments)
|
||||||
|
|
@ -312,9 +322,12 @@ class stack:
|
||||||
rich.text.Text(":", style="default", end="") + \
|
rich.text.Text(":", style="default", end="") + \
|
||||||
self.rtext(desc, "description.long", end="") )
|
self.rtext(desc, "description.long", end="") )
|
||||||
|
|
||||||
|
elif k in [ "due", "end", "entry", "modified", "scheduled", "start", "until", "wait"]:
|
||||||
|
row.append( self.rdate(val, k) )
|
||||||
|
|
||||||
# Strings, but not description.
|
# Strings, but not description.
|
||||||
else:
|
else:
|
||||||
row.append( self.rtext(val, f"{k}") )
|
row.append( self.rtext(val, k) )
|
||||||
##### List keys. #####
|
##### List keys. #####
|
||||||
elif type(val) == list:
|
elif type(val) == list:
|
||||||
# Tags are a special case.
|
# Tags are a special case.
|
||||||
|
|
@ -324,16 +337,16 @@ class stack:
|
||||||
# FIXME use Columns if/when it does not expand.
|
# FIXME use Columns if/when it does not expand.
|
||||||
tags += \
|
tags += \
|
||||||
self.rtext(self.tag_icons[0], "tags.ends") + \
|
self.rtext(self.tag_icons[0], "tags.ends") + \
|
||||||
self.rtext(t, f"{k}") + \
|
self.rtext(t, k) + \
|
||||||
self.rtext(self.tag_icons[1], "tags.ends") + \
|
self.rtext(self.tag_icons[1], "tags.ends") + \
|
||||||
" "
|
" "
|
||||||
row.append( tags )
|
row.append( tags )
|
||||||
# List, but not tags.
|
# List, but not tags.
|
||||||
else:
|
else:
|
||||||
row.append( self.rtext(" ".join(val), f"{k}") )
|
row.append( self.rtext(" ".join(val), k) )
|
||||||
##### Other type of keys. #####
|
##### Other type of keys. #####
|
||||||
else:
|
else:
|
||||||
row.append( self.rtext(str(val), f"{k}") )
|
row.append( self.rtext(str(val), k) )
|
||||||
else:
|
else:
|
||||||
row.append("")
|
row.append("")
|
||||||
table.add_row(*[t for t in row])
|
table.add_row(*[t for t in row])
|
||||||
|
|
@ -375,7 +388,7 @@ class sections:
|
||||||
if self.grouper.field:
|
if self.grouper.field:
|
||||||
swatch = f"{self.grouper.field}.{key}"
|
swatch = f"{self.grouper.field}.{key}"
|
||||||
else:
|
else:
|
||||||
swatch = f"{key}"
|
swatch = key
|
||||||
val = str(key).upper()
|
val = str(key).upper()
|
||||||
sections.append( rich.panel.Panel(self.stacker(groups[key]), title = self.rtext(val, swatch), title_align = "left", expand = True, border_style = self.swatch_of(swatch, val)))
|
sections.append( rich.panel.Panel(self.stacker(groups[key]), title = self.rtext(val, swatch), title_align = "left", expand = True, border_style = self.swatch_of(swatch, val)))
|
||||||
return rich.console.Group(*sections)
|
return rich.console.Group(*sections)
|
||||||
|
|
@ -396,7 +409,7 @@ class sections:
|
||||||
|
|
||||||
row = []
|
row = []
|
||||||
for k in keys:
|
for k in keys:
|
||||||
row.append( rich.panel.Panel(self.stacker(groups[k]), title = self.rtext(k.upper(), f"{k}"), title_align = "left", expand = True, border_style="color.title"))
|
row.append( rich.panel.Panel(self.stacker(groups[k]), title = self.rtext(k.upper(), k), title_align = "left", expand = True, border_style="color.title"))
|
||||||
|
|
||||||
table.add_row(*row)
|
table.add_row(*row)
|
||||||
return table
|
return table
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue