libsim Versione 7.2.4

◆ 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 1543 del file datetime_class.F90.

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

Generated with Doxygen.