[refactor] pulling getTimestamp off Terminal

This commit is contained in:
Steven Evans
2018-08-01 13:38:54 -04:00
parent 0345daf359
commit 3130b410e2
3 changed files with 15 additions and 9 deletions
+9
View File
@@ -0,0 +1,9 @@
export function getTimestamp() {
const d: Date = new Date();
// A negative slice value takes from the end of the string rather than the beginning.
const stringWidth: number = -2;
const formattedHours: string = `0${d.getHours()}`.slice(stringWidth);
const formattedMinutes: string = `0${d.getMinutes()}`.slice(stringWidth);
return `${d.getMonth() + 1}/${d.getDate()} ${formattedHours}:${formattedMinutes}`;
}