You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
533 B
25 lines
533 B
|
2 years ago
|
"use strict";
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Adds zero to strings shorter than two characters.
|
||
|
|
*
|
||
|
|
* @param {number} number
|
||
|
|
* @returns {string}
|
||
|
|
*/
|
||
|
|
function pad(number) {
|
||
|
|
return number < 10 ? `0${number}` : number.toString();
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Returns a timestamp in the format of `hours:minutes:seconds`
|
||
|
|
*/
|
||
|
|
|
||
|
|
|
||
|
|
function getTimeStamp() {
|
||
|
|
const date = new Date();
|
||
|
|
const hours = pad(date.getHours());
|
||
|
|
const minutes = pad(date.getMinutes());
|
||
|
|
const seconds = pad(date.getSeconds());
|
||
|
|
return `${hours}:${minutes}:${seconds}`;
|
||
|
|
}
|
||
|
|
|
||
|
|
module.exports = getTimeStamp;
|