libsim  Versione7.2.3
datetime_test.f90
1 ! Copyright (C) 2010 ARPA-SIM <urpsim@smr.arpa.emr.it>
2 ! authors:
3 ! Davide Cesari <dcesari@arpa.emr.it>
4 ! Paolo Patruno <ppatruno@arpa.emr.it>
5 
6 ! This program is free software; you can redistribute it and/or
7 ! modify it under the terms of the GNU General Public License as
8 ! published by the Free Software Foundation; either version 2 of
9 ! the License, or (at your option) any later version.
10 
11 ! This program is distributed in the hope that it will be useful,
12 ! but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ! GNU General Public License for more details.
15 
16 ! You should have received a copy of the GNU General Public License
17 ! along with this program. If not, see <http://www.gnu.org/licenses/>.
18 PROGRAM datetime_test
19 !USE kinds
21 IMPLICIT NONE
22 
23 TYPE(datetime) :: dt1, dt2
24 TYPE(timedelta) :: td1
25 INTEGER :: i
26 CHARACTER(len=24) :: dtlong
27 
28 print*,'=== Testing datetime_class module ==='
29 
30 print*,'Testing datetime_init and datetime_getval with simpledate'
31 dt1 = datetime_new(simpledate='000412300000')
32 CALL getval(dt1, simpledate=dtlong)
33 IF (dtlong(1:12) /= '000412300000') CALL exit(1)
34 dt1 = datetime_new(simpledate='000412310000')
35 CALL getval(dt1, simpledate=dtlong)
36 IF (dtlong(1:12) /= '000412310000') CALL exit(1)
37 
38 print*,'Testing datetime_init and datetime_getval with isodate'
39 dt1 = datetime_new(simpledate='000412300000')
40 CALL getval(dt1, isodate=dtlong)
41 IF (dtlong(1:23) /= '0004-12-30 00:00:00.000') CALL exit(1)
42 dt1 = datetime_new(simpledate='000412310000')
43 CALL getval(dt1, isodate=dtlong)
44 IF (dtlong(1:23) /= '0004-12-31 00:00:00.000') CALL exit(1)
45 
46 print*,'Testing leap year, 2000'
47 dt1 = datetime_new(simpledate='199912010000')
48 td1 = timedelta_new(minute=60*24)
49 DO i=1,366
50  dt1 = dt1+td1
51 ENDDO
52 CALL display(td1)
53 CALL display(dt1)
54 CALL getval(dt1, simpledate=dtlong)
55 IF (dtlong(1:17) /= '20001201000000000') CALL exit(1)
56 
57 print*,'Testing leap year, 1900'
58 dt1 = datetime_new(simpledate='189912010000')
59 td1 = timedelta_new(minute=60*24)
60 DO i=1,365
61  dt1 = dt1+td1
62 ENDDO
63 CALL getval(dt1, simpledate=dtlong)
64 IF (dtlong(1:17) /= '19001201000000000') CALL exit(1)
65 
66 print*,'Testing human timedelta intervals'
67 dt1 = datetime_new(simpledate='189912010000')
68 td1 = timedelta_new(month=3)
69 DO i=1,101
70  dt1 = dt1+4*td1
71 ENDDO
72 CALL getval(dt1, simpledate=dtlong)
73 IF (dtlong(1:17) /= '20001201000000000') CALL exit(1)
74 
75 print*,'Testing now'
76 dt1 = datetime_new_now(datetime_utc)
77 dt2 = datetime_new_now(datetime_local)
78 CALL getval(dt1, isodate=dtlong)
79 WRITE(*,'(A,A)')'UTC time is: ',dtlong
80 CALL getval(dt2, isodate=dtlong)
81 WRITE(*,'(A,A)')'Local time is: ',dtlong
82 
83 END PROGRAM datetime_test
Classi per la gestione delle coordinate temporali.
Restituiscono il valore dell&#39;oggetto nella forma desiderata.

Generated with Doxygen.