[hamster-applet] support negative minutes in time entry
- From: Toms Baugis <tbaugis src gnome org>
- To: svn-commits-list gnome org
- Subject: [hamster-applet] support negative minutes in time entry
- Date: Sat, 6 Jun 2009 16:30:14 -0400 (EDT)
commit e42fdc13edd81d0c606c2783bab3479eb6afcb2a
Author: Toms Bauģis <toms baugis gmail com>
Date: Sat Jun 6 19:23:32 2009 +0100
support negative minutes in time entry
---
hamster/stuff.py | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/hamster/stuff.py b/hamster/stuff.py
index 99bcce9..c20b29c 100644
--- a/hamster/stuff.py
+++ b/hamster/stuff.py
@@ -213,11 +213,17 @@ def parse_activity_input(text):
potential_time = text.split(" ")[0]
potential_end_time = None
- if potential_time.find("-") > -1:
- potential_time, potential_end_time = potential_time.split("-", 2)
- res.end_time = figure_time(potential_end_time)
-
- res.start_time = figure_time(potential_time)
+ if len(potential_time) > 1 and potential_time.startswith("-"):
+ #if starts with minus, treat as minus delta minutes
+ res.start_time = dt.datetime.now() + dt.timedelta(minutes =
+ int(potential_time))
+
+ else:
+ if potential_time.find("-") > 0:
+ potential_time, potential_end_time = potential_time.split("-", 2)
+ res.end_time = figure_time(potential_end_time)
+
+ res.start_time = figure_time(potential_time)
#remove parts that worked
if potential_end_time and not res.end_time:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]