@@ -10,22 +10,21 @@ program test_strptime
10
10
end type
11
11
12
12
interface
13
- integer (C_INT) function strptime(str,format ,tm) bind(C)
14
- import C_INT, C_CHAR, tm_struct
15
- character (kind= c_char ), intent (in ) :: str(* ), format (* )
13
+ function strptime (str ,format ,tm ) bind(C)
14
+ import
15
+ character (kind= C_CHAR ), intent (in ) :: str(* ), format (* )
16
16
type (tm_struct), intent (out ) :: tm
17
+ type (C_PTR) :: strptime
17
18
end function
18
19
end interface
19
20
20
- integer (C_INT ) :: rc
21
- character (kind= c_char , len= 20 ), parameter :: str = ' 2018-01-01 12:00:00'
22
- character (kind= c_char , len= 18 ), parameter :: fmt = ' %Y-%m-%d %H:%M:%S'
21
+ type (C_PTR ) :: rc
22
+ character (kind= C_CHAR , len= 20 ) :: str = ' 2018-01-01 12:00:00'
23
+ character (kind= C_CHAR , len= 18 ), parameter :: fmt = ' %Y-%m-%d %H:%M:%S' // c_null_char
23
24
type (tm_struct) :: tm
24
25
25
- rc = strptime(trim (str)// c_null_char, trim (fmt)// c_null_char, tm)
26
- if (rc == 0 ) then
27
- error stop " strptime failed"
28
- end if
26
+ rc = strptime(trim (str)// c_null_char, fmt, tm)
27
+ if (c_associated(rc, c_null_ptr)) error stop " strptime failed"
29
28
30
29
print ' (a3,1x,i4,1x,i2,1x,i2,1x,i2,1x,i2,1x,i2)' , " OK:" , &
31
30
tm% tm_year+1900 , tm% tm_mon+1 , tm% tm_mday, tm% tm_hour, tm% tm_min, tm% tm_sec
0 commit comments