Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #24: Support for Js.Date.t #61

Closed

Conversation

alfonsogarciacaro
Copy link

Fix #24. I'm using Js.Date.toJSONUnsafe for encoding following bs-json but please let me know if you prefer to use toISOString instead.

Thanks a lot for the ppx!

let date =
Js.Json.decodeString(j)->Belt.Option.getExn->Js.Date.fromString;
if (Js.Float.isNaN(Js.Date.getTime(date))) {
failwith("NaN");
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be Belt.Result.Error instead, using Result would make the error propagate to the parent and won't crash at runtime.

@alfonsogarciacaro
Copy link
Author

Hi @davesnx, thanks a lot for the review! Unfortunately I'm not working with ReasonML anymore and I forgot about this 😅 I'm closing the PR, but please feel free to take it over if the code is still useful.

@davesnx
Copy link
Contributor

davesnx commented Mar 8, 2021

Hey @alfonsogarciacaro, no worries the code is still useful for sure.

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.

Support Js.Date.t
2 participants