Skip to content

Commit

Permalink
fix(Improvement): Precision timestamp display for modified models.
Browse files Browse the repository at this point in the history
  • Loading branch information
imoize committed Aug 30, 2024
1 parent 8834712 commit 2b5fd18
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions package/contents/ui/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,21 @@ function getModels() {
function diffTime(date) {
const now = new Date();
const diffInMs = now - date;
const diffInMinutes = Math.round(diffInMs / (60 * 1000));
const diffInDays = Math.round(diffInMs / (24 * 60 * 60 * 1000));
const diffInSeconds = Math.floor(diffInMs / 1000);
const diffInMinutes = Math.floor(diffInSeconds / 60);
const diffInHours = Math.floor(diffInMinutes / 60);
const diffInDays = Math.floor(diffInHours / 24);

if (diffInDays === 0) {
if (diffInDays > 0) {
return `${diffInDays} Day${diffInDays !== 1 ? 's' : ''} Ago`;
} else if (diffInHours > 0) {
return `${diffInHours} Hour${diffInHours !== 1 ? 's' : ''} Ago`;
} else if (diffInMinutes > 0) {
return `${diffInMinutes} Minute${diffInMinutes !== 1 ? 's' : ''} Ago`;
} else if (diffInSeconds >= 10) {
return `${diffInSeconds} Second${diffInSeconds !== 1 ? 's' : ''} Ago`;
} else {
return `${diffInDays} Day${diffInDays !== 1 ? 's' : ''} Ago`;
return "Just now";
}
}

Expand Down

0 comments on commit 2b5fd18

Please sign in to comment.