timedelta Function

public pure function timedelta(days, hours, minutes, seconds, milliseconds) result(td)

Create a normalized timedelta_type from mixed units.

Arguments

Type IntentOptional Attributes Name
integer, intent(in), optional :: days
integer, intent(in), optional :: hours
integer, intent(in), optional :: minutes
integer, intent(in), optional :: seconds
integer, intent(in), optional :: milliseconds

Return Value type(timedelta_type)


Source Code

    pure function timedelta(days, hours, minutes, seconds, &
                            milliseconds) result(td)
        !! version: experimental
        !!
        !! Create a normalized timedelta_type from mixed units.
        integer, intent(in), optional :: days, hours, minutes
        integer, intent(in), optional :: seconds, milliseconds
        type(timedelta_type) :: td
        integer(int64) :: total_ms
        total_ms = 0_int64
        if (present(days)) &
            total_ms = total_ms &
                     + int(days, int64) * MS_PER_DAY
        if (present(hours)) &
            total_ms = total_ms &
                     + int(hours, int64) * MS_PER_HOUR
        if (present(minutes)) &
            total_ms = total_ms &
                     + int(minutes, int64) * MS_PER_MIN
        if (present(seconds)) &
            total_ms = total_ms &
                     + int(seconds, int64) * MS_PER_SEC
        if (present(milliseconds)) &
            total_ms = total_ms + int(milliseconds, int64)
        td = ms_to_td(total_ms)
    end function timedelta