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(
url = "https://github.com/bram85/topydo",
install_requires = [
'six >= 1.9.0',
'arrow',
],
extras_require = {
':sys_platform=="win32"': ['colorama>=0.2.5'],
......
......@@ -16,9 +16,16 @@
""" Ulities for formatting output with "list_format" option."""
import arrow
def filler(p_str, p_len):
"""
Returns p_str preceded by additional spaces if p_str is shorter than p_len.
"""
to_fill = p_len - len(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
from topydo.lib.Colors import NEUTRAL_COLOR, Colors
from topydo.lib.Config import config
from topydo.lib.ListFormat import filler
from topydo.lib.ListFormat import filler, humanize_date
class PrettyPrinterFilter(object):
......@@ -140,13 +140,13 @@ class PrettyPrinterFormatFilter(PrettyPrinterFilter):
'c': lambda t: t.creation_date().isoformat() if t.creation_date() else '',
# 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
'd': lambda t: t.due_date().isoformat() if t.due_date() else '',
# 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
'i': lambda t: str(self.todolist.number(t)),
......@@ -168,7 +168,7 @@ class PrettyPrinterFormatFilter(PrettyPrinterFilter):
't': lambda t: t.start_date().isoformat() if t.start_date() else '',
# relative start date
'T': lambda t: '#', # TODO: humanized start date
'T': lambda t: humanize_date(t.start_date()) if t.start_date() else '',
# literal %
'%': 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