Commit b4a6ef633a2408686f1ea64ca8399764554d616f
1 parent
b824cb30
Exists in
master
and in
1 other branch
Fix time parsing with nanoseconds
Showing
2 changed files
with
6 additions
and
2 deletions
Show diff stats
src/DDClientLibC/DD_time.c
... | ... | @@ -15,6 +15,7 @@ |
15 | 15 | #include <stdio.h> |
16 | 16 | #include <string.h> |
17 | 17 | #include <stdarg.h> |
18 | +#include <math.h> | |
18 | 19 | |
19 | 20 | #define YEARS 70 |
20 | 21 | #define STARTYEAR 1970 |
... | ... | @@ -117,7 +118,8 @@ void SetIntNew(dd_tmstr_t *UT,t_DDTimeKind timeKind) /* Fill int values of dd_tm |
117 | 118 | UT->min = (int)(msrest / msofmin); |
118 | 119 | msrest -= (double)(UT->min)*msofmin; |
119 | 120 | UT->sec = (int)(msrest); |
120 | - UT->msec = (int)((msrest - (double)(UT->sec))*1000.0); | |
121 | + double msec = (msrest - (double)(UT->sec))*1000.0; | |
122 | + UT->msec = (int)msec; | |
121 | 123 | return; |
122 | 124 | } |
123 | 125 | ... | ... |
src/DDClientLibCpp/DD_time.cc
... | ... | @@ -16,6 +16,7 @@ |
16 | 16 | #include <stdio.h> |
17 | 17 | #include <string.h> |
18 | 18 | #include <stdarg.h> |
19 | +#include <math.h> | |
19 | 20 | |
20 | 21 | #define YEARS 70 |
21 | 22 | |
... | ... | @@ -110,7 +111,8 @@ void SetIntNew(dd_tmstr_t *UT,t_DDTimeKind timeKind) /* Fill int values of dd_tm |
110 | 111 | UT->min = (int)(msrest / msofmin); |
111 | 112 | msrest -= (double)(UT->min)*msofmin; |
112 | 113 | UT->sec = (int)(msrest); |
113 | - UT->msec = (int)((msrest - (double)(UT->sec))*1000.0); | |
114 | + double msec = (msrest - (double)(UT->sec))*1000.0; | |
115 | + UT->msec = round(msec); | |
114 | 116 | return; |
115 | 117 | } |
116 | 118 | ... | ... |