Skip to content
This repository was archived by the owner on Jul 29, 2026. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions app/src/plugins/dates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,20 @@
const DAY_MS = 24 * 60 * 60 * 1000;

export function renderDaysAgo(lastUpdated: number) {
const now = new Date().getTime();
const now = new Date();

const diff = now - lastUpdated;
const diff = now.getTime() - lastUpdated;
const daysAgo = Math.floor(diff / DAY_MS);

if (daysAgo <= 0) {
return "today";
} else if (daysAgo === 1) {
return "yesterday";
} else if (daysAgo > 30) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great!

const lastUpdatedDate = new Date(lastUpdated);
let monthsAgo = (now.getFullYear() - lastUpdatedDate.getFullYear()) * 12;
monthsAgo = monthsAgo + now.getMonth() - lastUpdatedDate.getMonth();
return `${monthsAgo} months ago`;
} else {
return `${daysAgo} days ago`;
}
Expand Down