mirror of
https://github.com/Unleash/unleash.git
synced 2024-11-01 19:07:38 +01:00
17 lines
361 B
TypeScript
17 lines
361 B
TypeScript
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;
|
|
}
|