diff --git a/src/notifications.js b/src/notifications.js index 3e63628068..f0a7c3e892 100644 --- a/src/notifications.js +++ b/src/notifications.js @@ -34,7 +34,7 @@ var RDB = require('./redis.js'), 'text', text || '', 'score', score || 5, 'path', path || null, - 'datetime', new Date().getTime(), + 'datetime', Date.now(), 'uniqueId', uniqueId || utils.generateUUID(), function(err, status) { if (status === 'OK') callback(nid); diff --git a/src/postTools.js b/src/postTools.js index ac1499aa8e..f64569b558 100644 --- a/src/postTools.js +++ b/src/postTools.js @@ -56,7 +56,7 @@ marked.setOptions({ PostTools.edit = function(uid, pid, title, content) { var success = function() { RDB.set('pid:' + pid + ':content', content); - RDB.set('pid:' + pid + ':edited', new Date().getTime()); + RDB.set('pid:' + pid + ':edited', Date.now()); RDB.set('pid:' + pid + ':editor', uid); posts.get_tid_by_pid(pid, function(tid) { diff --git a/src/posts.js b/src/posts.js index 44d90ce251..30807e830f 100644 --- a/src/posts.js +++ b/src/posts.js @@ -167,7 +167,7 @@ marked.setOptions({ user.getUserField(uid, 'lastposttime', function(lastposttime) { - if(new Date().getTime() - lastposttime < config.post_delay) { + if(Date.now() - lastposttime < config.post_delay) { socket.emit('event:alert', { title: 'Too many posts!', message: 'You can only post every '+ (config.post_delay / 1000) + ' seconds.', @@ -185,7 +185,7 @@ marked.setOptions({ Posts.get_cid_by_pid(pid, function(cid) { RDB.del('cid:' + cid + ':read_by_uid'); - RDB.zadd('categories:recent_posts:cid:' + cid, (new Date()).getTime(), pid); + RDB.zadd('categories:recent_posts:cid:' + cid, Date.now(), pid); }); // Re-add the poster, so he/she does not get an "unread" flag on this topic @@ -204,7 +204,7 @@ marked.setOptions({ user.getUserFields(uid, ['username','reputation','picture','signature'], function(data) { - var timestamp = new Date().getTime(); + var timestamp = Date.now(); io.sockets.in('topic_' + tid).emit('event:new_post', { 'posts' : [ @@ -248,7 +248,7 @@ marked.setOptions({ RDB.incr('global:next_post_id', function(err, pid) { RDB.handle(err); - var timestamp = new Date().getTime(); + var timestamp = Date.now(); // Posts Info RDB.set('pid:' + pid + ':content', content); RDB.set('pid:' + pid + ':uid', uid); diff --git a/src/topics.js b/src/topics.js index 1a49e4359f..4b9a2127e2 100644 --- a/src/topics.js +++ b/src/topics.js @@ -322,7 +322,7 @@ marked.setOptions({ user.getUserField(uid, 'lastposttime', function(lastposttime) { - if(new Date().getTime() - lastposttime < config.post_delay) { + if(Date.now() - lastposttime < config.post_delay) { socket.emit('event:alert', { title: 'Too many posts!', message: 'You can only post every '+ (config.post_delay / 1000) + ' seconds.', @@ -350,7 +350,7 @@ marked.setOptions({ RDB.set(schema.topics(tid).title, title); RDB.set(schema.topics(tid).uid, uid); RDB.set(schema.topics(tid).slug, slug); - RDB.set(schema.topics(tid).timestamp, new Date().getTime()); + RDB.set(schema.topics(tid).timestamp, Date.now()); RDB.set('topic:slug:' + slug + ':tid', tid); @@ -384,7 +384,7 @@ marked.setOptions({ // let everyone know that there is an unread topic in this category RDB.del('cid:' + category_id + ':read_by_uid'); - RDB.zadd(schema.topics().recent, (new Date()).getTime(), tid); + RDB.zadd(schema.topics().recent, Date.now(), tid); //RDB.zadd('topics:active', tid); // in future it may be possible to add topics to several categories, so leaving the door open here. diff --git a/src/websockets.js b/src/websockets.js index 0f67153762..5aae09ba1e 100644 --- a/src/websockets.js +++ b/src/websockets.js @@ -286,7 +286,7 @@ var SocketIO = require('socket.io').listen(global.server, { log:false }), userSockets[touid][x].emit('chatMessage', {fromuid:uid, username:username, message:finalMessage}); } - notifications.create(finalMessage, 5, '', 'notification_'+new Date().getTime(), function(nid) { + notifications.create(finalMessage, 5, '', 'notification_'+Date.now(), function(nid) { notifications.push(nid, [touid], function(success) { });