!= dc_date ã‚ˆã‚Šæä¾›ã•ã‚Œã‚‹æ‰‹ç¶šã®å¼•ç”¨ä»•æ§˜å®£è¨€
!= Interface of procedures provided from dc_date
!
! Authors::   Yasuhiro MORIKAWA, Eizi TOYODA
! Version::   $Id: dc_date_generic.f90,v 1.3 2009-06-01 15:17:23 morikawa Exp $
! Tag Name::  $Name:  $
! Copyright:: Copyright (C) GFD Dennou Club, 2000-2005. All rights reserved.
! License::   See COPYRIGHT[link:../../COPYRIGHT]

module dc_date_generic
  != dc_date ã‚ˆã‚Šæä¾›ã•ã‚Œã‚‹æ‰‹ç¶šã®å¼•ç”¨ä»•æ§˜å®£è¨€
  != Interface of procedures provided from dc_date
  !
  ! ãƒ¢ã‚¸ãƒ¥ãƒ¼ãƒ«ã®æ¦‚è¦ã«ã¤ã„ã¦ã¯, dc_date
  ! ã‚’å‚ç…§ãã ã•ã„.
  !
  ! See "dc_date" for brief of this module.
  !
  !== Procedures List
  !
  ! ä»¥ä¸‹ã®æ‰‹ç¶šãã¯æ§‹é€ åž‹ dc_date_types#DC_DATETIME ã¾ãŸã¯
  ! dc_date_types#DC_DIFFTIME å¤‰æ•° (æ—¥æ™‚, æ™‚åˆ»ã«é–¢ã™ã‚‹æƒ…å ±ã‚’æ ¼ç´)
  ! ã‚’å¯¾è±¡ã¨ã—ã¾ã™.
  !
  ! DCDateTimeCreate     :: dc_date_types#DC_DATETIME åž‹å¤‰æ•°ã®åˆæœŸè¨å®š
  ! DCDiffTimeCreate     :: dc_date_types#DC_DIFFTIME åž‹å¤‰æ•°ã®åˆæœŸè¨å®š
  !
  ! #assignment(=)       :: dc_date_types#DC_DATETIME åž‹å¤‰æ•°ãŠã‚ˆã³
  !                         dc_date_types#DC_DIFFTIME åž‹å¤‰æ•°ã®åˆæœŸè¨å®š
  !
  ! Eval                 :: æ—¥æ™‚, æ™‚åˆ»æƒ…å ±ã‚’å€‹åˆ¥ã«å–å¾—
  !
  ! toChar               :: æ—¥æ™‚, æ™‚åˆ»æƒ…å ±ã‚’æ–‡å—åž‹å¤‰æ•°ã¸å¤‰æ›
  !
  ! EvalDay     :: æ—¥æ•° (å®Ÿæ•°åž‹) ã«æ›ç®—ã—ã¦å–å¾—
  ! EvalHour    :: æ™‚é–“ (å®Ÿæ•°åž‹) ã«æ›ç®—ã—ã¦å–å¾—
  ! EvalMin     :: åˆ† (å®Ÿæ•°åž‹) ã«æ›ç®—ã—ã¦å–å¾—
  ! EvalSec     :: ç§’ (å®Ÿæ•°åž‹) ã«æ›ç®—ã—ã¦å–å¾—
  ! EvalNondim  :: ç„¡æ¬¡å…ƒæ™‚é–“ (å®Ÿæ•°åž‹) ã«æ›ç®—ã—ã¦å–å¾—
  ! EvalByUnit  :: å˜ä½ã‚’æŒ‡å®šã—, æ—¥, æ™‚, åˆ†, ç§’ã®ã„ã¥ã‚Œã‹ (å®Ÿæ•°åž‹)
  !                ã«æ›ç®—ã—ã¦å–å¾—
  !
  ! #operator(+)  :: åŠ ç®— (dc_date_types#DC_DATETIME åž‹ ãŠã‚ˆã³
  !                  dc_date_types#DC_DIFFTIME åž‹ åŒå£«)
  ! #operator(-)  :: æ¸›ç®— (dc_date_types#DC_DATETIME åž‹ ãŠã‚ˆã³
  !                  dc_date_types#DC_DIFFTIME åž‹ åŒå£«)
  ! #operator(*)  :: ä¹—ç®— (dc_date_types#DC_DIFFTIME åž‹ã¨æ•°å€¤åž‹)
  ! #operator(/)  :: é™¤ç®— (dc_date_types#DC_DIFFTIME åž‹ã¨æ•°å€¤åž‹)
  ! mod           :: ä½™ã‚Š (dc_date_types#DC_DIFFTIME åž‹åŒå£«)
  ! #operator(==) :: æ¯”è¼ƒ (dc_date_types#DC_DATETIME åž‹åŒå£«)
  ! #operator(>)  :: æ¯”è¼ƒ (dc_date_types#DC_DATETIME åž‹åŒå£«)
  ! #operator(>=) :: æ¯”è¼ƒ (dc_date_types#DC_DATETIME åž‹åŒå£«)
  ! #operator(<)  :: æ¯”è¼ƒ (dc_date_types#DC_DATETIME åž‹åŒå£«)
  ! #operator(<=) :: æ¯”è¼ƒ (dc_date_types#DC_DATETIME åž‹åŒå£«)
  ! max           :: å¤§ãã„å€¤ã‚’è¿”ã™
  ! min           :: å°ã•ã„å€¤ã‚’è¿”ã™
  !
  ! SetZone       :: ã‚¿ã‚¤ãƒ ã‚¾ãƒ¼ãƒ³ã‚’å¤‰æ›´
  !
  ! DCDateTimePutLine    :: dc_date_types#DC_DATETIME åž‹å¤‰æ•°ã«æ ¼ç´ã•ã‚Œã¦ã„ã‚‹
  !                         æ—¥æ™‚, æ™‚åˆ»æƒ…å ±ã®å°å—
  ! DCDiffTimePutLine    :: dc_date_types#DC_DIFFTIME åž‹å¤‰æ•°ã«æ ¼ç´ã•ã‚Œã¦ã„ã‚‹
  !                         æ—¥æ™‚, æ™‚åˆ»æƒ…å ±ã®å°å—
  !
  !
  ! ä»¥ä¸‹ã®æ‰‹ç¶šãã¯ dc_date_types å†…éƒ¨ã®å¤‰æ•°ã‚’å¤‰æ›´ã—ã¾ã™.
  !
  ! SetCaltype  :: æš¦æ³•ã®ãƒ‡ãƒ•ã‚©ãƒ«ãƒˆã‚’å¤‰æ›´
  ! SetSecOfDay :: 1 æ—¥ã®ç§’æ•°ã®ãƒ‡ãƒ•ã‚©ãƒ«ãƒˆã‚’å¤‰æ›´
  !
  ! ãã®ä»–ã®æ‰‹ç¶šã
  !
  ! ValidCaltype   :: æš¦æ³•ãŒæœ‰åŠ¹ãªã‚‚ã®ã‹ã‚’ãƒã‚§ãƒƒã‚¯
  ! ValidZone      :: ã‚¿ã‚¤ãƒ ã‚¾ãƒ¼ãƒ³ã¨ã—ã¦æœ‰åŠ¹åŒ–ã‚’ãƒã‚§ãƒƒã‚¯
  ! ZoneToDiff     :: ã‚¿ã‚¤ãƒ ã‚¾ãƒ¼ãƒ³ã‚’ dc_date_types#DC_DIFFTIME å¤‰æ•°ã¸ã¨å¤‰æ›
  ! ParseTimeUnits :: æ™‚é–“ã®å˜ä½ã‚’è§£æžã—, å˜ä½ã®ã‚·ãƒ³ãƒœãƒ«ã‚’è¿”ã—ã¾ã™.
  !
  !== Usage
  !
  !=== ç¾åœ¨æ™‚åˆ»ã®è¡¨ç¤º
  !
  ! dc_date_types#DC_DATETIME åž‹ã®å¤‰æ•°ã«ã‚µãƒ–ãƒ«ãƒ¼ãƒãƒ³ DCDateTimeCreate
  ! ã‚’ç”¨ã„ã‚‹ã¨, æ™‚åˆ»ãŒè¨å®šã•ã‚Œã¾ã™.
  ! ä¸‹è¨˜ã®ã‚ˆã†ã«ç‰¹ã«å¹´æœˆæ—¥ã‚’æŒ‡å®šã—ãªã„ã¨ç¾åœ¨æ™‚åˆ»ãŒè¨å®šã•ã‚Œã¾ã™.
  ! è¨å®šã•ã‚ŒãŸæ™‚åˆ»ã¯ toChar ã«ã‚ˆã£ã¦æ–‡å—åž‹å¤‰æ•°ã¸ã¨å¤‰æ›ã§ãã¾ã™.
  ! ã‚µãƒ–ãƒ«ãƒ¼ãƒãƒ³ Printf ã«é–¢ã—ã¦ã¯ dc_string#Printf ã‚’å‚ç…§ãã ã•ã„.
  !
  !     program dc_date_sapmle1
  !       use dc_string, only: Printf
  !       use dc_date, only: DC_DATETIME, DCDateTimeCreate, toChar
  !       implicit none
  !       type(DC_DATETIME) :: time
  !
  !       call DCDateTimeCreate( time = time ) ! (out)
  !       call Printf( fmt = 'current date and time is %c', c1 = trim( toChar(time) ) )
  !     end program dc_date_sapmle1
  !
  !=== æ—¥æ™‚, æ™‚åˆ»æƒ…å ±ã®åŠ ç®—
  !
  ! dc_date_types#DC_DIFFTIME åž‹ã®å¤‰æ•°ã¯æ—¥æ™‚å·®ã‚’è¡¨ç¾ã—ã¾ã™. ä¸‹è¨˜ã®ä¾‹ã§ã¯,
  ! æ—¥æ™‚å·®ã‚’è¡¨ç¾ã™ã‚‹ãŸã‚ã®å¤‰æ•°ã¨ã—ã¦ *diff*
  ! ã‚’ç”¨æ„ã—, ã‚µãƒ–ãƒ«ãƒ¼ãƒãƒ³ Create ã«ã‚ˆã£ã¦ 25 æ—¥ + 12 æ™‚é–“ + 50 åˆ†ã®æ—¥æ™‚å·®
  ! ã‚’è¨å®šã—ã¦ã„ã¾ã™. dc_date_types#DC_DATETIME åž‹ã®å¤‰æ•° *time_before* ã¨ *diff* ã¨ã‚’
  ! #operator(+) ã«ã‚ˆã£ã¦åŠ ç®—ã™ã‚‹ã“ã¨ã§ *time_before* ã‹ã‚‰
  ! 25 æ—¥ + 12 æ™‚é–“ + 50 åˆ†ã‚’é€²ã‚ãŸæ—¥æ™‚ *time_after* ã‚’å–å¾—ã—ã¦ã„ã¾ã™.
  !
  !     program dc_date_sapmle2
  !       use dc_types, only: DP
  !       use dc_string, only: Printf
  !       use dc_date, only: DC_DATETIME, DC_DIFFTIME, &
  !         & DCDateTimeCreate, DCDiffTimeCreate, toChar, operator(+)
  !       implicit none
  !       type(DC_DATETIME) :: time_before, time_after
  !       type(DC_DIFFTIME) :: diff
  !
  !       call DCDateTimeCreate( time = time_before, & ! (out)
  !         & year = 2006, mon = 6,  day = 10, &       ! (in)
  !         & hour = 14,   min = 15, sec = 0.0_DP )    ! (in)
  !       call DCDiffTimeCreate( diff = diff, &        ! (out)
  !         & day = 25, hour = 12, min = 50)           ! (in)
  !
  !       time_after = time_before + diff
  !
  !       call Printf( fmt = '%c + %c = %c', &
  !         & c1 = trim( toChar(time_before) ), c2 = trim( toChar(diff) ), &
  !         & c3 = trim( toChar(time_after) ) )
  !     end program dc_date_sapmle2
  !
  !
  !=== æ™‚é–“ç©åˆ†ã®ãƒ«ãƒ¼ãƒ—ã¸ã®å¿œç”¨
  !
  ! ä»¥ä¸‹ã¯ dA/dt = - Î±A (åˆæœŸå€¤ 1, Î±=0.0001) ã‚’ t = 12 (æ™‚é–“)
  ! ã¾ã§è§£ããƒ—ãƒã‚°ãƒ©ãƒ ã®ä¾‹ã§ã™. æ™‚é–“ç©åˆ†ã«ã¯å‰é€²å·®åˆ†ã‚’ç”¨ã„ã¦ã„ã¾ã™.
  ! Î”t, ãƒ‡ãƒ¼ã‚¿ã®å‡ºåŠ›é–“éš”, è¨ˆç®—æ™‚é–“ã« dc_date_types#DC_DIFFTIME ã‚’ç”¨ã„ã‚‹ã“ã¨ã§,
  ! ãƒ«ãƒ¼ãƒ—ã®çµ‚äº†å‡¦ç†ã‚„
  ! ãƒ‡ãƒ¼ã‚¿å‡ºåŠ›ã®éš›ã®æ™‚åˆ»ã®æ¯”è¼ƒãŒå®¹æ˜“ã¨ãªã‚Šã¾ã™.
  !
  !     program dc_date_sapmle3
  !       use dc_types, only: DP
  !       use dc_date, only: DC_DIFFTIME, &
  !         & DCDiffTimeCreate, EvalSec, EvalByUnit, mod, &
  !         & operator(*), operator(==), operator(>)
  !       implicit none
  !       real(DP)                :: func_a = 1.0d0    ! é–¢æ•° A ã®åˆæœŸå€¤
  !       real(DP), parameter     :: alph   = 0.0001d0 ! ä¿‚æ•° Î±
  !       character(*), parameter :: out_unit = 'hour' ! å‡ºåŠ›ã•ã‚Œã‚‹æ™‚åˆ»ã®å˜ä½
  !       type(DC_DIFFTIME):: DelTimef, intervalf, calctimef
  !       integer :: i
  !     continue
  !       call DCDiffTimeCreate( &            !       Î”t = 5.0 (ç§’)
  !         & diff = DelTimef, &              ! (out)
  !         & value = 5.0_DP, unit = 'sec')   ! (in)
  !       call DCDiffTimeCreate( &            !       ãƒ‡ãƒ¼ã‚¿å‡ºåŠ›é–“éš” = 1.0 (åˆ†)
  !         & diff = intervalf, &             ! (out)
  !         & value = 1.0_DP, unit = 'min')   ! (in)
  !       call DCDiffTimeCreate( &            !       è¨ˆç®—æ™‚é–“ = 12.0 (æ™‚é–“)
  !         & diff = calctimef, &             ! (out)
  !         & value = 12.0_DP, unit = 'hour') ! (in)
  !
  !       open( 10, file='dc_date_sample.dat' )
  !       write(10,'(A,A,A)') '#  ', out_unit, '                value'
  !
  !       i = 1
  !       do
  !         if (DelTimef * i > calctimef) exit    ! è¨ˆç®—æ™‚é–“ã‚’éŽãŽãŸã‚‰çµ‚äº†
  !
  !         !---------------------------------------------
  !         ! A_(n+1) = (1 - Î±Î”t) * A_(n)
  !         !---------------------------------------------
  !         func_a = (1.0 - alph * EvalSec(DelTimef)) * func_a
  !
  !         !---------------------------------------------
  !         ! intervalf (1 åˆ†) æ¯Žã«ãƒ‡ãƒ¼ã‚¿ã‚’å‡ºåŠ›
  !         !---------------------------------------------
  !         if (mod(DelTimef * i, intervalf) == 0) then
  !           write(10,*) ' ', EvalByUnit( DelTimef * i, out_unit ), func_a
  !         end if
  !         i = i + 1
  !       end do
  !     end program dc_date_sapmle3
  !
  !

  use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
  use dc_types, only: DP, STRING, TOKEN
  use dc_present, only: present_and_not_empty

  implicit none

  private
  public:: DCDateTimeCreate, DCDiffTimeCreate
  public:: DCDateTimePutLine, DCDiffTimePutLine
  public:: Eval
  public:: SetCaltype, SetZone, SetSecOfDay
  public:: ValidCaltype, ValidZone, ZoneToDiff, ParseTimeUnits

  public:: assignment(=)
  public:: mod, operator(/), operator(-), operator(+), operator(*)
  public:: operator(<), operator(>), operator(>=), operator(<=)
  public:: operator(==), max, min
  public:: toChar, toCharCal
  public:: EvalDay, EvalHour, EvalMin, EvalSec, EvalNondim, EvalByUnit
  public:: EvalSclSec

  public:: Create, PutLine
                    ! å¾Œæ–¹äº’æ›ç”¨
                    ! For backward compatibility

  interface DCDateTimeCreate
    subroutine DCDateTimeCreate1(time, &
      & year, mon, day, hour, min, sec, &
      & zone, zone_hour, zone_min, caltype, caltype_str, day_seconds, &
      & sclyear, sclmon, sclday, sclsec, err) !:doc-priority 40:
      use dc_types, only: DP
      use dc_date_types, only: DC_DATETIME
      use dc_scaledsec, only: DC_SCALED_SEC
      type(DC_DATETIME), intent(out):: time
      integer, intent(in), optional:: year, mon, day, hour, min
      real(DP),intent(in), optional:: sec, day_seconds
      character(*), intent(in), optional :: zone
      integer, intent(in), optional :: zone_hour
      integer, intent(in), optional :: zone_min
      integer, intent(in), optional:: caltype
      character(*), intent(in), optional:: caltype_str
      type(DC_SCALED_SEC), intent(in), optional:: sclyear, sclmon, sclday, sclsec
      logical, intent(out), optional:: err
    end subroutine DCDateTimeCreate1
  end interface

  interface DCDiffTimeCreate
    subroutine DCDiffTimeCreate1(diff, &
      & year, mon, day, hour, min, sec, day_seconds, nondim, &
      & sclyear, sclmon, sclday, sclsec ) !:doc-priority 60:
      use dc_types, only: DP
      use dc_date_types, only: DC_DIFFTIME
      use dc_scaledsec, only: DC_SCALED_SEC
      type(DC_DIFFTIME), intent(out) :: diff
      integer, intent(in), optional:: year, mon, day, hour, min
      real(DP),intent(in), optional:: sec, day_seconds, nondim
      type(DC_SCALED_SEC), intent(in), optional:: sclyear, sclmon, sclday, sclsec
    end subroutine DCDiffTimeCreate1

    subroutine DCDiffTimeCreate2D(diff, value, unit, unit_symbol, err) !:doc-priority 70:
      use dc_types, only: DP
      use dc_date_types, only: DC_DIFFTIME
      type(DC_DIFFTIME), intent(out) :: diff
      real(DP), intent(in) :: value
      character(*), intent(in) :: unit
      integer, intent(in), optional :: unit_symbol
      logical, intent(out), optional :: err
    end subroutine DCDiffTimeCreate2D

    subroutine DCDiffTimeCreate2R(diff, value, unit, unit_symbol, err) !:doc-priority 80:
      use dc_date_types, only: DC_DIFFTIME
      type(DC_DIFFTIME), intent(out) :: diff
      real, intent(in) :: value
      character(*), intent(in) :: unit
      integer, intent(in), optional :: unit_symbol
      logical, intent(out), optional :: err
    end subroutine DCDiffTimeCreate2R

    subroutine DCDiffTimeCreate2I(diff, value, unit, unit_symbol, err) !:doc-priority 90:
      use dc_date_types, only: DC_DIFFTIME
      type(DC_DIFFTIME), intent(out) :: diff
      integer, intent(in) :: value
      character(*), intent(in) :: unit
      integer, intent(in), optional :: unit_symbol
      logical, intent(out), optional :: err
    end subroutine DCDiffTimeCreate2I

  end interface

  interface DCDateTimePutLine
    subroutine DCDateTimePutLine(time, unit, indent)
      use dc_date_types, only: DC_DATETIME
      type(DC_DATETIME), intent(in) :: time
      integer, intent(in), optional :: unit
      character(*), intent(in), optional:: indent
    end subroutine DCDateTimePutLine
  end interface

  interface DCDiffTimePutLine
    subroutine DCDiffTimePutLine(diff, unit, indent)
      use dc_date_types, only: DC_DIFFTIME
      type(DC_DIFFTIME), intent(in) :: diff
      integer, intent(in), optional :: unit
      character(*), intent(in), optional:: indent
    end subroutine DCDiffTimePutLine
  end interface

  interface assignment(=)

    subroutine DCDateTimeCreateI(time, sec) !:doc-priority 20:
      use dc_date_types, only: DC_DATETIME
      type(DC_DATETIME), intent(out):: time
      integer, intent(in):: sec
    end subroutine DCDateTimeCreateI

    subroutine DCDateTimeCreateR(time, sec) !:doc-priority 30:
      use dc_date_types, only: DC_DATETIME
      type(DC_DATETIME), intent(out):: time
      real, intent(in):: sec
    end subroutine DCDateTimeCreateR

    subroutine DCDateTimeCreateD(time, sec) !:doc-priority 40:
      use dc_types, only: DP
      use dc_date_types, only: DC_DATETIME
      type(DC_DATETIME), intent(out):: time
      real(DP), intent(in):: sec
    end subroutine DCDateTimeCreateD

    subroutine DCDiffTimeCreateI(diff, sec) !:doc-priority 60:
      use dc_date_types, only: DC_DIFFTIME
      type(DC_DIFFTIME), intent(out):: diff
      integer, intent(in):: sec
    end subroutine DCDiffTimeCreateI

    subroutine DCDiffTimeCreateR(diff, sec) !:doc-priority 70:
      use dc_date_types, only: DC_DIFFTIME
      type(DC_DIFFTIME), intent(out):: diff
      real, intent(in):: sec
    end subroutine DCDiffTimeCreateR

    subroutine DCDiffTimeCreateD(diff, sec) !:doc-priority 80:
      use dc_types, only: DP
      use dc_date_types, only: DC_DIFFTIME
      type(DC_DIFFTIME), intent(out):: diff
      real(DP), intent(in):: sec
    end subroutine DCDiffTimeCreateD

!!$    subroutine DCDateLetFC(diff, string)
!!$      use dc_date_types, only: DC_DIFFTIME
!!$      type(DC_DIFFTIME), intent(out):: diff
!!$      character(len = *), intent(in):: string
!!$    end subroutine DCDateLetFC
!!$
!!$    subroutine DCDateLetTC(time, string)
!!$      use dc_date_types, only: DC_DATETIME
!!$      type(DC_DATETIME), intent(out):: time
!!$      character(len = *), intent(in):: string
!!$    end subroutine DCDateLetTC

  end interface

  interface SetCaltype
    subroutine DCDateTimeSetCaltype(caltype)
      integer, intent(in):: caltype
    end subroutine DCDateTimeSetCaltype
  end interface

  interface SetSecOfDay
    subroutine DCDateTimeSetSecOfDay(sec)
      use dc_types, only: DP
      real(DP), intent(in):: sec
    end subroutine DCDateTimeSetSecOfDay
  end interface

  interface ValidCaltype
    function DCDateTimeValidCaltype(caltype) result(result)
      integer, intent(in):: caltype
      logical:: result
    end function DCDateTimeValidCaltype
  end interface

  interface ValidZone
    function DCDateTimeValidZone(zone) result(result)
      character(*), intent(in):: zone
      logical:: result
    end function DCDateTimeValidZone
  end interface

  interface ZoneToDiff
    function DCDateTimeZoneToDiff(zone) result(diff)
      use dc_date_types, only: DC_DIFFTIME
      type(DC_DIFFTIME):: diff
      character(*), intent(in):: zone
    end function DCDateTimeZoneToDiff
  end interface

  interface ParseTimeUnits
    function DCDateTimeParseUnits(str) result(symbol)
      character(*), intent(in):: str
      integer:: symbol
    end function DCDateTimeParseUnits
  end interface

  interface SetZone
    subroutine DCDateTimeSetZone(time, zone, err)
      use dc_date_types, only: DC_DATETIME
      type(DC_DATETIME), intent(inout):: time
      character(*), intent(in):: zone
      logical, intent(out), optional:: err
    end subroutine DCDateTimeSetZone
  end interface

  interface Eval

    subroutine DCDateTimeEval1(time, year, mon, day, hour, min, &
      & sec, caltype, zone, sclyear, sclmon, sclday, sclsec)  !:doc-priority 40:
      use dc_types, only: DP
      use dc_date_types, only: DC_DATETIME
      use dc_scaledsec, only: DC_SCALED_SEC
      type(DC_DATETIME), intent(in):: time
      integer, intent(out), optional:: year, mon, day, hour, min, caltype
      real(DP), intent(out), optional:: sec
      character(*), intent(out), optional:: zone
      type(DC_SCALED_SEC), intent(out), optional:: sclyear, sclmon, sclday, sclsec
    end subroutine DCDateTimeEval1

!!$    subroutine DCDateTimeEval0(time, mon, day, sec)
!!$      use dc_date_types, only: DC_DATETIME
!!$      use dc_types,      only: DP
!!$      type(DC_DATETIME), intent(in):: time
!!$      integer, intent(out):: mon, day
!!$      real(DP), intent(out):: sec
!!$    end subroutine DCDateTimeEval0

    subroutine DCDiffTimeEval1(diff, &
      & year, mon, day, hour, min, sec, nondim, &
      & sclyear, sclmon, sclday, sclsec, sclnondim, err)  !:doc-priority 60:
      use dc_types, only: DP
      use dc_date_types, only: DC_DIFFTIME
      use dc_scaledsec, only: DC_SCALED_SEC
      type(DC_DIFFTIME), intent(in):: diff
      integer, intent(out), optional:: year, mon, day, hour, min
      real(DP), intent(out), optional:: sec, nondim
      type(DC_SCALED_SEC), intent(out), optional:: sclyear, sclmon, sclday, sclsec, sclnondim
      logical, intent(out), optional :: err
    end subroutine DCDiffTimeEval1

  end interface

  interface EvalDay
    function DCDateTimeEvalDay(time) result(result)  !:doc-priority 40:
      use dc_types, only: DP
      use dc_date_types, only: DC_DATETIME
      real(DP):: result
      type(DC_DATETIME), intent(in):: time
    end function DCDateTimeEvalDay

    function DCDiffTimeEvalDay(diff) result(result)  !:doc-priority 60:
      use dc_types, only: DP
      use dc_date_types, only: DC_DIFFTIME
      real(DP):: result
      type(DC_DIFFTIME), intent(in):: diff
    end function DCDiffTimeEvalDay
  end interface

  interface EvalHour
    function DCDateTimeEvalHour(time) result(result) !:doc-priority 40:
      use dc_types, only: DP
      use dc_date_types, only: DC_DATETIME
      real(DP):: result
      type(DC_DATETIME), intent(in):: time
    end function DCDateTimeEvalHour

    function DCDifftimeEvalHour(diff) result(result) !:doc-priority 60:
      use dc_types, only: DP
      use dc_date_types, only: DC_DIFFTIME
      real(DP):: result
      type(DC_DIFFTIME), intent(in):: diff
    end function DCDifftimeEvalHour
  end interface

  interface EvalMin
    function DCDateTimeEvalMin(time) result(result) !:doc-priority 40:
      use dc_types, only: DP
      use dc_date_types, only: DC_DATETIME
      real(DP):: result
      type(DC_DATETIME), intent(in):: time
    end function DCDateTimeEvalMin

    function DCDifftimeEvalMin(diff) result(result) !:doc-priority 60:
      use dc_types, only: DP
      use dc_date_types, only: DC_DIFFTIME
      real(DP):: result
      type(DC_DIFFTIME), intent(in):: diff
    end function DCDifftimeEvalMin
  end interface

  interface EvalSec
    function DCDateTimeEvalSec(time) result(result) !:doc-priority 40:
      use dc_types, only: DP
      use dc_date_types, only: DC_DATETIME
      real(DP):: result
      type(DC_DATETIME), intent(in):: time
    end function DCDateTimeEvalSec

    function DCDifftimeEvalSec(diff) result(result) !:doc-priority 60:
      use dc_types, only: DP
      use dc_date_types, only: DC_DIFFTIME
      real(DP):: result
      type(DC_DIFFTIME), intent(in):: diff
    end function DCDifftimeEvalSec
  end interface

  interface EvalNondim
    function DCDiffTimeEvalNondim(diff) result(result)
      use dc_types, only: DP
      use dc_date_types, only: DC_DIFFTIME
      real(DP):: result
      type(DC_DIFFTIME), intent(in):: diff
    end function DCDiffTimeEvalNondim
  end interface

  interface EvalSclSec
    function DCDateTimeEvalSclSec(time) result(result) !:doc-priority 40:
      use dc_date_types, only: DC_DATETIME
      use dc_scaledsec, only: DC_SCALED_SEC
      type(DC_SCALED_SEC):: result
      type(DC_DATETIME), intent(in):: time
    end function DCDateTimeEvalSclSec

    function DCDifftimeEvalSclSec(diff) result(result) !:doc-priority 60:
      use dc_date_types, only: DC_DIFFTIME
      use dc_scaledsec, only: DC_SCALED_SEC
      type(DC_SCALED_SEC):: result
      type(DC_DIFFTIME), intent(in):: diff
    end function DCDifftimeEvalSclSec
  end interface

  interface EvalByUnit

    function DCDateTimeEvalByUnit(time, unit, unit_symbol) result(result)
      use dc_types, only: DP, TOKEN
      use dc_date_types, only: DC_DATETIME
      real(DP):: result
      type(DC_DATETIME), intent(in):: time
      character(*), intent(in), optional:: unit
      integer, intent(in), optional:: unit_symbol
    end function DCDateTimeEvalByUnit

    function DCDiffTimeEvalByUnit(diff, unit, unit_symbol) result(result)
      use dc_types, only: DP, TOKEN
      use dc_date_types, only: DC_DIFFTIME
      real(DP):: result
      type(DC_DIFFTIME), intent(in):: diff
      character(*), intent(in), optional:: unit
      integer, intent(in), optional:: unit_symbol
    end function DCDiffTimeEvalByUnit
  end interface

  interface toChar
    function DCDateTimeToChar(time) result(result) !:doc-priority 40:
      use dc_types, only: STRING
      use dc_date_types, only: DC_DATETIME
      character(STRING) :: result
      type(DC_DATETIME), intent(in):: time
    end function DCDateTimeToChar

    function DCDiffTimeToChar(diff) result(result) !:doc-priority 60:
      use dc_types, only: STRING
      use dc_date_types, only: DC_DIFFTIME
      character(STRING) :: result
      type(DC_DIFFTIME), intent(in):: diff
    end function DCDiffTimeToChar
  end interface

  interface toCharCal
    function DCDateTimeToCharCal(time, upcase) result(result)
      use dc_types, only: TOKEN
      use dc_date_types, only: DC_DATETIME
      character(TOKEN) :: result
      type(DC_DATETIME), intent(in):: time
      logical, intent(in), optional:: upcase
    end function DCDateTimeToCharCal
  end interface

  interface operator(+)
    type(DC_DATETIME) function dcdatetime_add_ft(diff, time) result(result)
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      type(DC_DIFFTIME), intent(in):: diff
      type(DC_DATETIME), intent(in):: time
    end function dcdatetime_add_ft

    type(DC_DATETIME) function dcdatetime_add_tf(time, diff) result(result)
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      type(DC_DATETIME), intent(in):: time
      type(DC_DIFFTIME), intent(in):: diff
    end function dcdatetime_add_tf

    type(DC_DIFFTIME) function dcdatetime_add_ff(diff1, diff2) result(result)
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      type(DC_DIFFTIME), intent(in):: diff1, diff2
    end function dcdatetime_add_ff

    type(DC_DIFFTIME) function dcdatetime_add_fd(diff, sec) result(result)
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      use dc_types, only: DP
      type(DC_DIFFTIME), intent(in):: diff
      real(DP), intent(in):: sec
    end function dcdatetime_add_fd

    type(DC_DIFFTIME) function dcdatetime_add_fr(diff, sec) result(result)
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      type(DC_DIFFTIME), intent(in):: diff
      real, intent(in):: sec
    end function dcdatetime_add_fr

    type(DC_DIFFTIME) function dcdatetime_add_fi(diff, sec) result(result)
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      type(DC_DIFFTIME), intent(in):: diff
      integer, intent(in):: sec
    end function dcdatetime_add_fi
  end interface

  interface operator(-)
    type(DC_DATETIME) function dcdatetime_sub_tf(time, diff) result(result) !:doc-priority 40:
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      type(DC_DATETIME), intent(in):: time
      type(DC_DIFFTIME), intent(in):: diff
    end function dcdatetime_sub_tf

    type(DC_DIFFTIME) function dcdatetime_sub_tt(time1, time2) result(result)
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      type(DC_DATETIME), intent(in):: time1, time2
    end function dcdatetime_sub_tt

    type(DC_DIFFTIME) function dcdatetime_sub_ff(diff1, diff2) result(result)
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      type(DC_DIFFTIME), intent(in):: diff1, diff2
    end function dcdatetime_sub_ff

    type(DC_DIFFTIME) function dcdatetime_sub_fd(diff, sec) result(result)
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      use dc_types, only: DP
      type(DC_DIFFTIME), intent(in):: diff
      real(DP), intent(in):: sec
    end function dcdatetime_sub_fd

    type(DC_DIFFTIME) function dcdatetime_sub_fr(diff, sec) result(result)
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      type(DC_DIFFTIME), intent(in):: diff
      real, intent(in):: sec
    end function dcdatetime_sub_fr

    type(DC_DIFFTIME) function dcdatetime_sub_fi(diff, sec) result(result)
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      type(DC_DIFFTIME), intent(in):: diff
      integer, intent(in):: sec
    end function dcdatetime_sub_fi
  end interface

  interface operator(*)
    type(DC_DIFFTIME) function dcdatetime_mul_if(factor, diff) result(result) !:doc-priority 51:
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      integer, intent(in):: factor
      type(DC_DIFFTIME), intent(in):: diff
    end function dcdatetime_mul_if

    type(DC_DIFFTIME) function dcdatetime_mul_fi(diff, factor) result(result) !:doc-priority 52:
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      type(DC_DIFFTIME), intent(in):: diff
      integer, intent(in):: factor
    end function dcdatetime_mul_fi

    type(DC_DIFFTIME) function dcdatetime_mul_rf(factor, diff) result(result) !:doc-priority 61:
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      real, intent(in):: factor
      type(DC_DIFFTIME), intent(in):: diff
    end function dcdatetime_mul_rf

    type(DC_DIFFTIME) function dcdatetime_mul_fr(diff, factor) result(result) !:doc-priority 62:
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      type(DC_DIFFTIME), intent(in):: diff
      real, intent(in):: factor
    end function dcdatetime_mul_fr

    type(DC_DIFFTIME) function dcdatetime_mul_df(factor, diff) result(result) !:doc-priority 71:
      use dc_types, only: DP
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      real(DP), intent(in):: factor
      type(DC_DIFFTIME), intent(in):: diff
    end function dcdatetime_mul_df

    type(DC_DIFFTIME) function dcdatetime_mul_fd(diff, factor) result(result) !:doc-priority 72:
      use dc_types, only: DP
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      type(DC_DIFFTIME), intent(in):: diff
      real(DP), intent(in):: factor
    end function dcdatetime_mul_fd

  end interface

  interface operator(/)
    type(DC_DIFFTIME) function dcdatetime_div_fi(diff, denominator) result(result)
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      type(DC_DIFFTIME), intent(in):: diff
      integer, intent(in):: denominator
    end function dcdatetime_div_fi

    type(DC_DIFFTIME) function dcdatetime_div_fr(diff, denominator) result(result)
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      type(DC_DIFFTIME), intent(in):: diff
      real, intent(in):: denominator
    end function dcdatetime_div_fr

    type(DC_DIFFTIME) function dcdatetime_div_fd(diff, denominator) result(result)
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      use dc_types, only: DP
      type(DC_DIFFTIME), intent(in):: diff
      real(DP), intent(in):: denominator
    end function dcdatetime_div_fd

    real(DP) function dcdatetime_div_ff(diff1, diff2) result(result)
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      use dc_types, only: DP
      type(DC_DIFFTIME), intent(in):: diff1, diff2
    end function dcdatetime_div_ff
  end interface

  interface mod
    type(DC_DIFFTIME) function dcdatetime_mod_ff(diff1, diff2) result(result)
      use dc_date_types, only: DC_DIFFTIME
      type(DC_DIFFTIME), intent(in):: diff1, diff2
    end function dcdatetime_mod_ff
  end interface

  interface operator(==)
    logical function dcdatetime_eq_tt(time1, time2) result(result) !:doc-priority 30:
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      type(DC_DATETIME), intent(in):: time1, time2
    end function dcdatetime_eq_tt

    logical function dcdatetime_eq_ff(diff1, diff2) result(result) !:doc-priority 40:
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      type(DC_DIFFTIME), intent(in):: diff1, diff2
    end function dcdatetime_eq_ff

    logical function dcdatetime_eq_if(i, diff) result(result) !:doc-priority 51:
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      type(DC_DIFFTIME), intent(in):: diff
      integer, intent(in):: i
    end function dcdatetime_eq_if

    logical function dcdatetime_eq_fi(diff, i) result(result) !:doc-priority 52:
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      type(DC_DIFFTIME), intent(in):: diff
      integer, intent(in):: i
    end function dcdatetime_eq_fi

    logical function dcdatetime_eq_rf(r, diff) result(result) !:doc-priority 61:
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      type(DC_DIFFTIME), intent(in):: diff
      real, intent(in):: r
    end function dcdatetime_eq_rf

    logical function dcdatetime_eq_fr(diff, r) result(result) !:doc-priority 62:
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      type(DC_DIFFTIME), intent(in):: diff
      real, intent(in):: r
    end function dcdatetime_eq_fr

    logical function dcdatetime_eq_df(d, diff) result(result) !:doc-priority 71:
      use dc_types, only: DP
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      type(DC_DIFFTIME), intent(in):: diff
      real(DP), intent(in):: d
    end function dcdatetime_eq_df

    logical function dcdatetime_eq_fd(diff, d) result(result) !:doc-priority 72:
      use dc_types, only: DP
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      type(DC_DIFFTIME), intent(in):: diff
      real(DP), intent(in):: d
    end function dcdatetime_eq_fd

  end interface

  interface operator(>)
    logical function dcdatetime_gt_tt(time1, time2) result(result) !:doc-priority 30:
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      type(DC_DATETIME), intent(in):: time1, time2
    end function dcdatetime_gt_tt

    logical function dcdatetime_gt_ff(diff1, diff2) result(result) !:doc-priority 40:
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      type(DC_DIFFTIME), intent(in):: diff1, diff2
    end function dcdatetime_gt_ff

    logical function dcdatetime_gt_fi(diff, factor) result(result) !:doc-priority 42:
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      type(DC_DIFFTIME), intent(in):: diff
      integer, intent(in):: factor
    end function dcdatetime_gt_fi

    logical function dcdatetime_gt_if(factor, diff) result(result) !:doc-priority 44:
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      integer, intent(in):: factor
      type(DC_DIFFTIME), intent(in):: diff
    end function dcdatetime_gt_if
  end interface

  interface operator(<)
    logical function dcdatetime_lt_tt(time1, time2) result(result) !:doc-priority 30:
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      type(DC_DATETIME), intent(in):: time1, time2
    end function dcdatetime_lt_tt

    logical function dcdatetime_lt_ff(diff1, diff2) result(result) !:doc-priority 40:
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      type(DC_DIFFTIME), intent(in):: diff1, diff2
    end function dcdatetime_lt_ff

    logical function dcdatetime_lt_fi(diff, factor) result(result) !:doc-priority 42:
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      type(DC_DIFFTIME), intent(in):: diff
      integer, intent(in):: factor
    end function dcdatetime_lt_fi

    logical function dcdatetime_lt_if(factor, diff) result(result) !:doc-priority 44:
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      integer, intent(in):: factor
      type(DC_DIFFTIME), intent(in):: diff
    end function dcdatetime_lt_if
  end interface

  interface operator(>=)
    logical function dcdatetime_ge_tt(time1, time2) result(result) !:doc-priority 30:
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      type(DC_DATETIME), intent(in):: time1, time2
    end function dcdatetime_ge_tt

    logical function dcdatetime_ge_ff(diff1, diff2) result(result) !:doc-priority 40:
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      type(DC_DIFFTIME), intent(in):: diff1, diff2
    end function dcdatetime_ge_ff

    logical function dcdatetime_ge_fi(diff, factor) result(result) !:doc-priority 42:
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      type(DC_DIFFTIME), intent(in):: diff
      integer, intent(in):: factor
    end function dcdatetime_ge_fi

    logical function dcdatetime_ge_if(factor, diff) result(result) !:doc-priority 44:
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      integer, intent(in):: factor
      type(DC_DIFFTIME), intent(in):: diff
    end function dcdatetime_ge_if
  end interface

  interface operator(<=)
    logical function dcdatetime_le_tt(time1, time2) result(result) !:doc-priority 30:
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      type(DC_DATETIME), intent(in):: time1, time2
    end function dcdatetime_le_tt

    logical function dcdatetime_le_ff(diff1, diff2) result(result) !:doc-priority 40:
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      type(DC_DIFFTIME), intent(in):: diff1, diff2
    end function dcdatetime_le_ff

    logical function dcdatetime_le_fi(diff, factor) result(result) !:doc-priority 42:
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      type(DC_DIFFTIME), intent(in):: diff
      integer, intent(in):: factor
    end function dcdatetime_le_fi

    logical function dcdatetime_le_if(factor, diff) result(result) !:doc-priority 44:
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      integer, intent(in):: factor
      type(DC_DIFFTIME), intent(in):: diff
    end function dcdatetime_le_if
  end interface

  interface max
    type(DC_DATETIME) function dcdatetime_max_tt(time1, time2) result(result) !:doc-priority 30:
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      type(DC_DATETIME), intent(in):: time1, time2
    end function dcdatetime_max_tt

    type(DC_DIFFTIME) function dcdatetime_max_ff(diff1, diff2) result(result) !:doc-priority 40:
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      type(DC_DIFFTIME), intent(in):: diff1, diff2
    end function dcdatetime_max_ff
  end interface

  interface min
    type(DC_DATETIME) function dcdatetime_min_tt(time1, time2) result(result) !:doc-priority 30:
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      type(DC_DATETIME), intent(in):: time1, time2
    end function dcdatetime_min_tt

    type(DC_DIFFTIME) function dcdatetime_min_ff(diff1, diff2) result(result) !:doc-priority 40:
      use dc_date_types, only: DC_DATETIME, DC_DIFFTIME
      type(DC_DIFFTIME), intent(in):: diff1, diff2
    end function dcdatetime_min_ff
  end interface

  !-----------------------------------------------
  ! å¾Œæ–¹äº’æ›ç”¨
  ! For backward compatibility
  interface Create
    subroutine DCDateTimeCreate1_bc(time, &
      & year, mon, day, hour, min, sec, &
      & zone, caltype, day_seconds, err) !:doc-priority 40:
      use dc_types, only: DP
      use dc_date_types, only: DC_DATETIME
      use dc_scaledsec, only: DC_SCALED_SEC
      type(DC_DATETIME), intent(out):: time
      integer, intent(in), optional:: year, mon, day, hour, min
      real(DP),intent(in), optional:: sec, day_seconds
      character(*), intent(in), optional :: zone
      integer, intent(in), optional:: caltype
      logical, intent(out), optional:: err
    end subroutine DCDateTimeCreate1_bc

    subroutine DCDiffTimeCreate1_bc(diff, &
      & year, mon, day, hour, min, sec, day_seconds ) !:doc-priority 60:
      use dc_types, only: DP
      use dc_date_types, only: DC_DIFFTIME
      use dc_scaledsec, only: DC_SCALED_SEC
      type(DC_DIFFTIME), intent(out) :: diff
      integer, intent(in), optional:: year, mon, day, hour, min
      real(DP),intent(in), optional:: sec, day_seconds
    end subroutine DCDiffTimeCreate1_bc

    subroutine DCDiffTimeCreate2_bc(diff, value, unit, unit_symbol, err) !:doc-priority 70:
      use dc_types, only: DP
      use dc_date_types, only: DC_DIFFTIME
      type(DC_DIFFTIME), intent(out) :: diff
      real(DP), intent(in) :: value
      character(*), intent(in) :: unit
      integer, intent(in), optional :: unit_symbol
      logical, intent(out), optional :: err
    end subroutine DCDiffTimeCreate2_bc
  end interface

  interface PutLine
    subroutine DCDateTimePutLine_bc(time, unit)
      use dc_date_types, only: DC_DATETIME
      type(DC_DATETIME), intent(in) :: time
      integer, intent(in), optional :: unit
    end subroutine DCDateTimePutLine_bc

    subroutine DCDiffTimePutLine_bc(diff, unit)
      use dc_date_types, only: DC_DIFFTIME
      type(DC_DIFFTIME), intent(in) :: diff
      integer, intent(in), optional :: unit
    end subroutine DCDiffTimePutLine_bc
  end interface

end module dc_date_generic