Commit 6417a08a authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

cdiDecodeTimevalue: fix rounding error for negativ timevalue

parent 7a208768
2015-03-12 Uwe Schulzweida
2015-03-26 Uwe Schulzweida
* Version 1.6.8 released
* using CGRIBEX library version 1.7.1
2015-02-18 Uwe Schulzweida
* cdiDecodeTimevalue: fix rounding error for negativ timevalue
2015-02-12 Uwe Schulzweida
* scan netcdf time units attribute (bug fix)
......
......@@ -941,7 +941,8 @@ void cdiDecodeTimevalue(int timeunit, double timevalue, int *days, int *secs)
if ( timeunit == TUNIT_SECOND )
{
*days = (int) (timevalue/86400);
*secs = (int) (timevalue - *days*86400. + 0.5);
double seconds = timevalue - *days*86400.;
*secs = lround(seconds);
if ( *secs < 0 ) { *days -= 1; *secs += 86400; };
/*
{
......@@ -954,7 +955,8 @@ void cdiDecodeTimevalue(int timeunit, double timevalue, int *days, int *secs)
else if ( timeunit == TUNIT_DAY )
{
*days = (int) timevalue;
*secs = (int) ((timevalue - *days)*86400 + 0.5);
double seconds = (timevalue - *days)*86400;
*secs = lround(seconds);
if ( *secs < 0 ) { *days -= 1; *secs += 86400; };
/*
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment