summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustavo Noronha Silva <gustavo.noronha@collabora.co.uk>2010-09-06 15:33:27 (GMT)
committerGustavo Noronha Silva <gustavo.noronha@collabora.co.uk>2010-09-07 21:37:21 (GMT)
commit992ecf64a1fc39fcf597c996b89c38ce0b267545 (patch)
tree20ec999375100541dd2bdb4a0b6d6c7296f073b4
parent9e866ba6204f211cc2e63d979331f6195c8fa91a (diff)
downloadgtimelog-992ecf64a1fc39fcf597c996b89c38ce0b267545.tar.gz
gtimelog-992ecf64a1fc39fcf597c996b89c38ce0b267545.tar.xz
Fix mislogging when work goes past the virtual midnight
When we log work that went past virtual midnight, log an entry for the day that ended, an automatic "arrived" message, and a second entry for the day that started, to avoid losing any time.
-rwxr-xr-xsrc/gtimelog/gtimelog.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/gtimelog/gtimelog.py b/src/gtimelog/gtimelog.py
index 25678e6..4d9bbe5 100755
--- a/src/gtimelog/gtimelog.py
+++ b/src/gtimelog/gtimelog.py
@@ -675,6 +675,11 @@ class TimeLog(object):
print >> f, line
f.close()
+ def append_entry(self, entry, now):
+ self.window.items.append((now, entry))
+ line = '%s: %s' % (now.strftime("%Y-%m-%d %H:%M %z"), entry)
+ self.raw_append(line)
+
def append(self, entry, now=None):
"""Append a new entry to the time log."""
if not now:
@@ -682,12 +687,18 @@ class TimeLog(object):
second=0, microsecond=0)
last = self.window.last_time()
if last and different_days(now, last, self.virtual_midnight):
- # next day: reset self.window
+ # We are working past the virtual midnight. We need to
+ # finish the first day, and add an arrival notice at the
+ # beginning of the next day, and also reload the log!
+ midnight = now.replace(hour = self.virtual_midnight.hour,
+ minute = self.virtual_midnight.minute)
+ one_minute_delta = datetime.timedelta(0, 60)
+
+ self.append_entry(entry, midnight - one_minute_delta)
self.reread()
- self.window.items.append((now, entry))
- line = '%s: %s' % (now.strftime("%Y-%m-%d %H:%M %z"), entry)
- self.raw_append(line)
+ self.append_entry('-automatic arrival-', midnight + one_minute_delta)
+ self.append_entry(entry, now)
class TaskList(object):
"""Task list.