Skip to content

Commit 7b3e66c

Browse files
committed
strptime actual check values
1 parent 6cd1b10 commit 7b3e66c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

test/time/strptime.f90

+9-3
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,20 @@ function strptime(str,format,tm) bind(C)
1919
end interface
2020

2121
type(C_PTR) :: rc
22-
character(kind=C_CHAR, len=20) :: str = '2018-01-01 12:00:00'
22+
character(kind=C_CHAR, len=20) :: str = '2018-01-02 12:05:15'
2323
character(kind=C_CHAR, len=18), parameter :: fmt = '%Y-%m-%d %H:%M:%S' // c_null_char
2424
type(tm_struct) :: tm
2525

2626
rc = strptime(trim(str)// c_null_char, fmt, tm)
2727
if(c_associated(rc, c_null_ptr)) error stop "strptime failed"
2828

29-
print '(a3,1x,i4,1x,i2,1x,i2,1x,i2,1x,i2,1x,i2)', "OK:", &
30-
tm%tm_year+1900, tm%tm_mon+1, tm%tm_mday, tm%tm_hour, tm%tm_min, tm%tm_sec
29+
if (tm%tm_year /= 118) error stop "tm_year /= 2018"
30+
if (tm%tm_mon /= 0) error stop "tm_mon /= 0+1"
31+
if (tm%tm_mday /= 2) error stop "tm_mday /= 2"
32+
if (tm%tm_hour /= 12) error stop "tm_hour /= 12"
33+
if (tm%tm_min /= 5) error stop "tm_min /= 0"
34+
if (tm%tm_sec /= 15) error stop "tm_sec /= 15"
35+
36+
print '(a)', "OK: strptime"
3137

3238
end program

0 commit comments

Comments
 (0)