vscode-todo-plus
Version:
Manage todo lists with ease. Powerful, easy to use and customizable.
68 lines (50 loc) • 1.45 kB
text/typescript
/* IMPORT */
import * as memoize from 'memoize-decorator';
import Config from '../config';
import Time from './time';
/* STATISTICS TOKENS */
class StatisticsTokens {
static supported = ['comments', 'projects', 'tags', 'pending', 'done', 'cancelled', 'finished', 'all', 'percentage', 'est', 'lasted', 'wasted', 'elapsed'];
comments = 0;
projects = 0;
tags = 0;
pending = 0;
done = 0;
cancelled = 0;
estSeconds = 0;
lastedSeconds = 0;
wastedSeconds = 0;
get finished () {
return this.done + this.cancelled;
}
get all () {
return this.pending + this.finished;
}
get percentage () {
return this.all ? Math.round ( this.finished / this.all * 100 ) : 100;
}
get est () {
return this.formatTime ( this.estSeconds, 'timekeeping.estimate.format' );
}
get lasted () {
return this.formatTime ( this.lastedSeconds, 'timekeeping.elapsed.format' );
}
get wasted () {
return this.formatTime ( this.wastedSeconds, 'timekeeping.elapsed.format' );
}
get elapsed () {
return this.formatTime ( this.lastedSeconds + this.wastedSeconds, 'timekeeping.elapsed.format' );
}
private formatTime ( seconds: number, format: string ) : string {
return seconds ? Time.diff ( Date.now () + seconds * 1000, undefined, Config.getKey ( format ) ) : '';
}
}
/* EXPORT */
export default StatisticsTokens;