You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By doing so, it adds additional precision which might result in a wrongly rounded number.
To Reproduce
While working on something totally different within icinga-notifications when I realized that my times.UnixMilli-based comparison simply didn't made any sense. After lots of debugging and enabling PostgreSQL's debug logs, I found an off-by-one issue with my timestamps and was able to reproduce it by adding another test case to TestUnixMilli_MarshalJSON.
Describe the bug
The
utils.FromUnixMilli
helper function internally converts the integer to a float and back again.icingadb/pkg/utils/utils.go
Line 24 in 9c2dcd2
By doing so, it adds additional precision which might result in a wrongly rounded number.
To Reproduce
While working on something totally different within icinga-notifications when I realized that my
times.UnixMilli
-based comparison simply didn't made any sense. After lots of debugging and enabling PostgreSQL's debug logs, I found an off-by-one issue with my timestamps and was able to reproduce it by adding another test case toTestUnixMilli_MarshalJSON
.Running this test results in an error, returning a number off by one.
Or, making it even more obvious by creating a test for
utils.FromUnixMilli
:Expected behavior
No additional floating point precision should be added and later cut off while being cast back to an integer.
Your Environment
Include as many relevant details about the environment you experienced the problem in
main
Additional context
#744 and #747 might solve this by switching to Go's native
time.UnixMilli
.The text was updated successfully, but these errors were encountered: