1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00

Fix date/time computations to deal with the sub-millisecond rounding

problem identified in [forum:/forumpost/766a2c9231|forum post 766a2c9231].

FossilOrigin-Name: afb0a5923a6db4045fab5226198aab970d746d4866294ebba943c6986e97ecde
This commit is contained in:
drh
2025-01-21 17:37:58 +00:00
parent 8e7a16895c
commit 255548562b
4 changed files with 20 additions and 9 deletions

View File

@@ -222,6 +222,9 @@ static int parseHhMmSs(const char *zDate, DateTime *p){
zDate++;
}
ms /= rScale;
/* Truncate to avoid problems with sub-milliseconds
** rounding. https://sqlite.org/forum/forumpost/766a2c9231 */
if( ms>0.999 ) ms = 0.999;
}
}else{
s = 0;
@@ -1429,7 +1432,7 @@ static void strftimeFunc(
}
case 'f': { /* Fractional seconds. (Non-standard) */
double s = x.s;
if( s>59.999 ) s = 59.999;
if( NEVER(s>59.999) ) s = 59.999;
sqlite3_str_appendf(&sRes, "%06.3f", s);
break;
}