do forever
say 'Enter the date in the format dd.mm.yyyy (<return> to exit):'
PULL thisDate
if thisDate = '' then
leave
say 'The day of the week for the ' || thisDate ||
' is: ' || dayOfTheWeek( thisDate )
end
exit
DayOfTheWeek: PROCEDURE
signal on syntax name DayOfTheWeekError
sep = '.'
parse arg dd (sep) mm (sep) year
days = "Sunday Monday Tuesday Wednesday Thursday Friday Saturday"
magic = 6 2 3 6 1 4 6 2 5 0 3 5
parse var year cent +2 yr
leap = year // 4 = 0 & (yr\=0 | cent//4=0)
dow=yr + yr%4 + (6-2*(cent//4)) + word(magic,mm) + dd
if mm < 3 & \leap then
dow=dow+1
dow = dow // 7
return word(days,dow+1)
DayOfTheWeekError:
return 'ERROR'