65 lines
1.5 KiB
JavaScript
65 lines
1.5 KiB
JavaScript
|
const fs = require("fs")
|
||
|
const path = require("path")
|
||
|
|
||
|
module.exports.getDate = function (formated) {
|
||
|
|
||
|
var date = new Date()
|
||
|
|
||
|
// [Date Format] - Format de la date
|
||
|
|
||
|
var gmonth = date.getMonth()
|
||
|
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.checkLogsDirectory = () => {
|
||
|
|
||
|
if(!fs.existsSync(__dirname + path.sep + "logs" + path.sep)) {
|
||
|
fs.mkdir(__dirname + path.sep + "logs", (err) => {
|
||
|
if(!err) {
|
||
|
|
||
|
|
||
|
console.log("[Logs] - Dossier de logs crée ! !")
|
||
|
|
||
|
} else {
|
||
|
|
||
|
console.log("[Logs] -Erreur d'écriture par manque de permission ")
|
||
|
console.log(err)
|
||
|
}
|
||
|
|
||
|
})
|
||
|
|
||
|
}
|
||
|
}
|