Conversation
Use Math.floor to have timestamp (full second) values. Use Date.now() to get milliseconds elapsed since the UNIX epoch.
| */ | ||
| const postLocation = (akey, locationObj, callback) => { | ||
| const now = parseInt(new Date() / 1000); | ||
| const now = Math.floor(Date.now() / 1000); |
There was a problem hiding this comment.
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
| */ | ||
| const postExtended = (akey, extendedObj, callback) => { | ||
| const now = parseInt(new Date() / 1000); | ||
| const now = Math.floor(Date.now() / 1000); |
There was a problem hiding this comment.
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
| */ | ||
| const postSoC = (akey, socObj, callback) => { | ||
| const now = parseInt(new Date() / 1000); | ||
| const now = Math.floor(Date.now() / 1000); |
There was a problem hiding this comment.
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
| // last activity track | ||
| app.use((req, res, next) => { | ||
| if (req.body.akey) db.query('UPDATE accounts SET lastactivity=? WHERE akey=?', [parseInt(new Date() / 1000), req.body.akey], () => next()); | ||
| if (req.body.akey) db.query('UPDATE accounts SET lastactivity=? WHERE akey=?', [Math.floor(Date.now() / 1000), req.body.akey], () => next()); |
There was a problem hiding this comment.
'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').
| ], (err, dbRes) => { | ||
| let data; | ||
| const now = parseInt(new Date() / 1000); | ||
| const now = Math.floor(Date.now() / 1000); |
There was a problem hiding this comment.
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
| // validate token | ||
| if (userObj.token === req.body.token) { | ||
| const now = parseInt(new Date() / 1000); | ||
| const now = Math.floor(Date.now() / 1000); |
There was a problem hiding this comment.
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
|
|
||
| if (!err && dbRes && (dbObj = dbRes[0])) { | ||
| const now = parseInt(new Date() / 1000); | ||
| const now = Math.floor(Date.now() / 1000); |
There was a problem hiding this comment.
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Use Math.floor to have timestamp (full second) values.
Use Date.now() to get milliseconds elapsed since the UNIX epoch.
parseInt has string parameter and calculation gives a number also most of the time creation of new Date object is unnecessary.