fdoc

functionday_of_yearpureprivate

pure integer function day_of_year(y, m, d)

Day of the year of a date, from 1.

Arguments

NameTypeIntentAttributesDescription
yintegerin

the year

mintegerin

the month, from 1

dintegerin

the day of the month

Result

NameTypeAttributesDescription
day_of_yearinteger

Source

Show the code
pure integer function day_of_year(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 :: BEFORE(12) = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334]
    logical :: leap
    leap = mod(y, 4) == 0 .and. (mod(y, 100) /= 0 .or. mod(y, 400) == 0)
    day_of_year = BEFORE(m) + d + merge(1, 0, leap .and. m > 2)
end function day_of_year

Graphs

Called by