Skip to content

Conversation

addaleax
Copy link
Collaborator

@addaleax addaleax commented Apr 4, 2023

tsToSeconds() has not been working as intended since it was first written. BSON Timestamp objects never had direct t or i properties, so the if condition here would never be met. Instead, if the function received a Timestamp object, it would implicitly convert it to a number (via the Long class’s .toString() conversion method). This happens to work out because x/(2**32) corresponds roughly to the time part for a Timestamp object t when interpreted as a Long.

I am not sure why exactly this breaks in the way it does described in the ticket (where this function seems to return NaN), but making this function work as intended should address the issue.

`tsToSeconds()` has not been working as intended since it was first written. BSON `Timestamp` objects never had direct `t` or `i` properties, so the `if` condition here would never be met. Instead, if the function received a `Timestamp` object, it would implicitly convert it to a number (via the `Long` class’s `.toString()` conversion method). This happens to work out because `x/(2**32)` corresponds roughly to the time part for a `Timestamp` object `t` when interpreted as a `Long`. I am not sure why exactly this breaks in the way it does described in the ticket (where this function seems to return `NaN`), but making this function work as intended should address the issue.
@addaleax addaleax merged commit b766f26 into main Apr 4, 2023
@addaleax addaleax deleted the 1428-dev branch April 4, 2023 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants