aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2017-01-09 20:22:32 +0100
committerGuido Günther <agx@sigxcpu.org>2017-01-09 20:22:32 +0100
commitec8418734c0f69d922075fbfb22f2814d67351df (patch)
tree6302aeadf5940969fcf0baa60650768db492e204 /examples
parenta930b7ec6463d6ef7ade7ba12026fe8328d3c7dd (diff)
trip-query: assume today when no date is given
Diffstat (limited to 'examples')
-rw-r--r--examples/trip-query.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/examples/trip-query.py b/examples/trip-query.py
index 1c814d5..10c9648 100644
--- a/examples/trip-query.py
+++ b/examples/trip-query.py
@@ -19,6 +19,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+import datetime
import sys
import optparse
@@ -130,7 +131,12 @@ def parse_datetime(when):
if not when:
return None
- date, time = when.split('T')
+ try:
+ date, time = when.split('T')
+ except ValueError:
+ time = when
+ date = str(datetime.date.today())
+
y, m, d = date.split('-')
H, M = time.split(':')
return tuple(map(int, [y, m, d, H, M, '00']))