1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-11-01 19:07:38 +01:00
unleash.unleash/src/lib/util/time-utils.ts

17 lines
361 B
TypeScript
Raw Normal View History

import { startOfHour, subHours } from 'date-fns';
export interface HourBucket {
timestamp: Date;
}
export function generateHourBuckets(hours: number): HourBucket[] {
const start = startOfHour(new Date());
const result = [];
for (let i = 0; i < hours; i++) {
result.push({ timestamp: subHours(start, i) });
}
return result;
}