summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlasdair Colley <ac@brede.(none)>2011-11-01 18:11:25 +0000
committerAlasdair Colley <ac@brede.(none)>2011-11-01 18:11:25 +0000
commit1d1307c0e8a83a18b832851dace15ff0af8929c4 (patch)
tree6f62023a12aa93e8351f49be7cfa6f5fbd7d3557
parent319fbf5ecd744d6a1fbe0ce4e219823132f29262 (diff)
change probability function to generate numbers with a more bell-like probability-density function
-rwxr-xr-xperc20
1 files changed, 10 insertions, 10 deletions
diff --git a/perc b/perc
index cf8aa3f..8ea71d8 100755
--- a/perc
+++ b/perc
@@ -194,9 +194,16 @@ def getDayOfWeek(day):
def parseTemporalEvent(event, user):
start, finish = None, None
- if event == "LATER":
- start = NOW - timedelta(minutes=random.randint(1, 400))
- finish = NOW + timedelta(minutes=random.randint(1, 400))
+ if event in CONFIG["CUSTOM_EVENTS"]:
+ start = datetime.strptime(CONFIG["CUSTOM_EVENTS"][event]["start"], EVENT_DATETIME_FORMAT)
+ finish = datetime.strptime(CONFIG["CUSTOM_EVENTS"][event]["finish"], EVENT_DATETIME_FORMAT)
+ format = CONFIG["CUSTOM_EVENTS"][event]["format"]
+
+ start_formatted = start.strftime(format).format(name=event)
+ finish_formatted = finish.strftime(format).format(name=event)
+ elif event == "LATER":
+ start = NOW - timedelta(minutes=(random.randint(1, 400) + random.randint(1, 400)) / 2)
+ finish = NOW + timedelta(minutes=(random.randint(1, 400) + random.randint(1, 400)) / 2)
start_formatted = start.strftime("%H:%M")
finish_formatted = finish.strftime("%H:%M")
@@ -260,13 +267,6 @@ def parseTemporalEvent(event, user):
finish_formatted = finish.strftime(user.format)
start_formatted = start.strftime(user.format)
- elif event in CONFIG["CUSTOM_EVENTS"]:
- start = datetime.strptime(CONFIG["CUSTOM_EVENTS"][event]["start"], EVENT_DATETIME_FORMAT)
- finish = datetime.strptime(CONFIG["CUSTOM_EVENTS"][event]["finish"], EVENT_DATETIME_FORMAT)
- format = CONFIG["CUSTOM_EVENTS"][event]["format"]
-
- start_formatted = start.strftime(format).format(name=event)
- finish_formatted = finish.strftime(format).format(name=event)
return start, finish, start_formatted, finish_formatted