sort entries on report

Signed-off-by: Nico Schottelius <nico@brief.schottelius.org>
This commit is contained in:
Nico Schottelius 2012-10-31 22:19:33 +01:00
parent a791bae133
commit 376d2d6079

View file

@ -52,7 +52,7 @@ class Report(object):
def _init_date(self, start_date, end_date): 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: try:
if start_date: if start_date:
@ -127,9 +127,14 @@ class Report(object):
def list_entries(self): def list_entries(self):
"""Return total time tracked""" """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) 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 end_datetime = start_datetime + delta
# Strip off microsecends - this is really too much # Strip off microsecends - this is really too much
@ -142,9 +147,9 @@ class Report(object):
comment = False comment = False
if comment: if comment:
print("%s - %s: %s" % (start_datetime, end_datetime, comment)) print("%s (%s): %s" % (start_datetime, delta, comment))
else: else:
print("%s - %s" % (start_datetime, end_datetime)) print("%s (%s)" % (start_datetime, delta))
@staticmethod @staticmethod