Date string update, midnight timer update, other stuff

This commit is contained in:
MrFry 2020-04-07 15:00:39 +02:00
parent c764c4f402
commit dbb23a6724
6 changed files with 92 additions and 61 deletions

View file

@ -11,15 +11,6 @@ let authDB
console.clear()
CreateDB()
// authDB.backup(usersDBPath)
// .then(() => {
// logger.Log('backup complete!')
// })
// .catch((err) => {
// logger.Log('backup failed!', logger.GetColor('redbg'))
// console.log(err)
// })
authDB.close()
function CreateDB () {
@ -44,7 +35,7 @@ function CreateDB () {
pw: uuidv4(),
oldCID: cid,
avaiblePWRequests: 4,
created: new Date().toString()
created: utils.GetDateString()
})
} catch (e) {
logger.Log('Error during inserting', logger.GetColor('redbg'))
@ -55,7 +46,7 @@ function CreateDB () {
console.error(e)
}
const dir = `./dbSetupResult/${GetDateString().replace(/ /g, '_')}`
const dir = `./dbSetupResult/${utils.GetDateString().replace(/ /g, '_')}`
utils.CreatePath(dir)
Object.keys(dbStruct).forEach((key) => {
const path = `${dir}/${key}.json`
@ -68,14 +59,3 @@ function CreateDB () {
logger.Log('Done')
}
function GetDateString () {
const m = new Date()
const d = m.getFullYear() + '-' +
('0' + (m.getMonth() + 1)).slice(-2) + '-' +
('0' + m.getDate()).slice(-2) + ' ' +
('0' + m.getHours()).slice(-2) + ':' +
('0' + m.getMinutes()).slice(-2) + ':' +
('0' + m.getSeconds()).slice(-2)
return d
}

View file

@ -64,12 +64,7 @@ let noLogips = []
function GetDateString () {
const m = new Date()
const d = m.getFullYear() + '/' +
('0' + (m.getMonth() + 1)).slice(-2) + '/' +
('0' + m.getDate()).slice(-2) + ' ' +
('0' + m.getHours()).slice(-2) + ':' +
('0' + m.getMinutes()).slice(-2) + ':' +
('0' + m.getSeconds()).slice(-2)
const d = utils.GetDateString()
return GetRandomColor(m.getHours().toString()) + d + C()
}

View file

@ -10,7 +10,8 @@ module.exports = {
CreatePath: CreatePath,
WatchFile: WatchFile,
ReadDir: ReadDir,
CopyFile: CopyFile
CopyFile: CopyFile,
GetDateString: GetDateString
}
var fs = require('fs')
@ -19,6 +20,16 @@ var logger = require('../utils/logger.js')
const dataFile = './public/data.json'
function GetDateString () {
const m = new Date()
return m.getFullYear() + '-' +
('0' + (m.getMonth() + 1)).slice(-2) + '-' +
('0' + m.getDate()).slice(-2) + ' ' +
('0' + m.getHours()).slice(-2) + ':' +
('0' + m.getMinutes()).slice(-2) + ':' +
('0' + m.getSeconds()).slice(-2)
}
function CopyFile (from, to) {
CreatePath(to)
fs.copyFileSync(from, to)