calendar ← ##.cal date ⍝ Calendar.
[cal] is an emulation of Unix shell command cal(1). Right argument [date] may be
one of:
yyyy ⍝ year, eg: 1986
yyyy mm ⍝ year and month, eg: 2009 12
mm ⍝ relative month, 0 means current month, ¯1 means last month ...
[cal] distinguishes the "yyyy" and "mm" cases on range. If the argument is a
single number in the range ¯12 to 12, it is interpreted as a relative month.
Otherwise, it is taken as a year. This means that [cal] cannot return a calendar
for the years ¯0012 to 0012.
Requires: →date← →days←
Examples:
cal 0 ⍝ current month
December 2009
Su Mo Tu We Th Fr Sa
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
cal ¯1 ⍝ last month
November 2009
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
cal 2 ⍝ the month after next.
February 2010
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28
cal 1985 2 ⍝ calendar for specific month.
February 1985
Su Mo Tu We Th Fr Sa
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28
cal 1752 09 ⍝ Sept 1752 was a short month in Merrie England.
September 1752
Su Mo Tu We Th Fr Sa
1 2 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
cal 2010 ⍝ calendar for a specific year.
2010
January February March
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 2 1 2 3 4 5 6 1 2 3 4 5 6
3 4 5 6 7 8 9 7 8 9 10 11 12 13 7 8 9 10 11 12 13
10 11 12 13 14 15 16 14 15 16 17 18 19 20 14 15 16 17 18 19 20
17 18 19 20 21 22 23 21 22 23 24 25 26 27 21 22 23 24 25 26 27
24 25 26 27 28 29 30 28 28 29 30 31
31
April May June
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 2 3 1 1 2 3 4 5
4 5 6 7 8 9 10 2 3 4 5 6 7 8 6 7 8 9 10 11 12
11 12 13 14 15 16 17 9 10 11 12 13 14 15 13 14 15 16 17 18 19
18 19 20 21 22 23 24 16 17 18 19 20 21 22 20 21 22 23 24 25 26
25 26 27 28 29 30 23 24 25 26 27 28 29 27 28 29 30
30 31
July August September
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 2 3 1 2 3 4 5 6 7 1 2 3 4
4 5 6 7 8 9 10 8 9 10 11 12 13 14 5 6 7 8 9 10 11
11 12 13 14 15 16 17 15 16 17 18 19 20 21 12 13 14 15 16 17 18
18 19 20 21 22 23 24 22 23 24 25 26 27 28 19 20 21 22 23 24 25
25 26 27 28 29 30 31 29 30 31 26 27 28 29 30
October November December
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 2 1 2 3 4 5 6 1 2 3 4
3 4 5 6 7 8 9 7 8 9 10 11 12 13 5 6 7 8 9 10 11
10 11 12 13 14 15 16 14 15 16 17 18 19 20 12 13 14 15 16 17 18
17 18 19 20 21 22 23 21 22 23 24 25 26 27 19 20 21 22 23 24 25
24 25 26 27 28 29 30 28 29 30 26 27 28 29 30 31
31
⍝ Yves Tanguy points out that while playing on an unlucky date might not improve
⍝ my chances of _winning_ the Rollover Jackpot, doing so might reduce the number
⍝ of other winners with whom I have to share. To this end, Yves suggests playing
⍝ on Friday 13th.
isFr13←{∨/{6=⍎⍕¯1↑0,⍕⍸13=⍎⍕,⍵}¨2↓1⊂[1]⍵}
mois←'Jan' 'Fév' 'Mar' 'Avr' 'Mai' 'Juin' 'Juil' 'Août' 'Sept' 'Oct' 'Nov' 'Déc'
whenFr13←{⍵,mois[⍸⍵∘{isFr13 cal ⍺ ⍵}¨⍳12]}
whenFr13¨ 2018 2019 2020
┌───────────────┬───────────────┬──────────────┐
│┌────┬───┬────┐│┌────┬────┬───┐│┌────┬───┬───┐│
││2018│Avr│Juil│││2019│Sept│Déc│││2020│Mar│Nov││
│└────┴───┴────┘│└────┴────┴───┘│└────┴───┴───┘│
└───────────────┴───────────────┴──────────────┘
See also: Dates date days
Back to: contents
Back to: Workspaces