Skip to content

Instantly share code, notes, and snippets.

@hamnis
Created March 26, 2015 07:38
Show Gist options
  • Save hamnis/08f52073d4281449d7bc to your computer and use it in GitHub Desktop.
Save hamnis/08f52073d4281449d7bc to your computer and use it in GitHub Desktop.
def extractPartitionKey(duration: ReadablePeriod, now: DateTime = DateTime.now(DateTimeZone.UTC)): Seq[String] = {
val end = now.withZone(DateTimeZone.UTC)
val period = new Interval(duration, end)
val start = period.getStart
val fmt = ISODateTimeFormat.date()
val days = Days.daysBetween(start.withTimeAtStartOfDay(), end).getDays
for (d <- 0 to days) yield start.plusDays(d).toString(fmt)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment