@rivet-health/design-system 40.7.1 → 40.8.0
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.
- package/esm2020/lib/input/date/date.component.mjs +41 -10
- package/fesm2015/rivet-health-design-system.mjs +40 -9
- package/fesm2015/rivet-health-design-system.mjs.map +1 -1
- package/fesm2020/rivet-health-design-system.mjs +40 -9
- package/fesm2020/rivet-health-design-system.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -4308,18 +4308,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
|
|
|
4308
4308
|
'large',
|
|
4309
4309
|
'xlarge',
|
|
4310
4310
|
];
|
|
4311
|
-
// Accepts MM/DD/YYYY, M/D/YY, and YYYY-MM-DD with /, -, or . separators
|
|
4312
|
-
//
|
|
4311
|
+
// Accepts MM/DD/YYYY, M/D/YY, and YYYY-MM-DD with /, -, or . separators, as
|
|
4312
|
+
// well as separator-less digit runs (MMDDYYYY or MMDDYY). A 4-digit leading
|
|
4313
|
+
// segment in the separated form is treated as an ISO year; 2-digit years
|
|
4314
|
+
// pivot at 50 (<50 → 2000s, >=50 → 1900s).
|
|
4313
4315
|
function parseDate(input) {
|
|
4314
|
-
const
|
|
4315
|
-
if (
|
|
4316
|
+
const trimmed = input.trim();
|
|
4317
|
+
if (!trimmed)
|
|
4316
4318
|
return undefined;
|
|
4317
|
-
const
|
|
4318
|
-
|
|
4319
|
+
const ymd = /^\d+$/.test(trimmed)
|
|
4320
|
+
? parseDigits(trimmed)
|
|
4321
|
+
: parseSeparated(trimmed);
|
|
4322
|
+
if (!ymd)
|
|
4319
4323
|
return undefined;
|
|
4320
|
-
|
|
4321
|
-
if (parts[0].length !== 4 && year < 100)
|
|
4322
|
-
year += year < 50 ? 2000 : 1900;
|
|
4324
|
+
const [year, month, day] = ymd;
|
|
4323
4325
|
const date = new Date(year, month - 1, day);
|
|
4324
4326
|
return date.getFullYear() === year &&
|
|
4325
4327
|
date.getMonth() === month - 1 &&
|
|
@@ -4328,6 +4330,35 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
|
|
|
4328
4330
|
: undefined;
|
|
4329
4331
|
}
|
|
4330
4332
|
DateComponent.parseDate = parseDate;
|
|
4333
|
+
function expandTwoDigitYear(year) {
|
|
4334
|
+
return year < 100 ? year + (year < 50 ? 2000 : 1900) : year;
|
|
4335
|
+
}
|
|
4336
|
+
// A run of digits with no separators: 8 → MMDDYYYY (literal year), 6 → MMDDYY
|
|
4337
|
+
// (2-digit year pivoted at 50).
|
|
4338
|
+
function parseDigits(digits) {
|
|
4339
|
+
if (digits.length !== 8 && digits.length !== 6)
|
|
4340
|
+
return undefined;
|
|
4341
|
+
const year = parseInt(digits.slice(4), 10);
|
|
4342
|
+
return [
|
|
4343
|
+
digits.length === 6 ? expandTwoDigitYear(year) : year,
|
|
4344
|
+
parseInt(digits.slice(0, 2), 10),
|
|
4345
|
+
parseInt(digits.slice(2, 4), 10),
|
|
4346
|
+
];
|
|
4347
|
+
}
|
|
4348
|
+
function parseSeparated(input) {
|
|
4349
|
+
const parts = input.split(/[/.-]/);
|
|
4350
|
+
if (parts.length !== 3)
|
|
4351
|
+
return undefined;
|
|
4352
|
+
const nums = parts.map(p => parseInt(p, 10));
|
|
4353
|
+
if (nums.some(isNaN))
|
|
4354
|
+
return undefined;
|
|
4355
|
+
const [year, month, day] = parts[0].length === 4 ? nums : [nums[2], nums[0], nums[1]];
|
|
4356
|
+
return [
|
|
4357
|
+
parts[0].length === 4 ? year : expandTwoDigitYear(year),
|
|
4358
|
+
month,
|
|
4359
|
+
day,
|
|
4360
|
+
];
|
|
4361
|
+
}
|
|
4331
4362
|
function isValidDate(date, min, max) {
|
|
4332
4363
|
const time = date.getTime();
|
|
4333
4364
|
return time >= min.getTime() && time <= max.getTime();
|