Initial commit

This commit is contained in:
2023-11-03 21:12:55 +01:00
parent a4afe6cc85
commit 57362e7520
39 changed files with 3505 additions and 1 deletions
+38
View File
@@ -0,0 +1,38 @@
module.exports = {
name:"readableTime",
async timeframe(seconds){
return new Promise(resolve => {
seconds = Math.floor(Number(seconds)/1000);
var d = Math.floor(seconds / (3600*24));
var h = Math.floor(seconds % (3600*24) / 3600);
var m = Math.floor(seconds % 3600 / 60);
var s = Math.floor(seconds % 60);
var dDisplay = d > 0 ? d + (d == 1 ? " day, " : " days, ") : "";
var hDisplay = h > 0 ? h + (h == 1 ? " hour, " : " hours, ") : "";
var mDisplay = m > 0 ? m + (m == 1 ? " minute, " : " minutes, ") : "";
var sDisplay = s > 0 ? s + (s == 1 ? " second" : " seconds") : "";
resolve(dDisplay + hDisplay + mDisplay + sDisplay);
})
},
async timestamp(timestamp=new Date()){
return new Promise(resolve => {
let vals = {
yyyy: timestamp.getFullYear(),
m: timestamp.getMonth()+1,
d: timestamp.getDate(),
h: timestamp.getHours(),
mi: timestamp.getMinutes(),
s: timestamp.getSeconds(),
ms: timestamp.getMilliseconds()
};
// console.log(`${vals.yyyy}/${vals.m}/${vals.d} ${vals.h}:${vals.mi}:${vals.s}`);
resolve(`${vals.yyyy}/${vals.m}/${vals.d} ${vals.h}:${vals.mi}:${vals.s}`)
})
}
}