year & month replaced by yearMonth object

This commit is contained in:
2024-01-09 16:20:49 +01:00
parent 46b65711a8
commit d627ad757d
12 changed files with 82 additions and 64 deletions

View File

@@ -1,4 +1,12 @@
import { YearMonth } from "./db-types";
export const formatYearMonth = (year: number, month:number): string => {
export const formatYearMonth = ({ year, month }: YearMonth): string => {
return `${year}-${month<10?"0":""}${month}`;
}
export const parseYearMonth = (yearMonthString: string): YearMonth => {
const [year, month] = yearMonthString.split("-").map((s) => parseInt(s, 10));
return({ year, month } as YearMonth);
}