updated everything to make it general

This commit is contained in:
Jayex
2022-01-06 19:01:27 +01:00
parent 02f71f5ed0
commit 3634ab8865
17 changed files with 525 additions and 227 deletions
+15
View File
@@ -0,0 +1,15 @@
const sleep = (ms) => {
return new Promise(resolve => setTimeout(resolve, ms));
};
const randomInRange = (min, max) => {
return Math.floor(Math.random() * (max - min)) + min;
};
const logMessage = (module, message) => {
console.log(`[${module}]: ${message}`);
};
const logObject = (module, object) => {
console.log(`[${module}]: `, object);
};
+52
View File
@@ -0,0 +1,52 @@
timeFunc = {
addHours(time, h) {
time.setTime(time.getTime() + (h * 60 * 60 * 1000));
return time;
},
addMinutes(time, m) {
time.setTime(time.getTime() + (m * 60 * 1000));
return time;
},
addSeconds (time, s) {
time.setTime(time.getTime() + (s * 1000));
return time;
},
getHours(time) {
let hours;
if (typeof time !== 'number') {
hours = time.getHours().toString();
}
else {
hours = Math.floor(time / (1000 * 60 * 60)).toString();
}
hours = (hours.length < 2) ? `0${hours}` : hours;
return hours;
},
getMinutes(time) {
let minutes;
if (typeof time !== 'number') {
minutes = time.getMinutes().toString();
}
else {
minutes = Math.floor((time % (1000 * 60 * 60)) / (1000 * 60)).toString();
}
minutes = (minutes.length < 2) ? `0${minutes}` : minutes;
return minutes;
},
getSeconds(time) {
let seconds;
if (typeof time !== 'number') {
seconds = time.getSeconds().toString();
}
else {
seconds = Math.floor((time % (1000 * 60)) / 1000).toString();
}
seconds = (seconds.length < 2) ? `0${seconds}` : seconds;
return seconds;
}
};
+1
View File
File diff suppressed because one or more lines are too long