Skip to content

Commit

Permalink
Fix plural/singular
Browse files Browse the repository at this point in the history
  • Loading branch information
carlthome committed Sep 16, 2023
1 parent 0783253 commit 9a17432
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,29 @@ function relativeTimePassed(now: number, past: number): string {

const elapsed = now - past;

let value = 0;
let unit = "";
if (elapsed < msMinutes) {
Math.round(elapsed / 1000);
return Math.round(elapsed / 1000) + " seconds ago";
value = Math.round(elapsed / 1000);
unit = "second";
} else if (elapsed < msHours) {
return Math.round(elapsed / msMinutes) + " minutes ago";
value = Math.round(elapsed / msMinutes);
unit = "minute";
} else if (elapsed < msDays) {
return Math.round(elapsed / msHours) + " hours ago";
value = Math.round(elapsed / msHours);
unit = "hour";
} else if (elapsed < msMonths) {
return "Around " + Math.round(elapsed / msDays) + " day(s) ago";
value = Math.round(elapsed / msDays);
unit = "day";
} else if (elapsed < msYears) {
return "Around " + Math.round(elapsed / msMonths) + " month(s) ago";
value = Math.round(elapsed / msMonths);
unit = "month";
} else {
return "Around " + Math.round(elapsed / msYears) + " year(s) ago";
value = Math.round(elapsed / msYears);
unit = "year";
}
const plural = value > 1 ? "s" : "";
return `${value} ${unit}${plural} ago`;
}

const annotationDecoration: vscode.TextEditorDecorationType =
Expand Down

0 comments on commit 9a17432

Please sign in to comment.