Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@mrdomino
Copy link
Contributor

Fixes #4598.

#4474 made the JSON time conversion no longer invertible, which caused
problems for chat, which uses message timestamp in milliseconds as a key
— so chat would send a message with ms timestamp x, it would get
encoded as @da x, but then when it went back through the conversion to
milliseconds, it would often (not always) get encoded as x-1.

I still do not fully understand why this is — and why it doesn't seem
to be a problem with seconds based on cursory testing — but integer
multiplication and division generally do not invert. And adding a half a
millisecond to the input date before converting it resolves the issue
and makes the functions invertible.

I added a regression test, so hopefully the next courageous adventurer
who winds up here after wondering why +unm looks funny will have a
safeguard against some of the mistakes I made.

Fixes #4598.

#4474 made the JSON time conversion no longer invertible, which caused
problems for chat, which uses message timestamp in milliseconds as a key
-- so chat would send a message with ms timestamp x, it would get
encoded as @da x, but then when it went back through the conversion to
milliseconds, it would often (not always) get encoded as x-1.

I still do not fully understand why this is -- and why it doesn't seem
to be a problem with seconds based on cursory testing -- but integer
multiplication and division generally do not invert. And adding a half a
millisecond to the input date before converting it resolves the issue
and makes the functions invertible.

I added a regression test, so hopefully the next courageous adventurer
who winds up here after wondering why +unm looks funny will have a
safeguard against some of the mistakes I made.
Copy link
Collaborator

@joemfb joemfb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mrdomino
Copy link
Contributor Author

Do we want this on master or next-sys?

@joemfb
Copy link
Collaborator

joemfb commented Mar 13, 2021

release/next-sys

@mrdomino mrdomino changed the base branch from master to release/next-sys March 13, 2021 03:26
@mrdomino mrdomino merged commit 3869498 into release/next-sys Mar 13, 2021
@mrdomino mrdomino deleted the jo/zuse-time-unfix branch March 13, 2021 03:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

unm:chrono:userlib and from-unix-ms:chrono:userlib are sometimes not invertible

3 participants