diff options
author | Alasdair Colley <ac@brede.(none)> | 2011-11-01 18:11:25 +0000 |
---|---|---|
committer | Alasdair Colley <ac@brede.(none)> | 2011-11-01 18:11:25 +0000 |
commit | 1d1307c0e8a83a18b832851dace15ff0af8929c4 (patch) | |
tree | 6f62023a12aa93e8351f49be7cfa6f5fbd7d3557 | |
parent | 319fbf5ecd744d6a1fbe0ce4e219823132f29262 (diff) |
change probability function to generate numbers with a more bell-like probability-density function
-rwxr-xr-x | perc | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -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 |