/*REXX*/
/* sample code to determine what day of the week a date falls on      */
/*                                                                    */
/* Source: Found in a message in a public news group                  */
/*                                                                    */
  do forever
    say 'Enter the date in the format dd.mm.yyyy (<return> to exit):'
    PULL thisDate
    /*  thisDate = strip( translate( lineIn() ) )  */
    if thisDate = '' then
      leave
    say 'The day of the week for the ' || thisDate || ,
        ' is: ' || dayOfTheWeek( thisDate )
  end /* do forever */
exit
/* ------------------------------------------------------------------ */
/* function: Determine what day of the week a date falls on           */
/*                                                                    */
/* call:     dayOfTheWeek = DayOfTheWeek( thisDate )                  */
/*                                                                    */
/* where:    thisDate - date in the format dd.mm.yyyy                 */
/*                                                                    */
/* returns:  the name of the day or ERROR in case of an error         */
/*                                                                    */
/*                                                                    */
DayOfTheWeek: PROCEDURE
                    /* install a local error handler                  */
  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'