Throws on invalid dates
See original GitHub issue> require('msgpackr').encode(new Date('invalid'))
Uncaught:
RangeError: The number NaN cannot be converted to a BigInt because it is not an integer
at BigInt (<anonymous>)
at Packr.pack (.../node_modules/msgpackr/dist/node.cjs:1627:41)
at pack (.../node_modules/msgpackr/dist/node.cjs:1355:34)
at Object.Packr.pack.encode (.../node_modules/msgpackr/dist/node.cjs:1101:5)
> require('cbor-x').encode(new Date('invalid'))
<Buffer c1 fb 7f f8 00 00 00 00 00 00>
> require('@msgpack/msgpack').encode(new Date('invalid'))
Uint8Array(15) [
199, 12, 255, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0
]
> require('msgpack-lite').encode(new Date('invalid'))
<Buffer c7 09 0d cb 7f f8 00 00 00 00 00 00>
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How to throw an error whenever an invalid date object is ...
Create a factory type function which throws an error if the string given produces an invalid date, but returns the date if it's...
Read more >RangeError: invalid date - JavaScript - MDN Web Docs
The JavaScript exception "invalid date" occurs when a string leading to an invalid date has been provided to Date or Date.parse() .
Read more >Throw an error on invalid dates #455 - moment/luxon - GitHub
Is there a way to have luxon throw Errors when parsing invalid dates? The text was updated successfully, but these errors were encountered: ......
Read more >new Date("2018-06-19") throws invalid date error - ServiceNow
I am reading the date from a variable as this. Ideally it should be supported, just not sure why it's not.
Read more >Invalid date/time issue in Apex Code
In the apex class, I am trying to populate this date on the Asset object. Below is my code. Datetime effectiveDt = Datetime.parse(wsResponse....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, a better error message certainly seems appropriate. I can certainly just come up with a invalid date representation. It probably would be reasonable to use the MessagePack timestamp code (-1), with zero length data to represent an invalid date. And would probably use a flag for this since it seems like most users prefer predictable fail-fast behavior. But this is a good suggestion, I will take a look at this.
Published in v1.5.1