-
Couldn't load subscription status.
- Fork 767
Description
I'm just wondering why fromISO accepts pretty much every input while fromFormat need to match 100%:
//Why is this getting parsed?
const iso = DateTime.fromISO('11');
console.log(iso.toISO());
console.log(iso.isValid);
//Why is this *not* getting parsed?!
const input = DateTime.fromFormat('11', 'D');
console.log(input.toISO());
console.log(input.isValid);
(https://stackblitz.com/edit/vitejs-vite-3v4qvn)
I'm asking because (using Angular) I switched to Luxon and their implementation of the Luxon DateAdapter feels pretty broken: https://github.com/angular/components/blob/main/src/material-luxon-adapter/adapter/luxon-date-adapter.ts
But in the end it goes down to that question: why is fromISO so loose / fromFormat so restrictive? Is there an equivalent to old moments' strict: false? To would I need to loop over several input formats (from strict to loose) until the first one matches?
date-fns solved it quite handy: a default date can be passed to fill the missing positions.