Created
June 17, 2013 18:31
-
-
Save firefly05/5799075 to your computer and use it in GitHub Desktop.
Traverse document for any element that has a due date. Then compare that date to today's date. Use the difference for whatever purpose you like. My original, color the table cells yellow if the item is due in two days or less
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
// get the current date | |
var now = new Date(); | |
var curr_date = now.getDate(); | |
var curr_month = now.getMonth() + 1; | |
var curr_year = now.getFullYear(); | |
// format current date as it is in Redmine so we can do the math | |
var now = curr_month + '/' + curr_date + '/' + curr_year; | |
var now | |
console.log(now); | |
// find each table cell with a due date | |
$('.due_date').each(function(){ | |
//find due date of this row | |
var date1 = new Date(now); | |
var date2 = new Date($(this).text()); | |
var timeDiff = Math.abs(date2.getTime() - date1.getTime()); | |
var diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24)); | |
// if it is due within two days, add due soon class | |
if(diffDays <= 2) { | |
$(this).parent().css('background-color','#ffffdd'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment