Commit b4a6ef633a2408686f1ea64ca8399764554d616f

Authored by Benjamin Renard
1 parent b824cb30
Exists in master and in 1 other branch ubuntu

Fix time parsing with nanoseconds

src/DDClientLibC/DD_time.c
@@ -15,6 +15,7 @@ @@ -15,6 +15,7 @@
15 #include <stdio.h> 15 #include <stdio.h>
16 #include <string.h> 16 #include <string.h>
17 #include <stdarg.h> 17 #include <stdarg.h>
  18 +#include <math.h>
18 19
19 #define YEARS 70 20 #define YEARS 70
20 #define STARTYEAR 1970 21 #define STARTYEAR 1970
@@ -117,7 +118,8 @@ void SetIntNew(dd_tmstr_t *UT,t_DDTimeKind timeKind) /* Fill int values of dd_tm @@ -117,7 +118,8 @@ void SetIntNew(dd_tmstr_t *UT,t_DDTimeKind timeKind) /* Fill int values of dd_tm
117 UT->min = (int)(msrest / msofmin); 118 UT->min = (int)(msrest / msofmin);
118 msrest -= (double)(UT->min)*msofmin; 119 msrest -= (double)(UT->min)*msofmin;
119 UT->sec = (int)(msrest); 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 return; 123 return;
122 } 124 }
123 125
src/DDClientLibCpp/DD_time.cc
@@ -16,6 +16,7 @@ @@ -16,6 +16,7 @@
16 #include <stdio.h> 16 #include <stdio.h>
17 #include <string.h> 17 #include <string.h>
18 #include <stdarg.h> 18 #include <stdarg.h>
  19 +#include <math.h>
19 20
20 #define YEARS 70 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,7 +111,8 @@ void SetIntNew(dd_tmstr_t *UT,t_DDTimeKind timeKind) /* Fill int values of dd_tm
110 UT->min = (int)(msrest / msofmin); 111 UT->min = (int)(msrest / msofmin);
111 msrest -= (double)(UT->min)*msofmin; 112 msrest -= (double)(UT->min)*msofmin;
112 UT->sec = (int)(msrest); 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 return; 116 return;
115 } 117 }
116 118