Mercurial > getan
changeset 17:2712fc2b8276
human_seconds: Use timespec instead of seconds and document it.
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Tue, 18 Aug 2009 15:45:12 +0200 |
parents | 22aa74768d97 |
children | 4242b263fad4 |
files | getan |
diffstat | 1 files changed, 7 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/getan Tue Aug 18 14:49:40 2009 +0200 +++ b/getan Tue Aug 18 15:45:12 2009 +0200 @@ -142,9 +142,10 @@ 'h' : 60*60, 'd': 24*60*60} -def human_seconds(seconds): +def human_seconds(timespec): + """Translate human input to seconds, default factor is minutes""" total = 0 - for v in seconds.split(':'): + for v in timespec.split(':'): factor = FACTORS.get(v[-1]) if factor: v = v[:-1] else: factor = 60 @@ -548,9 +549,9 @@ if key: parts = SPACE.split(key, 1) if len(parts) > 1: - key, seconds = parts[0], parts[1] + key, timespec = parts[0], parts[1] try: - seconds = human_seconds(seconds) + seconds = human_seconds(timespec) if seconds > 0: seconds = timedelta(seconds=seconds) self.substractTime(key, seconds) @@ -574,11 +575,11 @@ if key: parts = SPACE.split(key, 2) if len(parts) > 1: - key, seconds = parts[0], parts[1] + key, timespec = parts[0], parts[1] if len(parts) > 2: desc = parts[2] else: desc = None try: - seconds = human_seconds(seconds) + seconds = human_seconds(timespec) if seconds > 0: seconds = timedelta(seconds=seconds) self.addTime(key, seconds, desc)