JohnWeisz / TypedJSON

Typed JSON parsing and serializing for TypeScript that preserves type information.
MIT License
603 stars 64 forks source link

Fix bug with timestamp before epoch #143

Closed MatthiasKunnen closed 4 years ago

MatthiasKunnen commented 4 years ago

Deserializing a date with a negative timestamp (dates before 1970-01-01) caused rejection due to a combination of bad isInteger checking and an unneeded greater than zero check.

I checked and Firefox, Chrome, nor Node seem to have a problem with creating dates from timestamps with decimal places. This means that the isInteger check is not necessarily needed. I don't have a preference towards keeping it or not keeping it.

MatthiasKunnen commented 4 years ago

@Neos3452, PR updated and ready

Neos3452 commented 4 years ago

MDN and the spec says that only integer part matters so I think an error is fine there. https://tc39.es/ecma262/#sec-date-value