dmtrKovalenko / date-io

Abstraction over common javascript date management libraries
MIT License
726 stars 90 forks source link

Improving js-joda support #627

Open joshkel opened 2 years ago

joshkel commented 2 years ago

I'm looking at using the js-joda adapters with the MUI date/time pickers and am running into limitations: js-joda provides several date/time classes, but @date-io/js-joda only supports a few of them. (See here for a good overview of the Java Joda-Time API; js-joda is modeled off of that.)

I'm happy to work on a PR to improve this but wasn't sure about date-io's error-handling philosophy:

To pick a concrete example: How should isAfter work if it's asked to compare a js-joda LocalDate (a date with no time specified) with a LocalTime (a time of day with no date specified)?

  1. Explicitly return false, since they aren't comparable, similar to how NaN !== NaN?
  2. Fall through to return undefined, indicating that there's a potential hole in @date-io/js-joda's abstraction over js-joda?
  3. Throw an exception, since that's what js-joda itself would do if you compared a LocalDate to a LocalTime?
  4. Something I'm not thinking of?

If you can provide some guidance on how to handle these interface mismatches and how errors ought to be handled within date-io, I can try to put together a PR to extend @date-io/js-joda accordingly. Thanks!