Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Futility
Futility
Commits
ec44cb25
Commit
ec44cb25
authored
May 02, 2022
by
Graham, Aaron
Browse files
Fix issue with getDate
parent
75911d92
Pipeline
#218061
passed with stage
in 2 minutes and 20 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/Times.f90
View file @
ec44cb25
...
...
@@ -288,7 +288,7 @@ FUNCTION getDate(opt) RESULT(strdate)
mon
=
(/
'Jan.'
,
'Feb.'
,
'Mar.'
,
'Apr.'
,
'May '
,
'June'
,
&
'July'
,
'Aug.'
,
'Sep.'
,
'Oct.'
,
'Nov.'
,
'Dec.'
/)
INTEGER
(
SIK
),
OPTIONAL
,
INTENT
(
IN
)
::
opt
CHARACTER
(
LEN
=
13
)
::
strdate
TYPE
(
StringType
)
::
strdate
CHARACTER
(
LEN
=
8
)
::
adate
CHARACTER
(
LEN
=
4
)
::
yy
CHARACTER
(
LEN
=
2
)
::
dd
,
mm
...
...
@@ -305,11 +305,11 @@ FUNCTION getDate(opt) RESULT(strdate)
yy
=
adate
(
1
:
4
)
mm
=
adate
(
5
:
6
)
dd
=
adate
(
7
:
8
)
READ
(
mm
,
'(i2)'
)
imon
IF
(
fmt
==
1_SIK
.AND.
LEN
(
strdate
)
>=
8_SIK
)
THEN
IF
(
fmt
==
1_SIK
)
THEN
strdate
=
mm
//
'/'
//
dd
//
'/'
//
yy
ELSEIF
(
fmt
==
2_SIK
.AND.
LEN
(
strdate
)
>=
13_SIK
)
THEN
strdate
=
mon
(
imon
)//
' '
//
dd
//
', '
//
yy
ELSEIF
(
fmt
==
2_SIK
)
THEN
READ
(
mm
,
'(i2)'
)
imon
strdate
=
TRIM
(
mon
(
imon
))//
' '
//
dd
//
', '
//
yy
ENDIF
ENDFUNCTION
getDate
!
...
...
unit_tests/testTimes/testTimes.f90
View file @
ec44cb25
...
...
@@ -20,7 +20,7 @@ INTEGER :: idum1,idum2,idum3,ioerr
CHARACTER
(
LEN
=
1
)
::
adum1
,
adum2
CHARACTER
(
LEN
=
5
)
::
adum3
CHARACTER
(
LEN
=
2
)
::
adum4
TYPE
(
StringType
)
::
adate
TYPE
(
StringType
)
::
adate
,
adate2
TYPE
(
StringType
)
::
aclock
REAL
(
SRK
)
::
totalElapsed
!
...
...
@@ -56,8 +56,8 @@ SUBROUTINE testTimers()
ASSERT_GT
(
idum2
,
0
,
'day'
)
ASSERT_LT
(
idum2
,
32
,
'day'
)
ASSERT_GT
(
idum3
,
0
,
'year'
)
INFO
(
0
)
'getDate() = '
//
getDate
()
ASSERT_EQ
(
getD
ate
(
),
getD
ate
(
1
),
'getDate(1)'
)
adate2
=
getDate
(
1
)
ASSERT_EQ
(
CHAR
(
ad
ate
),
CHAR
(
ad
ate
2
),
'getDate(1)'
)
idum1
=
0
idum2
=
0
...
...
@@ -68,7 +68,12 @@ SUBROUTINE testTimers()
ASSERT_GT
(
idum1
,
0
,
'day'
)
ASSERT_LT
(
idum1
,
32
,
'day'
)
ASSERT_GT
(
idum2
,
0
,
'year'
)
ASSERT_EQ
(
tokens
(
1
)
%
substr
(
LEN
(
tokens
(
1
))),
'.'
,
'month'
)
SELECTCASE
(
CHAR
(
tokens
(
1
)))
CASE
(
'Jan.'
,
'Feb.'
,
'Mar.'
,
'Apr.'
,
'May'
,
'June'
,
'July'
,
'Aug.'
,
'Sep.'
,
'Oct.'
,
'Nov.'
,
'Dec.'
)
ASSERT
(
.TRUE.
,
'month'
)
CASE
DEFAULT
ASSERT
(
.FALSE.
,
'month = "'
//
tokens
(
1
)//
'"'
)
ENDSELECT
!Test getTimeFromDate
COMPONENT_TEST
(
'getTimeFromDate'
)
...
...
@@ -172,7 +177,7 @@ SUBROUTINE testTimers()
ASSERT_GT
(
idum2
,
0
,
'day'
)
ASSERT_LT
(
idum2
,
32
,
'day'
)
ASSERT_GT
(
idum3
,
0
,
'year'
)
ASSERT_EQ
(
testTimer
%
getDate
(),
testTimer
%
getDate
(
1
),
'%getDate(1)'
)
ASSERT_EQ
(
CHAR
(
testTimer
%
getDate
()
)
,
CHAR
(
testTimer
%
getDate
(
1
)
)
,
'%getDate(1)'
)
idum1
=
0
idum2
=
0
tokens
=
adate
%
split
(
'/'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment