heatmaps: part 2

This commit is contained in:
nym21
2026-05-29 23:17:39 +02:00
parent 52883bbdba
commit 6938204a24
8 changed files with 233 additions and 113 deletions
+31
View File
@@ -0,0 +1,31 @@
const DAY_MS = 86_400_000;
/**
* @param {Date} date
*/
export function toISODate(date) {
return date.toISOString().slice(0, 10);
}
export function todayISODate() {
return toISODate(new Date());
}
/**
* Inclusive UTC date range.
*
* @param {string} from
* @param {string} to
*/
export function dateRange(from, to) {
const dates = [];
for (
let time = Date.parse(`${from}T00:00:00Z`),
end = Date.parse(`${to}T00:00:00Z`);
time <= end;
time += DAY_MS
) {
dates.push(toISODate(new Date(time)));
}
return dates;
}