ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
test_pm_dateTime.F90
Go to the documentation of this file.
1!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
3!!!! !!!!
4!!!! ParaMonte: Parallel Monte Carlo and Machine Learning Library. !!!!
5!!!! !!!!
6!!!! Copyright (C) 2012-present, The Computational Data Science Lab !!!!
7!!!! !!!!
8!!!! This file is part of the ParaMonte library. !!!!
9!!!! !!!!
10!!!! LICENSE !!!!
11!!!! !!!!
12!!!! https://github.com/cdslaborg/paramonte/blob/main/LICENSE.md !!!!
13!!!! !!!!
14!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
15!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
16
24
25!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
26
28
29 use pm_dateTime
30 use pm_kind, only: LK
31 use pm_test, only: test_type
32
33 implicit none
34
35 private
36 public :: setTest
37 type(test_type) :: test
38
39!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
40
41 interface
42 module function test_constructDateTimeInt() result(assertion); logical(LK) :: assertion; end function
43 module function test_constructDateTimeStr() result(assertion); logical(LK) :: assertion; end function
44 module function test_getDateTimeShifted() result(assertion); logical(LK) :: assertion; end function
45 module function test_getDateTimeNewZone() result(assertion); logical(LK) :: assertion; end function
46 module function test_getCountLeapYears() result(assertion); logical(LK) :: assertion; end function
47 module function test_isLastDayInMonth() result(assertion); logical(LK) :: assertion; end function
48 module function test_getDateTimeDiff() result(assertion); logical(LK) :: assertion; end function
49 module function test_isValidDateTime() result(assertion); logical(LK) :: assertion; end function
50 module function test_getMillisecond() result(assertion); logical(LK) :: assertion; end function
51 module function test_getDateTimeUTC() result(assertion); logical(LK) :: assertion; end function
52 module function test_getDateTime_1() result(assertion); logical(LK) :: assertion; end function
53 module function test_getDateTime_2() result(assertion); logical(LK) :: assertion; end function
54 module function test_getDateBefore() result(assertion); logical(LK) :: assertion; end function
55 module function test_getOrdinalDay() result(assertion); logical(LK) :: assertion; end function
56 module function test_getWeekNumber() result(assertion); logical(LK) :: assertion; end function
57 module function test_getCountWeeks() result(assertion); logical(LK) :: assertion; end function
58 module function test_getWeekDayISO() result(assertion); logical(LK) :: assertion; end function
59 module function test_getDateAfter() result(assertion); logical(LK) :: assertion; end function
60 module function test_getCountDays() result(assertion); logical(LK) :: assertion; end function
61 module function test_getJulianDay() result(assertion); logical(LK) :: assertion; end function
62 module function test_getWeekDate() result(assertion); logical(LK) :: assertion; end function
63 module function test_isValidZone() result(assertion); logical(LK) :: assertion; end function
64 module function test_getWeekYear() result(assertion); logical(LK) :: assertion; end function
65 module function test_getWeekDay() result(assertion); logical(LK) :: assertion; end function
66 module function test_isMorning() result(assertion); logical(LK) :: assertion; end function
67 module function test_getZone() result(assertion); logical(LK) :: assertion; end function
68 end interface
69
70!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
71
72contains
73
74!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
75
76 subroutine setTest()
77
78 implicit none
79
81 call test%run(test_constructDateTimeInt, SK_"test_constructDateTimeInt")
82 call test%run(test_constructDateTimeStr, SK_"test_constructDateTimeStr")
83 call test%run(test_getDateTimeShifted, SK_"test_getDateTimeShifted")
84 call test%run(test_getDateTimeNewZone, SK_"test_getDateTimeNewZone")
85 call test%run(test_getCountLeapYears, SK_"test_getCountLeapYears")
86 call test%run(test_isLastDayInMonth, SK_"test_isLastDayInMonth")
87 call test%run(test_getDateTimeDiff, SK_"test_getDateTimeDiff")
88 call test%run(test_isValidDateTime, SK_"test_isValidDateTime")
89 call test%run(test_getMillisecond, SK_"test_getMillisecond")
90 call test%run(test_getDateTimeUTC, SK_"test_getDateTimeUTC")
91 call test%run(test_getDateTime_1, SK_"test_getDateTime_1")
92 call test%run(test_getDateTime_2, SK_"test_getDateTime_2")
93 call test%run(test_getDateAfter, SK_"test_getDateAfter")
94 call test%run(test_getDateBefore, SK_"test_getDateBefore")
95 call test%run(test_getWeekNumber, SK_"test_getWeekNumber")
96 call test%run(test_getCountWeeks, SK_"test_getCountWeeks")
97 call test%run(test_getWeekDayISO, SK_"test_getWeekDayISO")
98 call test%run(test_getOrdinalDay, SK_"test_getOrdinalDay")
99 call test%run(test_getCountDays, SK_"test_getCountDays")
100 call test%run(test_getJulianDay, SK_"test_getJulianDay")
101 call test%run(test_getWeekDate, SK_"test_getWeekDate")
102 call test%run(test_getWeekYear, SK_"test_getWeekYear")
103 call test%run(test_isValidZone, SK_"test_isValidZone")
104 call test%run(test_getWeekDay, SK_"test_getWeekDay")
105 call test%run(test_isMorning, SK_"test_isMorning")
106 call test%run(test_getZone, SK_"test_getZone")
107 call test%summarize()
108
109 end subroutine setTest
110
111!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
112
113! function test_queryDateTime() result(assertion)
114!
115! implicit none
116! logical(LK) :: assertion
117! type(DateTime_type) :: DateTime
118!
119! assertion = .true._LK
120!
121! call DateTime%query()
122!
123! if (test%traceable .and. .not. assertion) then
124! ! LCOV_EXCL_START
125! write(test%disp%unit,"(*(g0,:,' '))")
126! write(test%disp%unit,"(*(g0,:,' '))") " date:", DateTime%date
127! write(test%disp%unit,"(*(g0,:,' '))") " time:", DateTime%time
128! write(test%disp%unit,"(*(g0,:,' '))") " zone:", DateTime%zone
129! write(test%disp%unit,"(*(g0,:,' '))") " century:", DateTime%century
130! write(test%disp%unit,"(*(g0,:,' '))") " year:", DateTime%year
131! write(test%disp%unit,"(*(g0,:,' '))") " month:", DateTime%month
132! write(test%disp%unit,"(*(g0,:,' '))") " day:", DateTime%day
133! write(test%disp%unit,"(*(g0,:,' '))") " hour:", DateTime%hour
134! write(test%disp%unit,"(*(g0,:,' '))") " minute:", DateTime%minute
135! write(test%disp%unit,"(*(g0,:,' '))") " second:", DateTime%second
136! write(test%disp%unit,"(*(g0,:,' '))") " millisecond:", DateTime%millisecond
137! write(test%disp%unit,"(*(g0,:,' '))") " values:", DateTime%vals
138! write(test%disp%unit,"(*(g0,:,' '))") "fancyStyleBasic:", DateTime%fancyStyleBasic
139! write(test%disp%unit,"(*(g0,:,' '))") " fancyStyle:", DateTime%fancyStyle
140! write(test%disp%unit,"(*(g0,:,' '))")
141! ! LCOV_EXCL_STOP
142! end if
143!
144! end function test_queryDateTime
145!
146!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
147!
148! ! Test the equivalence of [getNiceDateTime()](@ref pm_dateTime::getnicedatetime) with
149! ! the output of the `fancyStyleBasic()` method of [DateTime_type](@ref pm_dateTime::dateTime_type).
150! function test_getNiceDateTime() result(assertion)
151!
152! implicit none
153! logical(LK) :: assertion
154! type(DateTime_type) :: DateTime
155! character(:, SK), allocatable :: niceDateTime
156!
157! call DateTime%query()
158! niceDateTime = getNiceDateTime()
159! assertion = niceDateTime == DateTime%fancyStyleBasic
160!
161! if (test%traceable .and. .not. assertion) then
162! ! LCOV_EXCL_START
163! write(test%disp%unit,"(*(g0,:,' '))")
164! write(test%disp%unit,"(*(g0,:,' '))") " getNiceDateTime():", niceDateTime
165! write(test%disp%unit,"(*(g0,:,' '))") "DateTime%fancyStyleBasic:", DateTime%fancyStyleBasic
166! write(test%disp%unit,"(*(g0,:,' '))")
167! end if
168! ! LCOV_EXCL_STOP
169!
170!#if !CODECOV_ENABLED
171! assertion = .true._LK
172!#endif
173! end function test_getNiceDateTime
174
175!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
176
177end module test_pm_dateTime ! LCOV_EXCL_LINE
This module contains classes and procedures for computing, manipulating, and styling dates and times.
character(*, SK), parameter MODULE_NAME
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
Definition: pm_kind.F90:268
integer, parameter LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
Definition: pm_kind.F90:541
This module contains a simple unit-testing framework for the Fortran libraries, including the ParaMon...
Definition: pm_test.F90:42
This include file contains procedure implementations of the tests of pm_dateTime.
subroutine setTest()
type(test_type) test
This is the derived type test_type for generating objects that facilitate testing of a series of proc...
Definition: pm_test.F90:209