Commit e294c590 authored by Jacek Sowiński's avatar Jacek Sowiński

Implement relative dates in list-format

parent 3a8e8efa
...@@ -31,6 +31,7 @@ setup( ...@@ -31,6 +31,7 @@ setup(
url = "https://github.com/bram85/topydo", url = "https://github.com/bram85/topydo",
install_requires = [ install_requires = [
'six >= 1.9.0', 'six >= 1.9.0',
'arrow',
], ],
extras_require = { extras_require = {
':sys_platform=="win32"': ['colorama>=0.2.5'], ':sys_platform=="win32"': ['colorama>=0.2.5'],
......
...@@ -16,9 +16,16 @@ ...@@ -16,9 +16,16 @@
""" Ulities for formatting output with "list_format" option.""" """ Ulities for formatting output with "list_format" option."""
import arrow
def filler(p_str, p_len): def filler(p_str, p_len):
""" """
Returns p_str preceded by additional spaces if p_str is shorter than p_len. Returns p_str preceded by additional spaces if p_str is shorter than p_len.
""" """
to_fill = p_len - len(p_str) to_fill = p_len - len(p_str)
return to_fill*' ' + p_str return to_fill*' ' + p_str
def humanize_date(p_datetime):
now = arrow.now()
date = now.replace(day=p_datetime.day, month=p_datetime.month, year=p_datetime.year)
return date.humanize()
...@@ -22,7 +22,7 @@ from six import u ...@@ -22,7 +22,7 @@ from six import u
from topydo.lib.Colors import NEUTRAL_COLOR, Colors from topydo.lib.Colors import NEUTRAL_COLOR, Colors
from topydo.lib.Config import config from topydo.lib.Config import config
from topydo.lib.ListFormat import filler from topydo.lib.ListFormat import filler, humanize_date
class PrettyPrinterFilter(object): class PrettyPrinterFilter(object):
...@@ -140,13 +140,13 @@ class PrettyPrinterFormatFilter(PrettyPrinterFilter): ...@@ -140,13 +140,13 @@ class PrettyPrinterFormatFilter(PrettyPrinterFilter):
'c': lambda t: t.creation_date().isoformat() if t.creation_date() else '', 'c': lambda t: t.creation_date().isoformat() if t.creation_date() else '',
# relative creation date # relative creation date
'C': lambda t: '#', # TODO: humanized creation date 'C': lambda t: humanize_date(t.creation_date()) if t.creation_date() else '',
# absolute due date # absolute due date
'd': lambda t: t.due_date().isoformat() if t.due_date() else '', 'd': lambda t: t.due_date().isoformat() if t.due_date() else '',
# relative due date # relative due date
'D': lambda t: '#', # TODO: humanized due date 'D': lambda t: humanize_date(t.due_date()) if t.due_date() else '',
# todo ID # todo ID
'i': lambda t: str(self.todolist.number(t)), 'i': lambda t: str(self.todolist.number(t)),
...@@ -168,7 +168,7 @@ class PrettyPrinterFormatFilter(PrettyPrinterFilter): ...@@ -168,7 +168,7 @@ class PrettyPrinterFormatFilter(PrettyPrinterFilter):
't': lambda t: t.start_date().isoformat() if t.start_date() else '', 't': lambda t: t.start_date().isoformat() if t.start_date() else '',
# relative start date # relative start date
'T': lambda t: '#', # TODO: humanized start date 'T': lambda t: humanize_date(t.start_date()) if t.start_date() else '',
# literal % # literal %
'%': lambda _: '%', '%': lambda _: '%',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment