Loop over dates

Dates can be ranges to.

def today = new Date()
def later = today + 3
(today..later).eachWithIndex() {
d, i -> println "[${i}] ${d}"
}

This will output.

[0] Sun Mar 23 21:15:57 CET 2008
[1] Mon Mar 24 21:15:57 CET 2008
[2] Tue Mar 25 21:15:57 CET 2008
[3] Wed Mar 26 21:15:57 CET 2008