Skip to content

Instantly share code, notes, and snippets.

@3846masa
Created October 28, 2014 06:28
Show Gist options
  • Save 3846masa/23a95b04f7b16cdb9fbb to your computer and use it in GitHub Desktop.
Save 3846masa/23a95b04f7b16cdb9fbb to your computer and use it in GitHub Desktop.
ceylonでカレンダー
//@3846masa
import ceylon.time { now, date, Date }
void run() {
Date today = now().date();
Integer start_wday = date(today.year, today.month, 1).dayOfWeek.integer;
Integer all_days = today.month.numberOfDays();
for (day in (1 - start_wday)..all_days) {
String day_str = (day <= 0) then "" else day.string;
process.write(day_str.padLeading(2));
String pad = ((day + start_wday) % 7 == 0) then "\n" else " ";
process.write(pad);
}
process.write("\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment