Frontend security / security (push) Successful in 9s
Frontend verify / verify (push) Failing after 37m50s
Frontend security / security (pull_request) Successful in 9s
Frontend verify / verify (pull_request) Failing after 42m10s
Conventional commits / commits (pull_request) Successful in 29s
Enable every plugin recommended preset and replace Biome with ESLint formatting. Preserve API contracts and JSX whitespace; verify source, tests, builds and tooling.
27 lines
701 B
TypeScript
27 lines
701 B
TypeScript
import { z } from "zod";
|
|
|
|
import { bankMonth } from "./form-validation";
|
|
|
|
const calendarDate = z.iso.date();
|
|
const ISO_DATE_LENGTH = 10;
|
|
function bankPeriod(parameters: URLSearchParams) {
|
|
const month = bankMonth(parameters.get("month"));
|
|
const monthEnd = new Date(`${month}-01T00:00:00Z`);
|
|
monthEnd.setUTCMonth(monthEnd.getUTCMonth() + 1, 0);
|
|
const from = parameters.get("from");
|
|
const to = parameters.get("to");
|
|
return from
|
|
&& to
|
|
&& calendarDate.safeParse(from).success
|
|
&& calendarDate.safeParse(to).success
|
|
&& from >= "0001-01-01"
|
|
&& from <= to
|
|
? { from, to }
|
|
: {
|
|
from: `${month}-01`,
|
|
to: monthEnd.toISOString().slice(0, ISO_DATE_LENGTH),
|
|
};
|
|
}
|
|
|
|
export { bankPeriod };
|