From 376d2d6079a1a4e2fc446faa69c7635d7904b80f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 31 Oct 2012 22:19:33 +0100 Subject: [PATCH] sort entries on report Signed-off-by: Nico Schottelius --- lib/ctt/report.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/ctt/report.py b/lib/ctt/report.py index c999c77..01675ad 100755 --- a/lib/ctt/report.py +++ b/lib/ctt/report.py @@ -52,7 +52,7 @@ class Report(object): def _init_date(self, start_date, end_date): - """ Setup date - either default or user given values""" + """Setup date - either default or user given values""" try: if start_date: @@ -127,9 +127,14 @@ class Report(object): def list_entries(self): """Return total time tracked""" - for time, entry in self._report_db.items(): + sorted_times = sorted(self._report_db.keys()) + #for time, entry in self._report_db.items(): + + for time in sorted_times: + entry = self._report_db[time] + start_datetime = datetime.datetime.strptime(time, ctt.DATETIMEFORMAT) - delta = datetime.timedelta(seconds=float(entry['delta'])) + delta = datetime.timedelta(seconds=int(float(entry['delta']))) end_datetime = start_datetime + delta # Strip off microsecends - this is really too much @@ -142,9 +147,9 @@ class Report(object): comment = False if comment: - print("%s - %s: %s" % (start_datetime, end_datetime, comment)) + print("%s (%s): %s" % (start_datetime, delta, comment)) else: - print("%s - %s" % (start_datetime, end_datetime)) + print("%s (%s)" % (start_datetime, delta)) @staticmethod