procedural programming – Build a list from events

SeedRandom[1];
dates = Sort[RandomSample[With[{first = Now}, 
     DateRange[first, DatePlus[first, Quantity[1000, "Minutes"]], "Minutes"]], 20] ];

events = RandomChoice[{3, 1} -> {"in", "out"}, 20];

names = RandomWord["Noun", 20];

data = Transpose[{names, events, dates}];

Grid @ data

enter image description here

Prepend dates with an initial date and use Differencesto get durations.

time0 = Now - Quantity[10, "Minutes"];
durations = Differences[Prepend[time0]@data[[All, 3]]];

Replace "in" with with 1 and "out" with -1 in the second column of data and use Accumulate to get numberofpeople:

numberofpeople = Accumulate[data[[All, 2]] /. {"in" -> 1, "out" -> -1}];

Add the new columns to data:

newdata = Join[data, List /@ numberofpeople, List /@ durations, 2];

Grid @ newdata

enter image description here