Ajout gestion Look & Sync firmwares, et routes BST
This commit is contained in:
3
util/index.js
Normal file
3
util/index.js
Normal file
@@ -0,0 +1,3 @@
|
||||
const util = require('./util.js')
|
||||
|
||||
module.exports = util
|
||||
34
util/util.js
Normal file
34
util/util.js
Normal file
@@ -0,0 +1,34 @@
|
||||
|
||||
|
||||
const dateToTimestamp = function (date) {
|
||||
var iteration = 0
|
||||
|
||||
while (1) {
|
||||
try {
|
||||
switch (iteration++) {
|
||||
///// ISO String
|
||||
case 0: return Math.floor(Date.parse(date) / 1000);
|
||||
|
||||
///// Timestamp string
|
||||
case 2:
|
||||
if (typeof(date) != 'string') continue;
|
||||
date = parseInt(date); break;
|
||||
|
||||
///// Timestamp integer
|
||||
case 1:
|
||||
if (typeof(date) != 'integer') continue;
|
||||
// if (date > 0xFFFFFFFF) return Math.floor(date / 1000)
|
||||
else return date;
|
||||
|
||||
default: return undefined
|
||||
}
|
||||
} catch (e) { continue }
|
||||
}
|
||||
}
|
||||
|
||||
const unixTimestamp = function () { return Math.floor(Date.now() / 1000) }
|
||||
|
||||
module.exports = {
|
||||
dateToTimestamp,
|
||||
unixTimestamp,
|
||||
}
|
||||
Reference in New Issue
Block a user