module analytics.util;

import std.datetime;

SysTime[] generateTimeSeriesTimestamps(Duration intervalSize, int intervalCount) {
    const SysTime now = Clock.currTime(UTC());
    const SysTime endOfToday = SysTime(
        DateTime(now.year, now.month, now.day, 23, 59, 59),
        now.timezone
    );
    SysTime timestamp = endOfToday;
    SysTime[] timestamps = new SysTime[intervalCount + 1];
    timestamps[0] = timestamp;
    for (int i = 0; i < intervalCount; i++) {
        timestamp = timestamp - intervalSize;
        timestamps[i + 1] = timestamp;
    }
    return timestamps;
}