mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-12 11:08:34 -05:00
Reworks date parsing, formatting etc for perf
Isolates moment.js
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
'use strict';
|
||||
import { Strings } from '../../system';
|
||||
import { Dates, Strings } from '../../system';
|
||||
import { Uri } from 'vscode';
|
||||
import { GlyphChars } from '../../constants';
|
||||
import { Git } from '../git';
|
||||
@@ -73,6 +73,22 @@ export class GitCommit {
|
||||
return Uri.file(path.resolve(this.repoPath, this.originalFileName || this.fileName));
|
||||
}
|
||||
|
||||
private _dateFormatter?: Dates.IDateFormatter;
|
||||
|
||||
formatDate(format: string) {
|
||||
if (this._dateFormatter === undefined) {
|
||||
this._dateFormatter = Dates.toFormatter(this.date);
|
||||
}
|
||||
return this._dateFormatter.format(format);
|
||||
}
|
||||
|
||||
fromNow() {
|
||||
if (this._dateFormatter === undefined) {
|
||||
this._dateFormatter = Dates.toFormatter(this.date);
|
||||
}
|
||||
return this._dateFormatter.fromNow();
|
||||
}
|
||||
|
||||
getFormattedPath(separator: string = Strings.pad(GlyphChars.Dot, 2, 2)): string {
|
||||
return GitUri.getFormattedPath(this.fileName, separator);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user