Anonymous user
Calendar: Difference between revisions
Tighter code, verbage
(added zkl) |
(Tighter code, verbage) |
||
Line 3,648:
<lang zkl>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
(1).pump(dayz,(0).pump(day1,T,T(Void,""))).apply("%2s ".fmt)
}
const M=70; // mystery number
fcn oneYear(y,title){
println(center(
[1..12,3].pump(String,'wrap(m){ // 3 months per line
mmm:=
if (mmm.apply("len").sum() % 3) // months have diff # of lines, pad
mmm=mmm.apply("append","");
Line 3,672 ⟶ 3,670:
}
oneYear(1969,"3 Days of Peace & Music").println();</lang>
oneMonth produces a list of strings that make up a one month calender. Each day is three characters, the first line is padded with blanks to line it up with the 1st day of the week. The entire month is one long list of "days" that is then chunked into a list of weeks (one line per week). oneYear takes 3 months and builds the page line by line.
{{out}}
<pre>
|