I am trying to generate some test data through python. (my app is not in python but python seems easy and succinct for data generation). I want to simulate a typical work day of an employee, by generating ‘time slots’ of activities. Below function needs to generate ‘n‘ number of time slot between start and end(with some random gap between to seem natural) with a total(total_hrs).
slots = [] #list of slot == {start:<>, end:<>}
def time_slot(start, end, n, total_hrs):
# generate n non-overlapping time slot between start and end (with some random gap between to seem natural)
print (slots)
Eg:
time_slot( "1/1/2013 9:00", "1/1/2013 17:00", 3, 8)
[ {start: "1/1/2013 9:00", end: "1/1/2013 10:30"}, ...., {start: "1/1/2013 14:00", end: "1/1/2013 16:44"}]
#total time == 8
I can give an outline of what I would do:
nrandom numberss = sum all numberstotal_hrstototal_minchunks = [c/s * total_min for c in numbers]end - startandtotal_hrsdatetime.timedeltaand add the timedelta consecutively to start (already at the beginning you should have convertedstartandendtodatetime.date)