Skip to content

Commit

Permalink
Lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jackyef committed Nov 21, 2024
1 parent 4882bbe commit f3ac040
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
13 changes: 10 additions & 3 deletions src/components/HistoryCalendar/AsideHeading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,17 @@ export const AsideHeading = ({
onPrevClick,
}: Props) => {
const from =
event.from === TIMELINE_START ? '2013' : formatMonth(event.from, true, 'en-US', 'short');
const to = event.to === TODAY ? 'Present' : formatMonth(event.to, true, 'en-US', 'short');
event.from === TIMELINE_START
? '2013'
: formatMonth(event.from, true, 'en-US', 'short');
const to =
event.to === TODAY
? 'Present'
: formatMonth(event.to, true, 'en-US', 'short');

const headingText = `${from === to ? from : `${from}${to}`} (${getTimeDifference(event.from, event.to)})`;
const headingText = `${
from === to ? from : `${from}${to}`
} (${getTimeDifference(event.from, event.to)})`;

return (
<h2
Expand Down
10 changes: 7 additions & 3 deletions src/lib/datetime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ export const formatDate = (

const monthFormatter: Map<string, Intl.DateTimeFormat> = new Map();

const getMonthFormatter = (languageKey: string, withYear: boolean, monthFormat: Intl.DateTimeFormatOptions['month']) => {
const getMonthFormatter = (
languageKey: string,
withYear: boolean,
monthFormat: Intl.DateTimeFormatOptions['month'],
) => {
const cacheKey = `${languageKey}${withYear}${monthFormat}`;
if (monthFormatter.get(cacheKey)) return monthFormatter.get(cacheKey);

Expand Down Expand Up @@ -73,8 +77,8 @@ export const getTimeDifference = (a: Date, b: Date) => {
}

const years = Math.floor(monthDiff / 12);
const months = monthDiff % 12 + 1;
const months = (monthDiff % 12) + 1;

if (months === 12) {
return `${years + 1}y`;
}
Expand Down

0 comments on commit f3ac040

Please sign in to comment.