hildjj / node-cbor

Encode and decode CBOR documents, with both easy mode, streaming mode, and SAX-style evented mode.
MIT License
356 stars 73 forks source link

Loss of Precision when Parsing Date Strings #146

Closed JesusMcCloud closed 3 years ago

JesusMcCloud commented 3 years ago

Date Strings can represent timestamps with nanosecond-precision, while JS's date class cannot. This GH-145 addresses this issue and returns date strings verbatim

hildjj commented 3 years ago

As a work-around, you can use code like this:

cbor.decodeFirstSync(input, {
  tags: {
    0: x => x
  }
})

which may be more concise than adding a preference.

JesusMcCloud commented 3 years ago

Thanks for the support! This works well for our case. Maybe even a note in the README would suffice, given how easy it si to deal with it?

hildjj commented 3 years ago

See the text I added at https://github.com/hildjj/node-cbor/pull/147/files#diff-358273ba3280ca05870b503d54d3908dca434851fab72f89bceac10784ccb0a4R236 and either comment on the PR or here, please.

JesusMcCloud commented 3 years ago

Perfect, thanks for all the help! In my opinion GH-147 fixes this, as the behaviour is clearly documented.