function [BlockStartTimes, BlockEndTimes] = CreateTimeBlocks(StartTimes, EndTimes, TimeInterval)
% [BlockStartTimes, BlockEndTimes] = CreateTimeBlocks(StartTimes, EndTimes, TimeInterval)
% Given continous StartTimes series, EndTimes series, and expected
% time interval, create blank time blocks
% Note the 3 inputs and 2 outputs in datetime format

BlockStartTimes = [];
BlockEndTimes = [];
for i = 1:length(StartTimes)
    temp_start = StartTimes(i);
    temp_end = temp_start + TimeInterval;
    while temp_end <= EndTimes(i)
       BlockStartTimes = [BlockStartTimes;temp_start]; 
       BlockEndTimes = [BlockEndTimes;temp_end];
       temp_start = temp_end + duration(0,0,50);% 50s, make sure no overlapping between endtime of previous timeblock and starttime of the next block
       temp_end = temp_start + TimeInterval;
    end
end
display('%--- function CreateTimeBlocks() complete ----%');
end