Skip to content
Snippets Groups Projects
Commit 95ab9af7 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

cdiDecodeTimevalue: fix rounding error for negativ timevalue

parent f334dad2
No related branches found
No related tags found
No related merge requests found
......@@ -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; };
/*
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment