Calendar - for "REAL" programmers: Difference between revisions

Content added Content deleted
(Merge omitted languages at bottom and add Processing)
Line 1,047: Line 1,047:


=={{header|Elena}}==
=={{header|Elena}}==
ELENA 4.1 :
ELENA 5.0 :
<lang elena>import system'text;
<lang elena>import system'text;
import system'routines;
import system'routines;
Line 1,054: Line 1,054:
import extensions'routines;
import extensions'routines;


const MonthNames = new string[]::("JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE","JULY","AUGUST","SEPTEMBER","OCTOBER","NOVEMBER","DECEMBER");
const MonthNames = new string[]{"JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE","JULY","AUGUST","SEPTEMBER","OCTOBER",
"NOVEMBER","DECEMBER"};
const DayNames = new string[]::("MO", "TU", "WE", "TH", "FR", "SA", "SU");
const DayNames = new string[]{"MO", "TU", "WE", "TH", "FR", "SA", "SU"};


class CalendarMonthPrinter
class CalendarMonthPrinter
Line 1,087: Line 1,088:
if (theDate.Month == theMonth)
if (theDate.Month == theMonth)
{
{
theLine.writeCopies(" ",theDate.DayOfWeek == 0 ? 7 : (theDate.DayOfWeek - 1));
var dw := theDate.DayOfWeek;
theLine.writeCopies(" ",theDate.DayOfWeek == 0 ? 6 : (theDate.DayOfWeek - 1));
do
do
{
{
theLine.writePaddingLeft(theDate.Day.Printable, $32, 3);
theLine.writePaddingLeft(theDate.Day.toPrintable(), $32, 3);
theDate := theDate.addDays:1
theDate := theDate.addDays:1
}
}
until:(theDate.Month != theMonth || theDate.DayOfWeek == 1)
until(theDate.Month != theMonth || theDate.DayOfWeek == 1)
};
};
Line 1,105: Line 1,108:
}
}
indexer() = new Indexer:
indexer() = new Indexer
{
{
bool Available = theRow < 7;
bool Available = theRow < 7;


int Index
readIndexTo(ref int retVal) { theRow.readValueTo(ref retVal) }

writeIndex(int index)
{
{
if (index <= theRow)
get() = theRow.Value;
{ self.writeTitle() };
set(int index)
while (index > theRow)
{
{ self.writeLine() }
if (index <= theRow)
{ self.writeTitle() };
while (index > theRow)
{ self.writeLine() }
}
}
}


appendIndex(int index)
appendIndex(int index)
{
<= writeIndex(theRow.Value + index);
this self.Index := theRow.Value + index
}
readLengthTo(ref int retVal) { retVal := 7 }
get int Length() { ^ 7 }


get() = self;
get() = self;
Line 1,156: Line 1,164:
output.writePadding("[SNOOPY]", $32, theRowLength * 25);
output.writePadding("[SNOOPY]", $32, theRowLength * 25);
output.writeLine();
output.writeLine();
output.writePadding(theYear.Printable, $32, theRowLength * 25);
output.writePadding(theYear.toPrintable(), $32, theRowLength * 25);
output.writeLine().writeLine();
output.writeLine().writeLine();