Skip to content

Instantly share code, notes, and snippets.

@kureikei
Created October 23, 2014 13:23
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
void main() {
var today = new DateTime.now();
var calendar = new List.generate(6, (i) => new List.filled(7, " "));
for (var i = 1, week = 0; i <= new DateTime(today.year, today.month + 1, 0).day; i++) {
var day = new DateTime(today.year, today.month, i);
calendar[week][day.weekday % 7] += i.toString();
if (day.weekday == DateTime.SATURDAY) week++;
}
print(calendar.where((w) => w.any((d) => d.trim() != "")).map(
(w) => w.map((d) => d.substring(d.length - 2)).join(" ")).join("\r\n"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment