-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutils.js
More file actions
29 lines (24 loc) · 657 Bytes
/
utils.js
File metadata and controls
29 lines (24 loc) · 657 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const config = require('./config');
console.log('Timezone correcter:', (config.CORR / 3600000), 'hour(s)');
const addZeros = (nbr) => (Number(nbr) < 10 ? `0${nbr}` : `${nbr}`);
const dateCorr = (...keys) => (item) => {
const rs = item;
for (const k of keys) {
if (rs[k] instanceof Date) rs[k] = rs[k].getTime() - config.CORR;
}
return rs;
};
const nowDate = () => {
const d = new Date(Date.now() + config.CORR);
return `> ${addZeros(d.getDate())
}/${addZeros(d.getMonth() + 1)
} ${addZeros(d.getHours())
}:${addZeros(d.getMinutes())
}:${addZeros(d.getSeconds())
}`;
};
module.exports = {
addZeros,
dateCorr,
nowDate,
};