Module dc_date

module dc_date

        ! Uses
    use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
    use dc_types, only: DP, STRING
    use dc_present, only: present_and_not_empty
    use dc_string, only: CPrintf

        ! Interfaces
    private interface operator(+)
    private interface operator(-)
    private interface operator(*)
    private interface operator(/)
    private interface mod
    public interface TimeNow
    private interface assignment(=)
    private interface toString
    private interface Eval
    private interface DiffTime
    private interface DateTime

        ! Subroutines and functions
    private subroutine dcdate_normalize (day, sec)
    private type (DC_DATETIME) function dcdate_add_ft (diff, time)
    private type (DC_DATETIME) function dcdate_add_tf (time, diff)
    private type (DC_DIFFTIME) function dcdate_add_ff (diff1, diff2)
    private type (DC_DIFFTIME) function dcdate_sub_tt (time1, time2)
    private type (DC_DATETIME) function dcdate_sub_tf (time, diff)
    private type (DC_DIFFTIME) function dcdate_mul_if (factor, diff)
    private type (DC_DIFFTIME) function dcdate_mul_rf (factor, diff)
    private type (DC_DIFFTIME) function dcdate_mul_df (factor, diff)
    private type (DC_DIFFTIME) function dcdate_mul_fi (diff, factor)
    private type (DC_DIFFTIME) function dcdate_mul_fr (diff, factor)
    private type (DC_DIFFTIME) function dcdate_mul_fd (diff, factor)
    private type (DC_DIFFTIME) function dcdate_div_fi (diff, denominator)
    private type (DC_DIFFTIME) function dcdate_div_fr (diff, denominator)
    private type (DC_DIFFTIME) function dcdate_div_fd (diff, denominator)
    private real (kind=DP) function dcdate_div_ff (diff1, diff2)
    private type (DC_DIFFTIME) function dcdate_mod_ff (diff1, diff2)
    private subroutine DCDateDiffEval (diff, year, mon, day, hour, min, sec)
    private function DCTimeNow (fmt) result (result)

end module dc_date

Description of Interfaces

operator(+)

private interface operator(+)
    module procedure dcdate_add_ft
    module procedure dcdate_add_tf
    module procedure dcdate_add_ff
end interface operator(+)

operator(-)

private interface operator(-)
    module procedure dcdate_sub_tt
    module procedure dcdate_sub_tf
end interface operator(-)

operator(*)

private interface operator(*)
    module procedure dcdate_mul_if
    module procedure dcdate_mul_rf
    module procedure dcdate_mul_df
    module procedure dcdate_mul_fi
    module procedure dcdate_mul_fr
    module procedure dcdate_mul_fd
end interface operator(*)

operator(/)

private interface operator(/)
    module procedure dcdate_div_fi
    module procedure dcdate_div_fr
    module procedure dcdate_div_fd
    module procedure dcdate_div_ff
end interface operator(/)

mod

private interface mod
    module procedure dcdate_mod_ff
end interface mod

TimeNow

public interface TimeNow
    module procedure DCTimeNow
end interface TimeNow

assignment(=)

private interface assignment(=)
    subroutine DCDateLetFC (diff, string)
        type (DC_DIFFTIME), intent(out) :: diff
        character (len=*), intent(in) :: string
    end subroutine DCDateLetFC
    subroutine DCDateLetFS (diff, string)
        type (DC_DIFFTIME), intent(out) :: diff
        type (VSTRING), intent(in) :: string
    end subroutine DCDateLetFS
    subroutine DCDateLetTC (time, string)
        type (DC_DATETIME), intent(out) :: time
        character (len=*), intent(in) :: string
    end subroutine DCDateLetTC
    subroutine DCDateLetTS (time, string)
        type (DC_DATETIME), intent(out) :: time
        type (VSTRING), intent(in) :: string
    end subroutine DCDateLetTS
end interface assignment(=)

toString

private interface toString
    type (VSTRING) function DCDateDiffToString (diff)
        type (DC_DIFFTIME), intent(in) :: diff
    end function DCDateDiffToString
    type (VSTRING) function DCDateTimeToString (time)
        type (DC_DATETIME), intent(in) :: time
    end function DCDateTimeToString
end interface toString

Eval

private interface Eval
    subroutine DCDateTimeEval (time, mon, day, sec)
        type (DC_DATETIME), intent(in) :: time
        integer, intent(out) :: mon
        integer, intent(out) :: day
        real (kind=DP), intent(out) :: sec
    end subroutine DCDateTimeEval
    subroutine DCDateTimeEval2 (time, year, mon, day, hour, min, sec)
        type (DC_DATETIME), intent(in) :: time
        integer, optional, intent(out) :: year
        integer, optional, intent(out) :: mon
        integer, optional, intent(out) :: day
        integer, optional, intent(out) :: hour
        integer, optional, intent(out) :: min
        integer, optional, intent(out) :: sec
    end subroutine DCDateTimeEval2
    module procedure DCDateDiffEval
end interface Eval

DiffTime

private interface DiffTime
    type (DC_DIFFTIME) function DCDiffTime (year, mon, day, hour, min, sec)
        integer, optional, intent(in) :: year
        integer, optional, intent(in) :: mon
        integer, optional, intent(in) :: day
        integer, optional, intent(in) :: hour
        integer, optional, intent(in) :: min
        integer, optional, intent(in) :: sec
    end function DCDiffTime
end interface DiffTime

DateTime

private interface DateTime
    type (DC_DATETIME) function DCDateTime (mon, day, sec)
        integer, intent(in) :: mon
        integer, intent(in) :: day
        real (kind=DP), intent(in) :: sec
    end function DCDateTime
    type (DC_DATETIME) function DCDateTime2 (year, mon, day, hour, min, sec)
        integer, optional, intent(in) :: year
        integer, optional, intent(in) :: mon
        integer, optional, intent(in) :: day
        integer, optional, intent(in) :: hour
        integer, optional, intent(in) :: min
        integer, optional, intent(in) :: sec
    end function DCDateTime2
end interface DateTime

Description of Subroutines and Functions

dcdate_normalize

private subroutine dcdate_normalize (day, sec)
    integer, intent(inout) :: day
    real (kind=DP), intent(inout) :: sec
end subroutine dcdate_normalize

dcdate_add_ft

private function dcdate_add_ft (diff, time) result (result)
    type (DC_DIFFTIME), intent(in) :: diff
    type (DC_DATETIME), intent(in) :: time
    type (DC_DATETIME) :: result
end function dcdate_add_ft

dcdate_add_tf

private function dcdate_add_tf (time, diff) result (result)
    type (DC_DATETIME), intent(in) :: time
    type (DC_DIFFTIME), intent(in) :: diff
    type (DC_DATETIME) :: result
end function dcdate_add_tf

dcdate_add_ff

private function dcdate_add_ff (diff1, diff2) result (result)
    type (DC_DIFFTIME), intent(in) :: diff1
    type (DC_DIFFTIME), intent(in) :: diff2
    type (DC_DIFFTIME) :: result
    ! Calls: dcdate_normalize
end function dcdate_add_ff

dcdate_sub_tt

private function dcdate_sub_tt (time1, time2) result (result)
    type (DC_DATETIME), intent(in) :: time1
    type (DC_DATETIME), intent(in) :: time2
    type (DC_DIFFTIME) :: result
    ! Calls: dcdate_normalize
end function dcdate_sub_tt

dcdate_sub_tf

private function dcdate_sub_tf (time, diff) result (result)
    type (DC_DATETIME), intent(in) :: time
    type (DC_DIFFTIME), intent(in) :: diff
    type (DC_DATETIME) :: result
end function dcdate_sub_tf

dcdate_mul_if

private function dcdate_mul_if (factor, diff) result (result)
    integer, intent(in) :: factor
    type (DC_DIFFTIME), intent(in) :: diff
    type (DC_DIFFTIME) :: result
    ! Calls: dcdate_normalize
end function dcdate_mul_if

dcdate_mul_rf

private function dcdate_mul_rf (factor, diff) result (result)
    real, intent(in) :: factor
    type (DC_DIFFTIME), intent(in) :: diff
    type (DC_DIFFTIME) :: result
    ! Calls: dcdate_normalize
end function dcdate_mul_rf

dcdate_mul_df

private function dcdate_mul_df (factor, diff) result (result)
    real (kind=DP), intent(in) :: factor
    type (DC_DIFFTIME), intent(in) :: diff
    type (DC_DIFFTIME) :: result
    ! Calls: dcdate_normalize
end function dcdate_mul_df

dcdate_mul_fi

private function dcdate_mul_fi (diff, factor) result (result)
    type (DC_DIFFTIME), intent(in) :: diff
    integer, intent(in) :: factor
    type (DC_DIFFTIME) :: result
    ! Calls: dcdate_normalize
end function dcdate_mul_fi

dcdate_mul_fr

private function dcdate_mul_fr (diff, factor) result (result)
    type (DC_DIFFTIME), intent(in) :: diff
    real, intent(in) :: factor
    type (DC_DIFFTIME) :: result
    ! Calls: dcdate_normalize
end function dcdate_mul_fr

dcdate_mul_fd

private function dcdate_mul_fd (diff, factor) result (result)
    type (DC_DIFFTIME), intent(in) :: diff
    real (kind=DP), intent(in) :: factor
    type (DC_DIFFTIME) :: result
    ! Calls: dcdate_normalize
end function dcdate_mul_fd

dcdate_div_fi

private function dcdate_div_fi (diff, denominator) result (result)
    type (DC_DIFFTIME), intent(in) :: diff
    integer, intent(in) :: denominator
    type (DC_DIFFTIME) :: result
end function dcdate_div_fi

dcdate_div_fr

private function dcdate_div_fr (diff, denominator) result (result)
    type (DC_DIFFTIME), intent(in) :: diff
    real, intent(in) :: denominator
    type (DC_DIFFTIME) :: result
    ! Calls: dcdate_normalize
end function dcdate_div_fr

dcdate_div_fd

private function dcdate_div_fd (diff, denominator) result (result)
    type (DC_DIFFTIME), intent(in) :: diff
    real (kind=DP), intent(in) :: denominator
    type (DC_DIFFTIME) :: result
    ! Calls: dcdate_normalize
end function dcdate_div_fd

dcdate_div_ff

private function dcdate_div_ff (diff1, diff2) result (result)
    type (DC_DIFFTIME), intent(in) :: diff1
    type (DC_DIFFTIME), intent(in) :: diff2
    real (kind=DP) :: result
end function dcdate_div_ff

dcdate_mod_ff

private function dcdate_mod_ff (diff1, diff2) result (result)
    type (DC_DIFFTIME), intent(in) :: diff1
    type (DC_DIFFTIME), intent(in) :: diff2
    type (DC_DIFFTIME) :: result
    ! Calls: dcdate_normalize
end function dcdate_mod_ff

DCDateDiffEval

private subroutine DCDateDiffEval (diff, year, mon, day, hour, min, sec)
    type (DC_DIFFTIME), intent(in) :: diff
    integer, optional, intent(out) :: year
    integer, optional, intent(out) :: mon
    integer, optional, intent(out) :: day
    integer, optional, intent(out) :: hour
    integer, optional, intent(out) :: min
    integer, optional, intent(out) :: sec
end subroutine DCDateDiffEval

DCTimeNow

private function DCTimeNow (fmt) result (result)
    character (len=*), optional, intent(in) :: fmt
    character (len=STRING) :: result
    ! Calls: date_and_time
end function DCTimeNow