functionweekdaypureprivate
pure integer function weekday(y, m, d)
Day of the week of a date: 0 for Sunday.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| y | integer | in | the year | |
| m | integer | in | the month, from 1 | |
| d | integer | in | the day of the month |
Result
| Name | Type | Attributes | Description |
|---|---|---|---|
| weekday | integer |
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