Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ttdoda
Last active August 29, 2015 14:08
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 ttdoda/00ea97bbf47a5a646797 to your computer and use it in GitHub Desktop.
Save ttdoda/00ea97bbf47a5a646797 to your computer and use it in GitHub Desktop.
date = getdate(time());
t = getdate(mktime(0, 0, 0, date.mon, 1, date.year));
offset = t.wday;
if (date.mon == 12) {
date.year += 1;
date.mon = 1;
}
else {
date.mon += 1;
}
t = getdate(mktime(0, 0, 0, date.mon, 1, date.year)-1);
count = t.mday;
echo("\x1b[2J\x1b[H"); // 画面消去
for (i=0; i<offset; i++) {
echo(" ");
}
for (i=1; i<=count; i++) {
echo(sprintf("%2d%s", i, (++offset%7==0)?"\n":" "));
}
if (offset % 7 != 0) {
echo("\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment