med-log
Version:
Logging package intended for gxp/samd regulated environments hosted in the cloud
25 lines (24 loc) • 808 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Prepends a 0 to n if n is less than 10, and returns that as a string.
*/
function prependZero(n, u) {
return n.toString().padStart(u || 2, "0");
}
exports.prependZero = prependZero;
function formatDate(date) {
var formatted = date.getFullYear().toString()
+ "_" + prependZero(date.getMonth() + 1)
+ "_" + prependZero(date.getDate());
return formatted;
}
exports.formatDate = formatDate;
function formatTime(date) {
var formatted = prependZero(date.getHours())
+ ":" + prependZero(date.getMinutes())
+ ":" + prependZero(date.getSeconds())
+ "m" + prependZero(date.getMilliseconds(), 4);
return formatted;
}
exports.formatTime = formatTime;