year & month replaced by yearMonth object
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user