Skip to content

Commit

Permalink
added support for previous year as well
Browse files Browse the repository at this point in the history
  • Loading branch information
nimit9 committed Mar 24, 2024
1 parent 3fc35d2 commit d12b5cb
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/app/history/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ const formatWatchHistoryDate = (date: Date) => {
} else if (diffInDays < 2) {
return 'Yesterday';
}
const currentYear = now.getFullYear();

const historyYear = date.getFullYear();

if (currentYear - historyYear > 0) {
return date.toLocaleDateString('en-US', {
month: 'short',
day: 'numeric',
year: 'numeric',
});
}
return date.toLocaleDateString('en-US', { month: 'short', day: 'numeric' });
};

Expand Down

0 comments on commit d12b5cb

Please sign in to comment.