# HG changeset patch # User Thomas Arendsen Hein # Date 1250603112 -7200 # Node ID 2712fc2b827617a927d7f5271aa8618ee90be846 # Parent 22aa74768d9705d39d4c600ab30386c44d72288a human_seconds: Use timespec instead of seconds and document it. diff -r 22aa74768d97 -r 2712fc2b8276 getan --- 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)