Skip to content

Instantly share code, notes, and snippets.

@kureikei
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kureikei/0e498e358c002005b690 to your computer and use it in GitHub Desktop.
Save kureikei/0e498e358c002005b690 to your computer and use it in GitHub Desktop.
var t = new Date();
var count = new Date(t.getFullYear(), t.getMonth() + 1, 0).getDate();
var offset = new Date(t.getFullYear(), t.getMonth(), 1).getDay();
var body = "";
for (var i = 0; i < offset; i++) {
body += " ";
}
for (var i = 1; i <= count; i++) {
body += (" " + i).slice(-2);
body += ((i + offset) % 7 == 0) ? "\n" : " ";
}
console.log(body);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment