Add discretizeTimeSeries() and the corresponding test