Files
sendou.ink/e2e/helpers/availability.ts
Kalle 9b82d577e2
Some checks failed
E2E Tests / e2e (push) Has been cancelled
Tests and checks on push / run-checks-and-tests (push) Has been cancelled
Updates translation progress / update-translation-progress-issue (push) Has been cancelled
Availability tool (#3375)
2026-08-30 17:35:14 +03:00

23 lines
709 B
TypeScript

import * as R from "remeda";
import * as Availability from "~/features/availability/core/Availability";
import { MACHINE_TIMEZONE } from "./playwright";
const DAY_SECONDS = 24 * 60 * 60;
/** The week `date` (default: now) falls in, as the test machine's timezone sees it. */
export function weekRange(date = new Date()) {
return Availability.weekRange(date, MACHINE_TIMEZONE);
}
/** The seven `YYYY-MM-DD` dates of the week `date` (default: now) falls in. */
export function weekDates(date = new Date()) {
const { startsAt } = weekRange(date);
return R.range(0, 7).map((dayIndex) =>
Availability.dateInTimezone(
startsAt + dayIndex * DAY_SECONDS + DAY_SECONDS / 2,
MACHINE_TIMEZONE,
),
);
}