June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -0,0 +1,33 @@
|
|||
DECLARE MON$[] = { "JANUARY", "FEBRUARY", "MARCH", "APRIL", "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER" }
|
||||
DECLARE MON[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
|
||||
Y$ = "1969"
|
||||
' Leap year
|
||||
INCR MON[1], IIF(MOD(VAL(Y$), 4) = 0 OR MOD(VAL(Y$), 100) = 0 AND MOD(VAL(Y$), 400) <> 0, 1, 0)
|
||||
PRINT ALIGN$("[SNOOPY HERE]", 132, 2)
|
||||
PRINT ALIGN$(Y$, 132, 2)
|
||||
FOR NR = 0 TO 11
|
||||
ROW = 3
|
||||
GOTOXY 1+(NR %6)*22, ROW+(NR/6)*9
|
||||
PRINT ALIGN$(MON$[NR], 21, 2);
|
||||
INCR ROW
|
||||
GOTOXY 1+(NR %6)*22, ROW+(NR/6)*9
|
||||
PRINT ALIGN$("MO TU WE TH FR SA SU", 21, 2);
|
||||
INCR ROW
|
||||
' Each day
|
||||
FOR D = 1 TO MON[NR]
|
||||
' Zeller
|
||||
J = VAL(LEFT$(Y$, 2))
|
||||
K = VAL(MID$(Y$, 3, 2))
|
||||
M = NR+1
|
||||
IF NR < 2 THEN
|
||||
INCR M, 12
|
||||
DECR K
|
||||
END IF
|
||||
H = (D + ((M+1)*26)/10 + K + (K/4) + (J/4) + 5*J)
|
||||
DAYNR = MOD(H, 7) - 2
|
||||
IF DAYNR < 0 THEN INCR DAYNR, 7
|
||||
IF DAYNR = 0 AND D > 1 THEN INCR ROW
|
||||
GOTOXY 1+(NR %6)*22+DAYNR*3, ROW+(NR/6)*9
|
||||
PRINT D;
|
||||
NEXT
|
||||
NEXT
|
||||
|
|
@ -15,18 +15,18 @@ class CalendarMonthPrinter
|
|||
object theYear.
|
||||
object theRow.
|
||||
|
||||
constructor new year:aYear month:aMonth
|
||||
constructor year:aYear month:aMonth
|
||||
[
|
||||
theMonth := aMonth.
|
||||
theYear := aYear.
|
||||
theLine := TextBuffer new.
|
||||
theRow := Integer new int:0.
|
||||
theLine := TextBuilder new.
|
||||
theRow := Integer new(0).
|
||||
]
|
||||
|
||||
writeTitle
|
||||
[
|
||||
theRow set:0.
|
||||
theDate := Date new year(theYear int) month(theMonth int) day:1.
|
||||
theRow value := 0.
|
||||
theDate := Date new(theYear, theMonth, 1).
|
||||
DayNames forEach(:aName)
|
||||
[ theLine print(" ",aName) ]
|
||||
]
|
||||
|
|
@ -39,38 +39,43 @@ class CalendarMonthPrinter
|
|||
[
|
||||
theLine write:" " length((theDate dayOfWeek == 0)iif(7,theDate dayOfWeek) - 1).
|
||||
|
||||
control do:
|
||||
[
|
||||
theLine write:(theDate day; literal) paddingLeft:3 with:$32.
|
||||
|
||||
theDate := theDate add days:1.
|
||||
theDate := theDate addDays:1.
|
||||
]
|
||||
until:$((theDate month != theMonth)or:$(theDate dayOfWeek == 1)).
|
||||
repeatUntil:$((theDate month != theMonth)||(theDate dayOfWeek == 1)).
|
||||
].
|
||||
|
||||
int aLength := theLine length.
|
||||
if (aLength < 21)
|
||||
[ theLine write:" " length(21 - aLength). ].
|
||||
|
||||
theRow append int:1.
|
||||
theRow append(1).
|
||||
]
|
||||
|
||||
indexer = Indexer::
|
||||
indexer = BaseIndexer::
|
||||
{
|
||||
available = theRow < 7.
|
||||
bool available = theRow < 7.
|
||||
|
||||
readIndexTo vint:anIndex [ anIndex int := theRow ]
|
||||
readIndexTo(ref<int> anIndex) [ theRow readValueTo(anIndex) ]
|
||||
|
||||
writeIndex int:anIndex
|
||||
writeIndex(int anIndex)
|
||||
[
|
||||
if (anIndex <= theRow)
|
||||
[ $owner writeTitle ].
|
||||
[ self writeTitle ].
|
||||
|
||||
while (anIndex > theRow)
|
||||
[ $owner writeLine ]
|
||||
[ self writeLine ]
|
||||
]
|
||||
|
||||
get = $owner.
|
||||
appendIndex(int anIndex)
|
||||
<= writeIndex(theRow value + anIndex).
|
||||
|
||||
readLengthTo(ref<int> retVal) [ retVal value := 7 ]
|
||||
|
||||
get = self.
|
||||
|
||||
set : o [ NotSupportedException new; raise ]
|
||||
}.
|
||||
|
||||
printTitleTo : anOutput
|
||||
|
|
@ -91,7 +96,7 @@ class Calendar
|
|||
|
||||
constructor new : aYear
|
||||
[
|
||||
theYear := aYear int.
|
||||
theYear := aYear.
|
||||
theRowLength := 3.
|
||||
]
|
||||
|
||||
|
|
@ -103,17 +108,16 @@ class Calendar
|
|||
anOutput writeLine; writeLine.
|
||||
|
||||
var aRowCount := 12 / theRowLength.
|
||||
var Months := Array new length:aRowCount; populate(:i)
|
||||
(Array new length:theRowLength;
|
||||
var Months := Array new(aRowCount); populate(:i)
|
||||
(Array new:theRowLength;
|
||||
populate(:j)
|
||||
( CalendarMonthPrinter new year(theYear int) month(i * theRowLength + j + 1))).
|
||||
( CalendarMonthPrinter year:theYear month(i * theRowLength + j + 1))).
|
||||
|
||||
Months forEach(:aRow)
|
||||
[
|
||||
aRow forEach(:aMonth)
|
||||
[
|
||||
aMonth printTitleTo:anOutput.
|
||||
|
||||
anOutput write:" ".
|
||||
].
|
||||
|
||||
|
|
@ -124,7 +128,6 @@ class Calendar
|
|||
aLine forEach(:aPrinter)
|
||||
[
|
||||
aPrinter printTo:anOutput.
|
||||
|
||||
anOutput write:" "
|
||||
].
|
||||
|
||||
|
|
@ -134,7 +137,7 @@ class Calendar
|
|||
]
|
||||
}
|
||||
|
||||
program =
|
||||
public program =
|
||||
[
|
||||
var aCalender := Calendar new(console write:"ENTER THE YEAR:"; readLineTo(Integer new)).
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ $define ISLEAPYEAR IsLeapYear
|
|||
$define JULIAN julian
|
||||
|
||||
PROCEDURE MAIN(A)
|
||||
PRINTCALENDAR(\A$<1$>|1969)
|
||||
PRINTCALENDAR(\A$<1$>|1969)
|
||||
END
|
||||
|
||||
PROCEDURE PRINTCALENDAR(YEAR)
|
||||
|
|
@ -23,7 +23,7 @@ PROCEDURE PRINTCALENDAR(YEAR)
|
|||
WRITES(" ")
|
||||
EVERY I := 1 TO COLS DO {
|
||||
WRITES(CENTER(MONS$<MON+I$>,24))
|
||||
M$<I$> := CREATE CALENDARFORMATWEEK(1969,MON + I)
|
||||
M$<I$> := CREATE CALENDARFORMATWEEK(YEAR,MON + I)
|
||||
$)
|
||||
WRITE()
|
||||
EVERY 1 TO 7 DO $(
|
||||
|
|
@ -34,15 +34,16 @@ PROCEDURE PRINTCALENDAR(YEAR)
|
|||
WRITE()
|
||||
$)
|
||||
$)
|
||||
RETURN
|
||||
END
|
||||
|
||||
PROCEDURE CALENDARFORMATWEEK(YEAR,M)
|
||||
STATIC D
|
||||
INITIAL D := $<31,28,31,30,31,30,31,31,30,31,30,31$>
|
||||
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"
|
||||
EVERY 1 TO (DAY := (JULIAN(M,1,YEAR)+1)%7) DO SUSPEND ""
|
||||
EVERY SUSPEND 1 TO D$<M$> DO DAY +:= 1
|
||||
IF M = 2 & ISLEAPYEAR(YEAR) THEN SUSPEND (DAY +:= 1, 29)
|
||||
EVERY DAY TO (6*7) DO SUSPEND ""
|
||||
EVERY SUSPEND "SU"|"MO"|"TU"|"WE"|"TH"|"FR"|"SA"
|
||||
EVERY 1 TO (DAY := (JULIAN(M,1,YEAR)+1)%7) DO SUSPEND ""
|
||||
EVERY SUSPEND 1 TO D$<M$> DO DAY +:= 1
|
||||
IF M = 2 & ISLEAPYEAR(YEAR) THEN SUSPEND (DAY +:= 1, 29)
|
||||
EVERY DAY TO (6*7) DO SUSPEND ""
|
||||
END
|
||||
|
|
|
|||
|
|
@ -23,3 +23,5 @@ $define LINK link
|
|||
$define IF if
|
||||
$define THEN then
|
||||
$define BY by
|
||||
$define DATETIME datetime
|
||||
$define RETURN return
|
||||
|
|
|
|||
|
|
@ -2,4 +2,4 @@ import subprocess
|
|||
px = subprocess.Popen(['python', '-c', 'import calendar; calendar.prcal(1969)'],
|
||||
stdout=subprocess.PIPE)
|
||||
cal = px.communicate()[0]
|
||||
print cal.upper()
|
||||
print (cal.upper())
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
cal -m 1969 | tr a-z A-Z
|
||||
Loading…
Add table
Add a link
Reference in a new issue