fix microseconds leading zeroes - #277
Conversation
1. We have TIMESTAMPTZ field with value: '2023-07-31 16:19:49.91874' 2. if we map it to trantor::Date class and invoke ::toDbLocalString() it returns '2023-07-31 16:19:49.091874' The microseconds part is converted incorrectly, because 91874 is not equal to 091874. It should be '2023-07-31 16:19:49.918740'
|
I look at your pull request, as I use these functions in my program, and it will affect my program. I think, you have other problem in your code - data are broken somewhere between database and trantor::Date::toDbStringLocal(). You propose changes, that are not correct - they calculate wrong in opposite direction and fix previous error in code, but it will work wrong in all other programs, that does not have this first error. std::string testString = "2023-07-31 16:19:49.91874"; fromDbString and toDbString now has bug (I unintentional introduced it when sent other bug fix), I hope patch will be applied in nearest time. |
|
Ok, maybe my solution is wrong, but the obvious thing is, there is a bug regarding to time conversion to string. Steps to reproduce:
The result will be: "2023-07-31 16:19:49.091874" |
|
Sorry to say, but it is not obvious. On my computer everything works OK, I use Postgres 15.4 and latest commit from trantor (master HEAD). Could you check step 2: check by any tool, what exact value inserted into the table History? If problem with driver, error can be on this step. Could you check in debugger step 5:
|
|
We use Postgres 17 and encountered a similar problem. We have a TIMESTAMP column with a timezone. In DB it has value This obviously prevents correct usage of I believe @Baxulio is right that |
The microseconds part is converted incorrectly, because 91874 is not equal to 091874. It should be '2023-07-31 16:19:49.918740'
e.g. https://stackoverflow.com/questions/62937930/postgres-timestamp-with-microseconds