Calendar: Difference between revisions

Content added Content deleted
(→‎{{header|Tcl}}: Go into more depth in the complexities of the code)
(revised/clarified task & added Template:Needs-review. Also updated the ALGOL 68 code to match. BTW: μέγας κῦδος to the Tcl code for the "octubre 1582" :Europe/Madrid es_ES calendar!!!)
Line 1:
{{task|Date and time}}
Create a routine that will generate an ASCIItext calendar for any date. Test the calendar by generating a calendar for the year 1969 on a line[[wp:IBM_3270#Displays|IBM printer3278 ofmodel the4 timeterminal]] (80×43 display with aaccented widthcharacters) of 132the characterstime.
 
As a test case, target formatting the months of the year to fit nicely across the 80 character width page. Restrict number of lines in test output to 43.
Ideally the program will generate well formatted calendars for any page width from 20 characters up.
 
(Ideally the program will generate well formatted calendars for any page width from 20 characters up.)
 
Kudos (κῦδος) for routines that also correctly transition from Julian to Gregorian calendar in September 1752.
Line 9 ⟶ 11:
THE REAL PROGRAMMER'S NATURAL HABITAT
"Taped to the wall is a line-printer Snoopy calender for the year 1969."
SeeFor also:further TheKudos see task [[Calendar - for "real"_programmers programmers|CALENDAR]], taskfor printing on a 132 character width {{Wikipedia|IBM 1403}} printer. Where all code and output is to be in UPPERCASE.
 
For economy of size, do not actually include Snoopy generation in either the code or the output, instead just output a place-holder.
Line 121 ⟶ 123:
CO
INT mankind stepped on the moon = 1969,
line printer width = 13280; # as at 1969! #
print calendar(mankind stepped on the moon, line printer width)
)</lang>
Output:
<pre>
[Insert Snoopy here]
1969
 
January January February February March April May JuneMarch
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 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 1 2 3 4 5 1 2 3 1 2 3 4 5 6 7
5 6 7 8 9 10 11 2 3 4 5 6 7 8 2 3 4 5 6 7 8 6 7 8 2 9 10 11 12 3 4 5 6 7 8 9 10 8 9 10 11 12 13 14
12 13 14 15 16 17 18 9 10 11 12 13 14 15 9 10 11 12 13 14 15 13 14 15 16 17 18 199 10 11 12 13 14 15 16 17 15 16 17 18 19 20 21
19 20 21 22 23 24 25 16 17 18 19 20 21 22 16 17 18 19 20 21 22 20 21 22 23 24 25 2616 17 18 19 20 21 22 23 24 22 23 24 25 26 27 28
26 27 28 29 30 31 23 24 25 26 27 28 23 24 25 26 27 28 29 27 28 29 30 23 24 25 26 27 28 29 30 31 29 30
30 31 30 31
July April August May September October June November December
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 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 1 2 3 4 5 6 1 1 2 3 4 5 67
6 7 8 9 10 11 12 3 4 5 6 7 8 9 7 8 9 10 11 12 13 4 5 6 7 8 9 10 11 2 3 4 5 6 7 8 7 8 9 10 11 12 13 14
13 14 15 16 17 18 19 10 11 12 13 14 15 16 14 15 16 17 18 19 20 11 12 13 14 15 16 17 18 9 10 11 12 13 14 15 14 15 16 17 18 19 20 21
20 21 22 23 24 25 26 17 18 19 20 21 22 23 21 22 23 24 25 26 27 18 19 20 21 22 23 24 25 16 17 18 19 20 21 22 21 22 23 24 25 26 27 28
27 28 29 30 31 24 25 26 27 28 29 30 28 29 30 25 26 27 28 29 30 31 23 24 2529 2630 27 28 29 28 29 30 31
31 30
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 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
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 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
</pre>
 
=={{header|J}}==
{{Template:Needs-review}}
'''Solution:'''
<lang j>require 'dates format' NB. J6.x
Line 178 ⟶ 196:
 
=={{header|PicoLisp}}==
{{Template:Needs-review}}
This "calendar" is nicely formated, and fits into 20 columns ;-)
<lang PicoLisp>(de cal (Year)
Line 219 ⟶ 238:
 
=={{header|Python}}==
{{Template:Needs-review}}
The Python [http://docs.python.org/py3k/library/calendar.html calendar].pryear function prints calendars with the following formatting options: optional parameters w, l, and c are for date column width, lines per week, and number of spaces between month columns, respectively.
 
Line 261 ⟶ 281:
 
=={{header|Ruby}}==
{{Template:Needs-review}}
{{incomplete|Ruby|The width is always 130 characters. The program needs more code to adjust the calendar for different widths.}}
<lang ruby>require 'date'