fix: improper conversion of iso8601 date to unix timestamp #48
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What?
Fixes the
cog_iso8601_to_unix_ms
function to properly account for milliseconds in ISO8601 datesWhy?
Previously, the function was broken because the double
second
field was being cast to a uint_64 before being multiplied by 1000, thus the decimal was being rounded For example,54.043
was being cast to54
before being multiplied by 1000, thus the result was 54000 instead of 54043How?
The solution was to add parenthesis so that the multiplication happens before the casting.
Testing?
I tested my changes by creating another bot in discord.js and comparing the timestamps there with the timestamps generated by concord.
Screenshots (optional)
Here's what the behavior looked like before I made these changes (notice that Concord's timestamps are rounded to the nearest thousands):
Here's what the behavior is like after I made the changes: