26 lines
1 KiB
Text
26 lines
1 KiB
Text
var [const] D=Time.Date, days="Su Mo Tu We Th Fr Sa";
|
|
|
|
fcn center(text,m) { String(" "*((m-text.len())/2),text) }
|
|
|
|
fcn oneMonth(year,month){
|
|
day1:=D.zeller(year,month,1); //1969-1-1 -->3 (Wed, ISO 8601)
|
|
dayz:=D.daysInMonth(year,month); //1969-1 -->31
|
|
List(center(D.monthNames[month],days.len()),days).extend(
|
|
(1).pump(dayz,(0).pump(day1,List,T(Void,""))).apply("%2s ".fmt)
|
|
.pump(List,T(Void.Read,days.len()/3,False),String.create));
|
|
}
|
|
|
|
const M=70; // mystery number
|
|
fcn oneYear(y=1969,title="3 Days of Peace & Music"){
|
|
println(center(title,M),"\n",center(y.toString(),M),"\n");
|
|
[1..12,3].pump(String,'wrap(m){ // 3 months per line
|
|
mmm:=(m).pump(3,List,oneMonth.fp(y)); //L(L(7-8 lines), L(...), L(...))
|
|
if(mmm.apply("len").sum() % 3) // months have diff # of lines, pad
|
|
mmm=mmm.apply("append","");
|
|
Utils.zipWith("%-25s%-25s%-25s\n".fmt,
|
|
mmm.xplode()).concat() + (if (m<D.October) "\n" else "")
|
|
})
|
|
}
|
|
|
|
if(vm.numArgs){ y:=vm.nthArg(0).toInt(); oneYear(y,"").println(); }
|
|
else oneYear().println();
|