Created
June 26, 2011 18:06
-
-
Save sreeix/1047810 to your computer and use it in GitHub Desktop.
View to check overlap
This file contains 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
function(doc) { | |
if (doc.type && doc.type === 'commission' && doc.affiliate_network && doc.begins && doc.ends) { | |
var current = doc.begins.split(/-/); | |
var ends = doc.ends.split(/-/); | |
var current_date = new Date(parseInt(current[0], 10), parseInt(current[1], 10) - 1, parseInt(current[2], 10) + 1); // javascript month starts at 0 | |
var ends_date = new Date(parseInt(ends[0], 10), parseInt(ends[1], 10) - 1, parseInt(ends[2], 10) + 1); // javascript month starts at 0 | |
while( current_date < ends_date){ | |
emit([doc.network, doc.provider, current_date.getFullYear(), current_date.getMonth()+1, current_date.getDate()], null); | |
current_date = new Date(current_date.getTime() + 86400000); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment