diff --git a/src/lib/render-date.ts b/src/lib/render-date.ts index 7156cc4..3a8c887 100644 --- a/src/lib/render-date.ts +++ b/src/lib/render-date.ts @@ -7,7 +7,11 @@ const dateFormatter = new Intl.DateTimeFormat(locale, { }); export function renderDateToHtml(date: Date) { - return ``; + let html = ''; + html += ``; + return html; } if (import.meta.vitest) { @@ -24,20 +28,28 @@ interface YearMonth { month: number; } -function convertYearMonthToDate({ year, month }: YearMonth) { - return new Date(Date.UTC(year, month - 1)); -} - const yearMonthFormatter = new Intl.DateTimeFormat(locale, { year: 'numeric', month: 'long', }); +export function renderYearMonthRangeToHtml(startYearMonth: YearMonth, endYearMonth?: YearMonth) { + const startHtml = renderYearMonthToHtml(startYearMonth); + const parts = [startHtml, '—']; + if (endYearMonth) { + const endHtml = renderYearMonthToHtml(endYearMonth); + parts.push(endHtml); + } + return parts.join(' '); +} + function renderYearMonthToHtml(yearMonth: YearMonth) { const date = convertYearMonthToDate(yearMonth); - return ``; + let html = ''; + html += ``; + return html; } if (import.meta.vitest) { @@ -49,10 +61,6 @@ if (import.meta.vitest) { }); } -export function renderYearMonthRangeToHtml(startYearMonth: YearMonth, endYearMonth?: YearMonth) { - const parts = [renderYearMonthToHtml(startYearMonth), '—']; - if (endYearMonth) { - parts.push(renderYearMonthToHtml(endYearMonth)); - } - return parts.join(' '); +function convertYearMonthToDate({ year, month }: YearMonth) { + return new Date(Date.UTC(year, month - 1)); }