FNLMath : Utilities : IDYWK
IDYWK
This function computes the day of the week for a given date.
Function Return Value
IDYWK — Function value. (Output)
The value of IDYWK ranges from 1 to 7, where 1 corresponds to Sunday and 7 corresponds to Saturday.
Required Arguments
IDAY — Day of the input date. (Input)
MONTH — Month of the input date. (Input)
IYEAR — Year of the input date. (Input)
1950 would correspond to the year 1950 A.D. and 50 would correspond to year 50 A.D.
FORTRAN 90 Interface
Generic: IDYWK (IDAY, MONTH, IYEAR)
Specific: The specific interface name is IDYWK.
FORTRAN 77 Interface
Single: IDYWK (IDAY, MONTH, IYEAR)
Description
Function IDYWK returns an integer code that specifies the day of week for a given date. Sunday corresponds to 1, Monday corresponds to 2, and so forth.
A negative IYEAR can be used to specify B.C. Input dates in year 0 and for October 5, 1582, through October 14, 1582, inclusive, do not exist; consequently, in these cases, IDYWK issues a terminal error.
Comments
1. Informational error
Type
Code
Description
1
1
The Julian calendar, the first modern calendar, went into use in 45 B.C. No calendar prior to 45 B.C. was as universally used nor as accurate as the Julian. Therefore, it is assumed that the Julian calendar was in use prior to 45 B.C.
2. The beginning of the Gregorian calendar was the first day after October 4, 1582, which became October 15, 1582. Prior to that, the Julian calendar was in use. Function IDYWK makes the proper adjustment for the change in calendars.
Example
The following example uses IDYWK to return the day of the week for February 24, 1963.
 
USE IDYWK_INT
USE UMACH_INT
 
IMPLICIT NONE
INTEGER IDAY, IYEAR, MONTH, NOUT
!
IDAY = 24
MONTH = 2
IYEAR = 1963
CALL UMACH (2, NOUT)
WRITE (NOUT,*) 'IDYWK (index for day of week) = ', &
IDYWK(IDAY,MONTH,IYEAR)
END
Output
 
IDYWK (index for day of week) = 1