Skip to content

Commit

Permalink
fix: date diff label full date with 3 month ago
Browse files Browse the repository at this point in the history
  • Loading branch information
tosaken1116 committed Apr 9, 2024
1 parent 618441f commit 34dafb2
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 7 deletions.
5 changes: 0 additions & 5 deletions src/components/ui/DateDiffLabel/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ describe('test ui/DateDiffLabel', () => {
expect(screen.getByText(//)).toBeInTheDocument();
});

it('should display date in MM/DD format for dates within the same year', () => {
render(<DateDiffLabel date={new Date(2023, 2, 10)} now={now} />);
expect(screen.getByText('3/10')).toBeInTheDocument();
});

it('should display date in YYYY/MM/DD format for dates in a different year', () => {
render(<DateDiffLabel date={new Date(2022, 11, 25)} now={now} />);
expect(screen.getByText('2022/12/25')).toBeInTheDocument();
Expand Down
2 changes: 0 additions & 2 deletions src/components/ui/DateDiffLabel/logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ export const DateToDiffLabel = (date: Date, now: Date): string => {
return `${Math.floor(diffInSeconds / WEEK)}${DATE_DIFF_LABEL['week']}`;
if (diffInSeconds <= MONTH * 3)
return `${Math.floor(diffInSeconds / MONTH)}${DATE_DIFF_LABEL['month']}`;
if (date.getFullYear() === now.getFullYear())
return `${date.getMonth() + 1}/${date.getDate()}`;

return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`;
};

0 comments on commit 34dafb2

Please sign in to comment.