Skip to content

Instantly share code, notes, and snippets.

@TheDahv
Forked from smoak/gist:1945982
Created March 1, 2012 00:38
Show Gist options
  • Save TheDahv/1946234 to your computer and use it in GitHub Desktop.
Save TheDahv/1946234 to your computer and use it in GitHub Desktop.
var groupedByWeek = new List<DateTime> {
new DateTime(2012, 02, 01),
new DateTime(2012, 02, 02),
new DateTime(2012, 02, 06),
new DateTime(2012, 02, 13)
}.
GroupBy(s => s.DayOfYear / 7).
ToDictionary(
s => (new DateTime(2012, 01, 01).AddDays((s.First().DayOfYear / 7) * 7)),
s => s.Count()
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment