Created
September 15, 2016 21:51
-
-
Save crocker/806fc453e0e1f8684bb00a2d9f6c503d 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
def getDateRange(year: Int, week: Int): (LocalDate, LocalDate) = { | |
val date = new LocalDate().withYear(year).withWeekOfWeekyear(week) | |
val startDate = date.withDayOfWeek(1) | |
val endDate = date.withDayOfWeek(7) | |
(startDate, endDate) | |
} | |
val dateFormat = "yyyy-MM-dd E" | |
val year = 2016 | |
for(week <- 1 to 52) { | |
val range = getDateRange(year, week) | |
val previousRange = getDateRange(year-1, week) | |
println(s"Week ${week}: ${range._1.toString(dateFormat)} - ${range._2.toString(dateFormat)} | ${previousRange._1.toString(dateFormat)} - ${previousRange._2.toString(dateFormat)}") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment