fdoc

functionweekdaypureprivate

pure integer function weekday(y, m, d)

Day of the week of a date: 0 for Sunday.

Arguments

NameTypeIntentAttributesDescription
yintegerin

the year

mintegerin

the month, from 1

dintegerin

the day of the month

Result

NameTypeAttributesDescription
weekdayinteger

Source

Show the code
pure integer function weekday(y, m, d)
    integer, intent(in) :: y    !! the year
    integer, intent(in) :: m    !! the month, from 1
    integer, intent(in) :: d    !! the day of the month
    integer, parameter :: T(12) = [0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4]
    integer :: yy
    yy = merge(y - 1, y, m < 3)
    weekday = mod(yy + yy/4 - yy/100 + yy/400 + T(m) + d, 7)
end function weekday

Graphs

Called by