libsim  Versione7.2.3

◆ timedelta_init()

subroutine timedelta_init ( type(timedelta), intent(inout)  this,
integer, intent(in), optional  year,
integer, intent(in), optional  month,
integer, intent(in), optional  day,
integer, intent(in), optional  hour,
integer, intent(in), optional  minute,
integer, intent(in), optional  sec,
integer, intent(in), optional  msec,
character(len=*), intent(in), optional  isodate,
character(len=*), intent(in), optional  simpledate,
character(len=12), intent(in), optional  oraclesimdate 
)

Costruisce un oggetto timedelta con i parametri opzionali forniti.

Se non viene passato nulla lo inizializza a intervallo di durata nulla. L'intervallo ottenuto � pari alla somma dei valori di tutti i parametri forniti, ovviamente non fornire un parametro equivale a fornirlo =0.

Parametri
[in,out]thisoggetto da inizializzare
[in]yearanni, se presente l'oggetto diventa "popolare"
[in]monthmesi, se presente l'oggetto diventa "popolare"
[in]daygiorni
[in]hourore
[in]minuteminuti
[in]secsecondi
[in]msecmillisecondi
[in]isodateinizializza l'oggetto ad un intervallo nel formato AAAAMMGGGG hh:mm:ss.msc, ignorando tutti gli altri parametri, se AAAA o MM sono diversi da 0 l'oggetto diventa "popolare"
[in]simpledateinizializza l'oggetto ad un intervallo nel formato GGGGGGGGhhmmmsc, ignorando tutti gli altri parametri, da preferire rispetto a oraclesimdate
[in]oraclesimdateinizializza l'oggetto ad un intervallo nel formato GGGGGGGGhhmm, ignorando tutti gli altri parametri

Definizione alla linea 1555 del file datetime_class.F90.

1555 
1556 lndays=ndays
1557 
1558 n = lndays/d400
1559 lndays = lndays - n*d400
1560 iaa = year0 + n*400
1561 n = min(lndays/d100, 3)
1562 lndays = lndays - n*d100
1563 iaa = iaa + n*100
1564 n = lndays/d4
1565 lndays = lndays - n*d4
1566 iaa = iaa + n*4
1567 n = min(lndays/d1, 3)
1568 lndays = lndays - n*d1
1569 iaa = iaa + n
1570 n = bisextilis(iaa)
1571 DO imm = 1, 12
1572  IF (lndays < ianno(imm+1,n)) EXIT
1573 ENDDO
1574 igg = lndays+1-ianno(imm,n) ! +1 perche' il mese parte da 1
1575 
1576 END SUBROUTINE ndyin
1577 
1578 
1579 integer elemental FUNCTION ndays(igg,imm,iaa)
1580 
1581 !!OMSTART NDAYS
1582 ! FUNCTION NDAYS(IGG,IMM,IAA)
1583 ! restituisce il numero di giorni dal 1/1/1
1584 ! fornendo in input la data
1585 !
1586 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1587 ! nota bene E' SICURO !!!
1588 ! un anno e' bisestile se divisibile per 4
1589 ! un anno rimane bisestile se divisibile per 400
1590 ! un anno NON e' bisestile se divisibile per 100
1591 !
1592 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1593 !
1594 !!omend
1595 
1596 INTEGER, intent(in) :: igg, imm, iaa
1597 
1598 INTEGER :: lmonth, lyear
1599 
1600 ! Limito il mese a [1-12] e correggo l'anno coerentemente
1601 lmonth = modulo(imm-1, 12) + 1 ! uso MODULO e non MOD per gestire bene i valori <0
1602 lyear = iaa + (imm - lmonth)/12
1603 ndays = igg+ianno(lmonth, bisextilis(lyear))
1604 ndays = ndays-1 + 365*(lyear-year0) + (lyear-year0)/4 - (lyear-year0)/100 + &
1605  (lyear-year0)/400
1606 
1607 END FUNCTION ndays
1608 
1609 
1610 elemental FUNCTION bisextilis(annum)
1611 INTEGER,INTENT(in) :: annum
1612 INTEGER :: bisextilis
1613 
1614 IF (mod(annum,4) == 0 .AND. (mod(annum,400) == 0 .EQV. mod(annum,100) == 0)) THEN
1615  bisextilis = 2
1616 ELSE
1617  bisextilis = 1
1618 ENDIF
1619 END FUNCTION bisextilis
1620 
1621 
1622 ELEMENTAL FUNCTION cyclicdatetime_eq(this, that) RESULT(res)
1623 TYPE(cyclicdatetime),INTENT(IN) :: this, that
1624 LOGICAL :: res
1625 
1626 res = .true.
1627 if (this%minute /= that%minute) res=.false.
1628 if (this%hour /= that%hour) res=.false.
1629 if (this%day /= that%day) res=.false.
1630 if (this%month /= that%month) res=.false.
1631 if (this%tendaysp /= that%tendaysp) res=.false.
1632 
1633 END FUNCTION cyclicdatetime_eq
1634 
1635 
1636 ELEMENTAL FUNCTION cyclicdatetime_datetime_eq(this, that) RESULT(res)
1637 TYPE(cyclicdatetime),INTENT(IN) :: this
1638 TYPE(datetime),INTENT(IN) :: that
1639 LOGICAL :: res
1640 
1641 integer :: minute,hour,day,month
1642 
1643 call getval(that,minute=minute,hour=hour,day=day,month=month)
1644 
1645 res = .true.
1646 if (c_e(this%minute) .and. this%minute /= minute) res=.false.
1647 if (c_e(this%hour) .and. this%hour /= hour) res=.false.
1648 if (c_e(this%day) .and. this%day /= day) res=.false.
1649 if (c_e(this%month) .and. this%month /= month) res=.false.
1650 if (c_e(this%tendaysp)) then
1651  if ( this%tendaysp /= min(((day-1)/10) +1,3)) res=.false.
1652 end if
1653 
1654 END FUNCTION cyclicdatetime_datetime_eq
1655 
1656 
1657 ELEMENTAL FUNCTION datetime_cyclicdatetime_eq(this, that) RESULT(res)
1658 TYPE(datetime),INTENT(IN) :: this
1659 TYPE(cyclicdatetime),INTENT(IN) :: that
1660 LOGICAL :: res
1661 
1662 integer :: minute,hour,day,month
1663 
1664 call getval(this,minute=minute,hour=hour,day=day,month=month)
1665 
1666 res = .true.
1667 if (c_e(that%minute) .and. that%minute /= minute) res=.false.
1668 if (c_e(that%hour) .and. that%hour /= hour) res=.false.
1669 if (c_e(that%day) .and. that%day /= day) res=.false.
1670 if (c_e(that%month) .and. that%month /= month) res=.false.
1671 
1672 if (c_e(that%tendaysp)) then
1673  if ( that%tendaysp /= min(((day-1)/10) +1,3)) res=.false.
1674 end if
1675 
1676 
1677 END FUNCTION datetime_cyclicdatetime_eq
1678 
1679 ELEMENTAL FUNCTION c_e_cyclicdatetime(this) result (res)
1680 TYPE(cyclicdatetime),INTENT(in) :: this
1681 LOGICAL :: res
1682 
1683 res = .not. this == cyclicdatetime_miss
1684 
1685 end FUNCTION c_e_cyclicdatetime
1686 
1687 

Generated with Doxygen.