const fs = require("fs") const path = require("path") var metricsPathFile = metricsPathFile module.exports.getDate = function (formated) { var date = new Date() // [Date Format] - Format de la date var gmonth = date.getMonth() + 1 var gday = date.getDate() var gHour = date.getHours() var gMinute = date.getMinutes() var gSecondes = date.getSeconds() if(date.getMonth() + 1 < 10) { gmonth = "0" + (date.getMonth() + 1) } if(date.getDate() + 1 <= 10) { gday = "0" + date.getDate() } if(date.getHours() + 1 <= 10) { gHour = "0" + date.getHours() } if(date.getMinutes() + 1 <= 10) { gMinute = "0" + date.getMinutes() } if(date.getSeconds() + 1 <= 10) { gSecondes = "0" + date.getSeconds() } if(!formated) { return gday + "/" + gmonth + " - " + gHour + "h" + "-" + gMinute + "m" + "-" + gSecondes + "s" } else { return date.getFullYear() + "-" + gmonth + "-" + gday + "-" + gHour + "h" + "-" + gMinute + "m" + "-" + gSecondes + "s" } } module.exports.setMetricsFile = (path) => { metricsPathFile = path } module.exports.getMetricsFile = () => { if(!fs.existsSync()) { fs.writeFileSync(metricsPathFile, JSON.stringify([], null, 2)) } else { return JSON.parse(fs.readFileSync(metricsPathFile)) } } module.exports.saveMetricsFile = (data) => { fs.writeFileSync(metricsPathFile, JSON.stringify(data, null, 2)) }