diff options
author | drh <> | 2025-01-21 17:37:58 +0000 |
---|---|---|
committer | drh <> | 2025-01-21 17:37:58 +0000 |
commit | 255548562b125e6c148bb27d49aaa01b2fe61dba (patch) | |
tree | 7fa27a5ea65dc7c683b6955e5dc32beac74f031d /src | |
parent | 8e7a16895c62f8c56e8ada82cecdacaf1e97fcd3 (diff) | |
download | sqlite-255548562b125e6c148bb27d49aaa01b2fe61dba.tar.gz sqlite-255548562b125e6c148bb27d49aaa01b2fe61dba.zip |
Fix date/time computations to deal with the sub-millisecond rounding
problem identified in [forum:/forumpost/766a2c9231|forum post 766a2c9231].
FossilOrigin-Name: afb0a5923a6db4045fab5226198aab970d746d4866294ebba943c6986e97ecde
Diffstat (limited to 'src')
-rw-r--r-- | src/date.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/date.c b/src/date.c index 8c48a81fa..de2736637 100644 --- a/src/date.c +++ b/src/date.c @@ -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; } |