This commit is contained in:
Ingy döt Net 2013-04-10 21:29:02 -07:00
parent 764da6cbbb
commit db842d013d
19005 changed files with 197040 additions and 7 deletions

View file

@ -0,0 +1,44 @@
procedure main(A)
printCalendar(\A[1]|1969)
end
procedure printCalendar(year) #: Print a 3 column x 80 char calendar
cols := 3 # fixed width
mons := [] # table of months
"January February March April May June " ||
"July August September October November December " ?
while put(mons, tab(find(" "))) do move(1)
write(center("[Snoopy Picture]",cols * 24 + 4)) # mandatory ..
write(center(year,cols * 24 + 4), "\n") # ... headers
M := list(cols) # coexpr container
every mon := 0 to 9 by cols do { # go through months by cols
writes(" ")
every i := 1 to cols do {
writes(center(mons[mon+i],24)) # header months
M[i] := create CalendarFormatWeek(1969,mon + i) # formatting coexpr
}
write()
every 1 to 7 do { # 1 to max rows
every c := 1 to cols do { # for each column
writes(" ")
every 1 to 7 do writes(right(@M[c],3)) # each row day element
}
write()
}
}
end
link datetime
procedure CalendarFormatWeek(year,m) #: Format Week for Calendar
static D
initial D := [31,28,31,30,31,30,31,31,30,31,30,31]
every suspend "Su"|"Mo"|"Tu"|"We"|"Th"|"Fr"|"Sa" # header
every 1 to (d := (julian(m,1,year)+1)%7) do suspend "" # lead day alignment
every suspend 1 to D[m] do d +:= 1 # days
if m = 2 & IsLeapYear(year) then suspend (d +:= 1, 29) # LY adjustment
every d to (6*7) do suspend "" # trailer alignment
end

View file

@ -0,0 +1,5 @@
require 'dates format' NB. J6.x
require 'dates general/misc/format' NB. J7.x
calBody=: (1 1 }. _1 _1 }. ":)@(-@(<.@%&22)@[ ]\ calendar@])
calTitle=: (<: - 22&|)@[ center '[Insert Snoopy here]' , '' ,:~ ":@]
formatCalendar=: calTitle , calBody

View file

@ -0,0 +1,39 @@
80 formatCalendar 1969
[Insert Snoopy here]
1969
Jan │ Feb │ Mar
Su Mo Tu We Th Fr Sa│ Su Mo Tu We Th Fr Sa│ Su Mo Tu We Th Fr Sa
1 2 3 4│ 1│ 1
5 6 7 8 9 10 11│ 2 3 4 5 6 7 8│ 2 3 4 5 6 7 8
12 13 14 15 16 17 18│ 9 10 11 12 13 14 15│ 9 10 11 12 13 14 15
19 20 21 22 23 24 25│ 16 17 18 19 20 21 22│ 16 17 18 19 20 21 22
26 27 28 29 30 31 │ 23 24 25 26 27 28 │ 23 24 25 26 27 28 29
│ │ 30 31
─────────────────────┼─────────────────────┼─────────────────────
Apr │ May │ Jun
Su Mo Tu We Th Fr Sa│ Su Mo Tu We Th Fr Sa│ Su Mo Tu We Th Fr Sa
1 2 3 4 5│ 1 2 3│ 1 2 3 4 5 6 7
6 7 8 9 10 11 12│ 4 5 6 7 8 9 10│ 8 9 10 11 12 13 14
13 14 15 16 17 18 19│ 11 12 13 14 15 16 17│ 15 16 17 18 19 20 21
20 21 22 23 24 25 26│ 18 19 20 21 22 23 24│ 22 23 24 25 26 27 28
27 28 29 30 │ 25 26 27 28 29 30 31│ 29 30
│ │
─────────────────────┼─────────────────────┼─────────────────────
Jul │ Aug │ Sep
Su Mo Tu We Th Fr Sa│ Su Mo Tu We Th Fr Sa│ Su Mo Tu We Th Fr Sa
1 2 3 4 5│ 1 2│ 1 2 3 4 5 6
6 7 8 9 10 11 12│ 3 4 5 6 7 8 9│ 7 8 9 10 11 12 13
13 14 15 16 17 18 19│ 10 11 12 13 14 15 16│ 14 15 16 17 18 19 20
20 21 22 23 24 25 26│ 17 18 19 20 21 22 23│ 21 22 23 24 25 26 27
27 28 29 30 31 │ 24 25 26 27 28 29 30│ 28 29 30
│ 31 │
─────────────────────┼─────────────────────┼─────────────────────
Oct │ Nov │ Dec
Su Mo Tu We Th Fr Sa│ Su Mo Tu We Th Fr Sa│ Su Mo Tu We Th Fr Sa
1 2 3 4│ 1│ 1 2 3 4 5 6
5 6 7 8 9 10 11│ 2 3 4 5 6 7 8│ 7 8 9 10 11 12 13
12 13 14 15 16 17 18│ 9 10 11 12 13 14 15│ 14 15 16 17 18 19 20
19 20 21 22 23 24 25│ 16 17 18 19 20 21 22│ 21 22 23 24 25 26 27
26 27 28 29 30 31 │ 23 24 25 26 27 28 29│ 28 29 30 31
│ 30 │

View file

@ -0,0 +1 @@
Needs["Calendar`"];

View file

@ -0,0 +1,23 @@
monthlyCalendar[y_, m_] :=
Module[{
days = {Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday},
months = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"},
d1, shortDays, offset, daysInMonth},
d1 = DayOfWeek[{y, m, 1}];
daysInMonth[year_, month_] := DaysBetween[{year, month, 1}, {If[month == 12, year + 1, year], If[month == 12, 1, month + 1], 1}];
shortDays = (StringTake[ToString[#], 3] & /@ days);
offset = d1 /. Thread[days -> Range[0, 6]];
Grid[
Prepend[
Prepend[
Partition[
PadRight[PadLeft[Range[daysInMonth[y, m]], daysInMonth[y, m] + offset, ""],
36, "" ],
7],
shortDays],
{months[[m]], SpanFromLeft}]]]

View file

@ -0,0 +1 @@
yearlyCalendar[y_] := Grid[Partition[Table[monthlyCalendar[y, k], {k, 12}], 3], Spacings -> {4, 2}];