13 lines
360 B
TypeScript
13 lines
360 B
TypeScript
import { YearMonth } from "./db-types";
|
|
|
|
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);
|
|
}
|