Created
March 28, 2011 19:58
-
-
Save danieldbower/891142 to your computer and use it in GitHub Desktop.
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
Date enddate = new Date() | |
Date startdate = enddate - 20 | |
//headers | |
println "Date - Year - Quarter - Month - Month - Month - WeekOfYear - WeekOfMonth - DayInYear - DayInMonth - DayInWeek - DayInWeek - DayInWeek - Weekday/Weekend" | |
//loop through each day | |
(startdate..enddate).each{ day -> | |
//Is this a weekend or a weekday? | |
def weekendStatus = 'Weekday' | |
if(day[Calendar.DAY_OF_WEEK]==Calendar.SUNDAY || day[Calendar.DAY_OF_WEEK]==Calendar.SATURDAY){ | |
weekendStatus = 'Weekend' | |
} | |
def quarter = ((day[Calendar.MONTH]/3).intValue() + 1) | |
//Just print the output | |
println day.getDateString() + ' ' + day.format("yyyy") + ' ' + quarter + ' ' + day.format("MM") + ' ' + day.format("MMM") + ' ' + day.format("MMMM") + ' ' + day.format("ww") + ' ' + day.format("WW") + ' ' + day.format("DDD") + ' ' + day.format("dd") + ' ' + day[Calendar.DAY_OF_WEEK] + ' ' + day.format("E")+ ' ' + day.format("EEEE") + ' ' + weekendStatus | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment