Update date time format to include minutes and seconds
Signed-off-by: Sanjula Ganepola <sanjulagane@gmail.com>
This commit is contained in:
@@ -20,11 +20,21 @@ export namespace DateUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get time duration in seconds.
|
||||
* Get time duration in minutes and seconds.
|
||||
*
|
||||
* Examples: 31s or 2m 52s
|
||||
*/
|
||||
export function getTimeDuration(startValue: string, endValue: string) {
|
||||
const start = new Date(startValue).getTime();
|
||||
const end = new Date(endValue).getTime();
|
||||
return ((end - start) / 1000).toFixed(0).toString();
|
||||
|
||||
const totalSeconds = Math.floor((end - start) / 1000);
|
||||
if (totalSeconds < 60) {
|
||||
return `${totalSeconds}s`;
|
||||
}
|
||||
|
||||
const minutes = Math.floor(totalSeconds / 60);
|
||||
const seconds = totalSeconds % 60;
|
||||
return `${minutes}m ${seconds}s`;
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ export default class HistoryTreeItem extends TreeItem implements GithubLocalActi
|
||||
|
||||
let totalDuration: string | undefined;
|
||||
if (history.date) {
|
||||
totalDuration = `${DateUtils.getTimeDuration(history.date.start, history.date.end)}s`;
|
||||
totalDuration = DateUtils.getTimeDuration(history.date.start, history.date.end);
|
||||
}
|
||||
|
||||
this.description = totalDuration;
|
||||
|
||||
Reference in New Issue
Block a user