From 319fbf5ecd744d6a1fbe0ce4e219823132f29262 Mon Sep 17 00:00:00 2001 From: Alasdair Colley Date: Tue, 1 Nov 2011 18:02:18 +0000 Subject: add event LATER --- perc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/perc b/perc index 1bdce80..cf8aa3f 100755 --- a/perc +++ b/perc @@ -40,6 +40,7 @@ import copy import decimal import json import optparse +import random import re import string import sys @@ -76,7 +77,7 @@ WEEK_LENGTH = 7 WEEKEND = [ SATURDAY, SUNDAY ] WORK_WEEK = [ MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY ] -IMPORTANT_TEMPORAL_EVENTS = ["tomorrow", "friday", "new year", "newyear", "christmas", "xmas", "weekend", "midday", "noon", "lunch", "easter", "halloween"] +IMPORTANT_TEMPORAL_EVENTS = ["LATER", "tomorrow", "friday", "new year", "newyear", "christmas", "xmas", "weekend", "midday", "noon", "lunch", "easter", "halloween"] OUTPUT_TYPES = ["perc", "bar", "ram", "pint"] @@ -193,7 +194,13 @@ def getDayOfWeek(day): def parseTemporalEvent(event, user): start, finish = None, None - if event == "tomorrow": + if event == "LATER": + start = NOW - timedelta(minutes=random.randint(1, 400)) + finish = NOW + timedelta(minutes=random.randint(1, 400)) + + start_formatted = start.strftime("%H:%M") + finish_formatted = finish.strftime("%H:%M") + elif event == "tomorrow": start = NOW.replace(hour=0, minute=0, second=0, microsecond=0) finish = NOW.replace(day=NOW.day + 1, hour=0, minute=0, second=0, microsecond=0) -- cgit v1.2.3