Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 2

Pseudocodeforcalendarprocedures

(fromReingoldandReingoldPascalgorithmsadaptedbyJosefMBreutzmann)

defIsLeapYear(year):
ifyear%400==0or(year%100!=0andyear%4==0):
returntrue
else:
returnfalse
defLastDayOfMonth(month,year):
ifmonth==2:
ifIsLeapYear(year)==1:
return29
else:
return28
elifmonth==4ormonth==6ormonth==9ormonth==11:
return30
else:
return31
defDateIsLegal(month,day,year)
LD=LastDayOfMonth(month,year)
ifyear<1ormonth<1ormonth>12orday<1orday>LD:
returnfalse
else:
returntrue
defDayNumber(month,day,year):
DOY=(month1)*31+day
Ifmonth>2:
DOY=DOY((4*month+23)/10)
ifIsLeapYear(year):
DOY++
returnDOY
defAbsFromNormDate(month,day,year)
DN=DayNumber(month,day,year)
returnDN+365*(year1)+(year1)/4(3*((year1)/100)+3)/4

defNormFromAbsDate(AbsDate)
year=AbsDate/366;
whileAbsFromNormDate(12,31,year)<AbsDate:
year++
month=1
while(AbsFromNormDate(month,LastDayOfMonth(month,year),year)<
AbsDate):
month++
day=AbsDate+3AbsoluteFromNormal(month,3,year)
returnmonth,day,year

ParameterConventionsforcalendarprocedures
Function
IsLeapYear
LastDayOfMonth
DateIsLegal
GetLegalDate

DayNumber
AbsFromNormDate
NormFromAbsDate
ASCIIfromNormDate
(bonuspart)

InputParameter(s)
EAX=year
EAX=year
EBX=month
EAX=year
EBX=month
ECX=day
None

EAX=year
EBX=month
ECX=day
EAX=year
EBX=month
CX=day
EAX=absolutedaynumber
EAX=year
EBX=month
ECX=day
EDXistheoffsettoa10bytestring

OutputParameter(s)
EAX=1ifyearisaleapyear
EAX=0ifyearisNOTaleapyear
EAX=28,29,30or31asappropriate
EAX=1ifthedateislegal
EAX=0ifthedateisillegal
EAX=year
EBX=month
ECX=day
EAX,EBX,ECXformalegaldate
EAXisanintegerintherange1to366
Appropriatefortheinput
EAXistheabsolutedaynumber
EAX=year
EBX=month
ECX=day
EDXwillpointtoastringformattedas
MM/DD/YYYY

Tohelpwithdebugging,herearesomeknown?absolutedates:12/7/1941is708911,10/15/1582is577736,
6/20/1952is712759,2/22/1732is632287,9/11/2001is730739

You might also like