Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libmtime
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
icon-libraries
libmtime
Commits
1be5926b
Commit
1be5926b
authored
6 years ago
by
Florian Prill
Browse files
Options
Downloads
Patches
Plain Diff
catch invalid dates when transforming them into strings.
parent
32690d93
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/example_hl.f90
+19
-16
19 additions, 16 deletions
examples/example_hl.f90
src/libmtime_hl.f90
+16
-11
16 additions, 11 deletions
src/libmtime_hl.f90
with
35 additions
and
27 deletions
examples/example_hl.f90
+
19
−
16
View file @
1be5926b
...
...
@@ -11,7 +11,7 @@ PROGRAM example
TYPE
(
t_juliandelta
)
::
jd
TYPE
(
divisionquotienttimespan
)
::
dqts
CHARACTER
(
LEN
=*
),
PARAMETER
::
ERR_UNCAUGHT
=
"!!!!!!!!!
error was not caught
!!!!!!!"
CHARACTER
(
LEN
=*
),
PARAMETER
::
ERR_UNCAUGHT
=
"!!!!!!!!!
ERROR WAS NOT CAUGHT
!!!!!!!"
INTEGER
::
test_number1
,
test_number2
,
test_result
LOGICAL
::
lerror
CHARACTER
(
c_char
)
::
c_sign
...
...
@@ -88,42 +88,45 @@ PROGRAM example
CALL
register_finish_mtime_procedure
(
error_callback
)
! produce errors
WRITE
(
0
,
*
)
'
ERROR TEST
: dt = t_datetime("1970--01-01T00:00:00")'
WRITE
(
0
,
*
)
'
error test
: dt = t_datetime("1970--01-01T00:00:00")'
lerror
=
.FALSE.
dt
=
t_datetime
(
"1970--01-01T00:00:00"
)
IF
(
.NOT.
lerror
)
WRITE
(
0
,
*
)
ERR_UNCAUGHT
WRITE
(
0
,
*
)
'ERROR TEST: dt = dt5'
lerror
=
.FALSE.
dt
=
dt5
IF
(
.NOT.
lerror
)
WRITE
(
0
,
*
)
ERR_UNCAUGHT
! The following test cannot be handled since we removed
! the explicit "assign" implementation:
!
! WRITE (0,*) 'error test: dt = dt5'
! lerror = .FALSE.
! dt = dt5
! IF (.NOT. lerror) WRITE(0,*) ERR_UNCAUGHT
WRITE
(
0
,
*
)
'
ERROR TEST
: dt5%toString()'
WRITE
(
0
,
*
)
'
error test
: dt5%toString()'
lerror
=
.FALSE.
WRITE
(
0
,
*
)
dt5
%
toString
()
IF
(
.NOT.
lerror
)
WRITE
(
0
,
*
)
ERR_UNCAUGHT
WRITE
(
0
,
*
)
'
ERROR TEST
: dt5%to_posix_string()'
WRITE
(
0
,
*
)
'
error test
: dt5%to_posix_string()'
lerror
=
.FALSE.
WRITE
(
0
,
*
)
dt5
%
toString
(
"%s%d%LK"
)
IF
(
.NOT.
lerror
)
WRITE
(
0
,
*
)
ERR_UNCAUGHT
WRITE
(
0
,
*
)
'
ERROR TEST
: dt = dt + td2'
WRITE
(
0
,
*
)
'
error test
: dt = dt + td2'
lerror
=
.FALSE.
dt
=
dt
+
td2
IF
(
.NOT.
lerror
)
WRITE
(
0
,
*
)
ERR_UNCAUGHT
WRITE
(
0
,
*
)
'
ERROR TEST
: dt = dt - td2'
WRITE
(
0
,
*
)
'
error test
: dt = dt - td2'
lerror
=
.FALSE.
dt
=
dt
-
td2
IF
(
.NOT.
lerror
)
WRITE
(
0
,
*
)
ERR_UNCAUGHT
WRITE
(
0
,
*
)
'
ERROR TEST
: dt = dt - td2'
WRITE
(
0
,
*
)
'
error test
: dt = dt - td2'
lerror
=
.FALSE.
dt
=
dt
-
td2
IF
(
.NOT.
lerror
)
WRITE
(
0
,
*
)
ERR_UNCAUGHT
WRITE
(
0
,
*
)
'
ERROR TEST
: td = t_timedelta(...)'
WRITE
(
0
,
*
)
'
error test
: td = t_timedelta(...)'
lerror
=
.FALSE.
td
=
t_timedelta
(
"P1lK"
)
IF
(
.NOT.
lerror
)
WRITE
(
0
,
*
)
ERR_UNCAUGHT
...
...
@@ -132,18 +135,18 @@ PROGRAM example
WRITE
(
0
,
*
)
"t_timedeltaFromMilliseconds(HUGE(INT(1))) : HUGE(INT(1)) = "
,
HUGE
(
INT
(
1
))
WRITE
(
0
,
*
)
"td%toString() = "
,
td
%
toString
()
WRITE
(
0
,
*
)
'
ERROR TEST
: td = td * 0.000001D0'
WRITE
(
0
,
*
)
'
error test
: td = td * 0.000001D0'
WRITE
(
0
,
*
)
'td%toString() = '
,
td
%
toString
()
lerror
=
.FALSE.
td
=
td
*
0.000001D0
IF
(
.NOT.
lerror
)
WRITE
(
0
,
*
)
ERR_UNCAUGHT
WRITE
(
0
,
*
)
'
ERROR TEST
: td2 = td2 * 1'
WRITE
(
0
,
*
)
'
error test
: td2 = td2 * 1'
lerror
=
.FALSE.
td2
=
td2
*
1
IF
(
.NOT.
lerror
)
WRITE
(
0
,
*
)
ERR_UNCAUGHT
WRITE
(
0
,
*
)
'
ERROR TEST
: td2%toString()'
WRITE
(
0
,
*
)
'
error test
: td2%toString()'
lerror
=
.FALSE.
WRITE
(
0
,
*
)
'td2%toString() = '
,
td2
%
toString
()
IF
(
.NOT.
lerror
)
WRITE
(
0
,
*
)
ERR_UNCAUGHT
...
...
@@ -153,7 +156,7 @@ PROGRAM example
c_sign
=
'+'
jd
=
t_juliandelta
(
sign
=
c_sign
,
day
=
99_c_int64_t
,
ms
=
123_c_int64_t
)
WRITE
(
0
,
*
)
"
ERROR TEST
: jd = t_juliandelta(sign='r', day='99', ms='123')"
WRITE
(
0
,
*
)
"
error test
: jd = t_juliandelta(sign='r', day='99', ms='123')"
lerror
=
.FALSE.
c_sign
=
'r'
jd
=
t_juliandelta
(
sign
=
c_sign
,
day
=
99_c_int64_t
,
ms
=
123_c_int64_t
)
...
...
This diff is collapsed.
Click to expand it.
src/libmtime_hl.f90
+
16
−
11
View file @
1be5926b
...
...
@@ -90,7 +90,8 @@ MODULE mtime_hl
!private
!> wrapped datatype of the standard mtime interface
TYPE
(
datetime
)
::
dt
TYPE
(
datetime
)
::
dt
=
datetime
(
date
(
year
=
0_c_int64_t
,
month
=
0_c_int
,
day
=
0_c_int
),&
&
time
(
hour
=
0_c_int
,
minute
=
0_c_int
,
second
=
0_c_int
,
ms
=
0_c_int
))
CONTAINS
...
...
@@ -153,7 +154,10 @@ MODULE mtime_hl
!private
!> wrapped datatype of the standard mtime interface
TYPE
(
timedelta
)
::
td
TYPE
(
timedelta
)
::
td
=
timedelta
(
flag_std_form
=
0_c_int
,
sign
=
'+'
,
year
=
0_c_int64_t
,
&
&
month
=
0_c_int
,
day
=
0_c_int
,
hour
=
0_c_int
,
&
&
minute
=
0_c_int
,
second
=
0_c_int
,
ms
=
0_c_int
)
CONTAINS
...
...
@@ -452,10 +456,13 @@ CONTAINS
FUNCTION
t_datetime_toString
(
this
)
result
(
string
)
CHARACTER
(
len
=
max_datetime_str_len
)
::
string
CLASS
(
t_datetime
)
::
this
type
(
c_ptr
)
::
c_pointer
,
dummy_ptr
integer
::
i
string
=
""
c_pointer
=
this
%
get_c_pointer
()
CALL
handle_errno
(
.not.
c_associated
(
c_pointer
),
0
*
100
+
2
,
__
FILE__
,
__
LINE__
)
dummy_ptr
=
my_datetimetostring
(
c_pointer
,
string
)
CALL
handle_errno
(
.not.
c_associated
(
dummy_ptr
),
4
*
100
+
6
,
__
FILE__
,
__
LINE__
)
...
...
@@ -475,8 +482,9 @@ CONTAINS
CLASS
(
t_datetime
)
::
this
integer
::
i
type
(
c_ptr
)
::
c_pointer
,
dummy_ptr
c_pointer
=
this
%
get_c_pointer
()
string
=
""
c_pointer
=
this
%
get_c_pointer
()
dummy_ptr
=
my_datetoposixstring
(
c_pointer
,
string
,
format_string
)
CALL
handle_errno
(
.not.
c_associated
(
dummy_ptr
),
2
*
100
+
8
,
__
FILE__
,
__
LINE__
)
char_loop
:
do
i
=
1
,
len
(
string
)
...
...
@@ -1205,13 +1213,10 @@ CONTAINS
FUNCTION
t_datetime_get_c_pointer
(
this
)
RESULT
(
c_pointer
)
TYPE
(
c_ptr
)
::
c_pointer
CLASS
(
t_datetime
)
::
this
TYPE
(
datetime
),
POINTER
::
datetime_pointer
datetime_pointer
=>
newDatetime
(
"0001-01-01T00:00:00"
)
datetime_pointer
=
this
%
dt
c_pointer
=
C_LOC
(
datetime_pointer
)
c_pointer
=
my_newrawdatetime
(
int
(
this
%
dt
%
date
%
year
,
c_int64_t
),
this
%
dt
%
date
%
month
,
&
&
this
%
dt
%
date
%
day
,
this
%
dt
%
time
%
hour
,
this
%
dt
%
time
%
minute
,
&
&
this
%
dt
%
time
%
second
,
this
%
dt
%
time
%
ms
)
call
handle_errno
((
.not.
c_associated
(
c_pointer
)),
4
*
100
+
3
,
__
FILE__
,
__
LINE__
)
END
FUNCTION
t_datetime_get_c_pointer
FUNCTION
t_timedelta_get_c_pointer
(
this
)
RESULT
(
c_pointer
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment