filter paleo by 3 days

This commit is contained in:
unknown 2015-07-23 13:25:35 +01:00
parent a2dd4b76ff
commit 43d658da71
2 changed files with 19 additions and 1 deletions

View File

@ -20,7 +20,7 @@ feeds.simple_test_feed = {
"description": "Combined Paleo Feed",
'site_url': 'http://pipes.silvrtree.co.uk/paleo.xml'
},
"plugins" : ['filter_last_week' ],
"plugins" : ['filter_3_days' ],
"sources": [
{
/* "name" : "JobServe",*/

18
plugins/filter_3_days.js Normal file
View File

@ -0,0 +1,18 @@
module.exports = function (item, itemOptions, source) {
function inDays(d1, d2) {
var t2 = d2.getTime();
var t1 = d1.getTime();
return parseInt((t2-t1)/(24*3600*1000));
}
var now = new Date();
var then = new Date(itemOptions.date);
var d = inDays(then,now);
if (d < 3)
return itemOptions;
else
return -1;
};