mcollina / msgpack5

A msgpack v5 implementation for node.js, with extension points / msgpack.org[Node]
MIT License
492 stars 76 forks source link

Add support for encoding and decoding timestamp96 data #79

Closed kevygreen closed 3 years ago

kevygreen commented 5 years ago

When working with SignalR Core and MessagePack-CSharp this should now let you handle C#'s full range.

kevygreen commented 5 years ago

@mcollina This should resolve the build issues that were introduced in the PR #76 as well.

mcollina commented 5 years ago

New option timestamp96ThrowRangeEx to throw errors in invalid cases. Default behavior is to trim precision without throwing an error

Is this new option needed to solve the build issues?

kevygreen commented 5 years ago

The option timestamp96ThrowRangeEx is used to handle the behaviour of edge cases as I emailed you about:

JavaScript Date object doesn’t support the same range and precision as the msgPack timestamp 96. As such, what should happen if you try to deserialize a value that can’t be handled in a JavaScript Date?

Case 1 - Date too large/small Option 1 – Throw “out of range” exception Option 2 – Use Max/Min JavaScript Date (DEFAULT)

Case 2 - Nanoseconds too precise Option 1 – Throw “too precise” exception Option 2 – Round nanoseconds to the closest value (DEFAULT)

Case3 - Nanoseconds invalid e.g. > 999999999 Option 1 – Throw exception

mcollina commented 5 years ago

I'm going to land https://github.com/mcollina/msgpack5/pull/78 first. You might have to rebase afterwards.

mcollina commented 5 years ago

Would you mind rebasing? Sorry for this, the other one was waiting.