libsim Versione 7.2.6
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/>.
18PROGRAM datetime_test
19!USE kinds
21IMPLICIT NONE
22
23TYPE(datetime) :: dt1, dt2
24TYPE(timedelta) :: td1
25INTEGER :: i
26CHARACTER(len=24) :: dtlong
27
28print*,'=== Testing datetime_class module ==='
29
30print*,'Testing datetime_init and datetime_getval with simpledate'
31dt1 = datetime_new(simpledate='000412300000')
32CALL getval(dt1, simpledate=dtlong)
33IF (dtlong(1:12) /= '000412300000') CALL exit(1)
34dt1 = datetime_new(simpledate='000412310000')
35CALL getval(dt1, simpledate=dtlong)
36IF (dtlong(1:12) /= '000412310000') CALL exit(1)
37
38print*,'Testing datetime_init and datetime_getval with isodate'
39dt1 = datetime_new(simpledate='000412300000')
40CALL getval(dt1, isodate=dtlong)
41IF (dtlong(1:23) /= '0004-12-30 00:00:00.000') CALL exit(1)
42dt1 = datetime_new(simpledate='000412310000')
43CALL getval(dt1, isodate=dtlong)
44IF (dtlong(1:23) /= '0004-12-31 00:00:00.000') CALL exit(1)
45
46print*,'Testing leap year, 2000'
47dt1 = datetime_new(simpledate='199912010000')
48td1 = timedelta_new(minute=60*24)
49DO i=1,366
50 dt1 = dt1+td1
51ENDDO
52CALL display(td1)
53CALL display(dt1)
54CALL getval(dt1, simpledate=dtlong)
55IF (dtlong(1:17) /= '20001201000000000') CALL exit(1)
56
57print*,'Testing leap year, 1900'
58dt1 = datetime_new(simpledate='189912010000')
59td1 = timedelta_new(minute=60*24)
60DO i=1,365
61 dt1 = dt1+td1
62ENDDO
63CALL getval(dt1, simpledate=dtlong)
64IF (dtlong(1:17) /= '19001201000000000') CALL exit(1)
65
66print*,'Testing human timedelta intervals'
67dt1 = datetime_new(simpledate='189912010000')
68td1 = timedelta_new(month=3)
69DO i=1,101
70 dt1 = dt1+4*td1
71ENDDO
72CALL getval(dt1, simpledate=dtlong)
73IF (dtlong(1:17) /= '20001201000000000') CALL exit(1)
74
75print*,'Testing now'
76dt1 = datetime_new_now(datetime_utc)
77dt2 = datetime_new_now(datetime_local)
78CALL getval(dt1, isodate=dtlong)
79WRITE(*,'(A,A)')'UTC time is: ',dtlong
80CALL getval(dt2, isodate=dtlong)
81WRITE(*,'(A,A)')'Local time is: ',dtlong
82
83END PROGRAM datetime_test
Restituiscono il valore dell'oggetto nella forma desiderata.
Classi per la gestione delle coordinate temporali.

Generated with Doxygen.