cleanup report/tracker, ensure end day ends at 23:59:59
Signed-off-by: Nico Schottelius <nico@brief.schottelius.org>
This commit is contained in:
parent
6d827c1dcc
commit
f990b0158d
2 changed files with 20 additions and 13 deletions
|
@ -39,7 +39,21 @@ class Report(object):
|
||||||
|
|
||||||
def __init__(self, project, start_date, end_date):
|
def __init__(self, project, start_date, end_date):
|
||||||
|
|
||||||
# Setup default values
|
self.project = project
|
||||||
|
self.project_dir = ctt.project_dir(self.project)
|
||||||
|
|
||||||
|
self._init_date(start_date, end_date)
|
||||||
|
self._init_report_db()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def commandline(cls, args):
|
||||||
|
report = cls(args.project[0], args.start, args.end)
|
||||||
|
report.report()
|
||||||
|
|
||||||
|
|
||||||
|
def _init_date(self, start_date, end_date):
|
||||||
|
""" Setup date - either default or user given values"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if start_date:
|
if start_date:
|
||||||
self.start_date = datetime.datetime.strptime(start_date[0], ctt.DATEFORMAT)
|
self.start_date = datetime.datetime.strptime(start_date[0], ctt.DATEFORMAT)
|
||||||
|
@ -53,18 +67,11 @@ class Report(object):
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
raise ctt.Error(e)
|
raise ctt.Error(e)
|
||||||
|
|
||||||
self.start_seconds = self.start_date.strftime("%s")
|
self.end_date = self.end_date.replace(hour=23,minute=59,second=59)
|
||||||
self.end_seconds = self.end_date.strftime("%s")
|
|
||||||
|
|
||||||
self.project = project
|
if self.start_date >= self.end_date:
|
||||||
self.project_dir = ctt.project_dir(self.project)
|
raise ctt.Error("End date must be after start date (%s >= %s)" %
|
||||||
|
(self.start_date, self.end_date))
|
||||||
self._init_report_db()
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def commandline(cls, args):
|
|
||||||
report = cls(args.project[0], args.start, args.end)
|
|
||||||
report.report()
|
|
||||||
|
|
||||||
def _init_report_db(self):
|
def _init_report_db(self):
|
||||||
"""Read all contents from db"""
|
"""Read all contents from db"""
|
||||||
|
|
|
@ -109,8 +109,8 @@ class Tracker:
|
||||||
raise ctt.Error("Already tracked time at this beginning for this project")
|
raise ctt.Error("Already tracked time at this beginning for this project")
|
||||||
|
|
||||||
os.makedirs(time_dir, mode=0o700)
|
os.makedirs(time_dir, mode=0o700)
|
||||||
filename = os.path.join(time_dir, ctt.FILE_DELTA)
|
|
||||||
|
|
||||||
|
filename = os.path.join(time_dir, ctt.FILE_DELTA)
|
||||||
with open(filename, "w") as fd:
|
with open(filename, "w") as fd:
|
||||||
fd.write("%s\n" % self.delta())
|
fd.write("%s\n" % self.delta())
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue