Skip to content

Commit 2c90237

Browse files
committed
1 parent f9fad16 commit 2c90237

File tree

1 file changed

+2
-35
lines changed

1 file changed

+2
-35
lines changed

src/vs/workbench/contrib/extensions/browser/extensionsActions.ts

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -65,40 +65,7 @@ import { IPaneCompositePartService } from 'vs/workbench/services/panecomposite/b
6565
import { ViewContainerLocation } from 'vs/workbench/common/views';
6666
import { flatten } from 'vs/base/common/arrays';
6767
import { isBoolean } from 'vs/base/common/types';
68-
69-
function getRelativeDateLabel(date: Date): string {
70-
const delta = new Date().getTime() - date.getTime();
71-
72-
const year = 365 * 24 * 60 * 60 * 1000;
73-
if (delta > year) {
74-
const noOfYears = Math.floor(delta / year);
75-
return noOfYears > 1 ? localize('noOfYearsAgo', "{0} years ago", noOfYears) : localize('one year ago', "1 year ago");
76-
}
77-
78-
const month = 30 * 24 * 60 * 60 * 1000;
79-
if (delta > month) {
80-
const noOfMonths = Math.floor(delta / month);
81-
return noOfMonths > 1 ? localize('noOfMonthsAgo', "{0} months ago", noOfMonths) : localize('one month ago', "1 month ago");
82-
}
83-
84-
const day = 24 * 60 * 60 * 1000;
85-
if (delta > day) {
86-
const noOfDays = Math.floor(delta / day);
87-
return noOfDays > 1 ? localize('noOfDaysAgo', "{0} days ago", noOfDays) : localize('one day ago', "1 day ago");
88-
}
89-
90-
const hour = 60 * 60 * 1000;
91-
if (delta > hour) {
92-
const noOfHours = Math.floor(delta / day);
93-
return noOfHours > 1 ? localize('noOfHoursAgo', "{0} hours ago", noOfHours) : localize('one hour ago', "1 hour ago");
94-
}
95-
96-
if (delta > 0) {
97-
return localize('just now', "Just now");
98-
}
99-
100-
return '';
101-
}
68+
import { fromNow } from 'vs/base/common/date';
10269

10370
export class PromptExtensionInstallFailureAction extends Action {
10471

@@ -1175,7 +1142,7 @@ export class InstallAnotherVersionAction extends ExtensionAction {
11751142
return {
11761143
id: v.version,
11771144
label: v.version,
1178-
description: `${getRelativeDateLabel(new Date(Date.parse(v.date)))}${v.isPreReleaseVersion ? ` (${localize('pre-release', "pre-release")})` : ''}${v.version === this.extension!.version ? ` (${localize('current', "current")})` : ''}`,
1145+
description: `${fromNow(new Date(Date.parse(v.date)), true)}${v.isPreReleaseVersion ? ` (${localize('pre-release', "pre-release")})` : ''}${v.version === this.extension!.version ? ` (${localize('current', "current")})` : ''}`,
11791146
latest: i === 0,
11801147
ariaLabel: `${v.isPreReleaseVersion ? 'Pre-Release version' : 'Release version'} ${v.version}`,
11811148
isPreReleaseVersion: v.isPreReleaseVersion

0 commit comments

Comments
 (0)