@ai-matrx/records 0.81.1 → 0.81.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -596,7 +596,32 @@ function readTypedDate(raw, opts = {}) {
596
596
  let month = null;
597
597
  let day = null;
598
598
  const numeric = /^(\d{1,4})[/.\-](\d{1,2})[/.\-](\d{1,4})$/.exec(dateText);
599
- if (numeric) {
599
+ const compact = /^(\d{8}|\d{6})$/.exec(dateText);
600
+ if (compact) {
601
+ const digits = compact[1];
602
+ const order = localeDateOrder(opts.locale);
603
+ const first2 = Number(digits.slice(0, 2));
604
+ const mid2 = Number(digits.slice(2, 4));
605
+ if (digits.length === 6) {
606
+ year = twoDigitYear(Number(digits.slice(4)));
607
+ if (order === "dmy") {
608
+ day = first2;
609
+ month = mid2;
610
+ } else {
611
+ month = first2;
612
+ day = mid2;
613
+ }
614
+ } else {
615
+ const yearLast = Number(digits.slice(4));
616
+ const yearFirst = Number(digits.slice(0, 4));
617
+ const localeReading = () => order === "dmy" ? [yearLast, mid2, first2] : [yearLast, first2, mid2];
618
+ const [ly, lm, ld] = localeReading();
619
+ const isoReading = [yearFirst, Number(digits.slice(4, 6)), Number(digits.slice(6))];
620
+ const fits = (y, m, d) => checkDay(y, m, d, raw) === null;
621
+ const useIso = order === "ymd" || !fits(ly, lm, ld) && fits(...isoReading);
622
+ [year, month, day] = useIso ? isoReading : [ly, lm, ld];
623
+ }
624
+ } else if (numeric) {
600
625
  const [a, b, c] = [numeric[1], numeric[2], numeric[3]];
601
626
  if (a.length === 4) {
602
627
  year = Number(a);