-
-
Save escuderomoyano/2cee5980d0a7a5a06d3a143e768d25b1 to your computer and use it in GitHub Desktop.
AngularJS daterange filter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RB.filter('daterange', function () | |
{ | |
return function(conversations, start_date, end_date) | |
{ | |
var result = []; | |
// date filters | |
var start_date = (start_date && !isNaN(Date.parse(start_date))) ? Date.parse(start_date) : 0; | |
var end_date = (end_date && !isNaN(Date.parse(end_date))) ? Date.parse(end_date) : new Date().getTime(); | |
// if the conversations are loaded | |
if (conversations && conversations.length > 0) | |
{ | |
$.each(conversations, function (index, conversation) | |
{ | |
var conversationDate = new Date(conversation.date_posted); | |
if (conversationDate >= start_date && conversationDate <= end_date) | |
{ | |
result.push(conversation); | |
} | |
}); | |
return result; | |
} | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment