@aemforms/af-formatters 0.22.90 → 0.22.92
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/esm/afb-formatters.js +3 -5
- package/lib/date/DateParser.js +21 -21
- package/package.json +1 -1
package/esm/afb-formatters.js
CHANGED
|
@@ -360,7 +360,6 @@ function parseDate(dateString, language, skeleton, timeZone, bUseUTC = false) {
|
|
|
360
360
|
let hourCycle = 'h12';
|
|
361
361
|
let _bUseUTC = bUseUTC;
|
|
362
362
|
let _setFullYear = false;
|
|
363
|
-
const isSeparator = str => str.length === 1 && ':-/.'.includes(str);
|
|
364
363
|
const monthNumber = str => getNumber(str) - 1;
|
|
365
364
|
const getNumber = str => str.split('').reduce((total, digit) => (total * 10) + digits.indexOf(digit), 0);
|
|
366
365
|
const yearNumber = templateDigits => str => {
|
|
@@ -377,8 +376,7 @@ function parseDate(dateString, language, skeleton, timeZone, bUseUTC = false) {
|
|
|
377
376
|
const months = monthNames(language, Object.fromEntries(parsed));
|
|
378
377
|
parsed.forEach(([option, value, len]) => {
|
|
379
378
|
if (option === 'literal') {
|
|
380
|
-
|
|
381
|
-
else regexParts.push(value);
|
|
379
|
+
regexParts.push(value);
|
|
382
380
|
} else if (option === 'month' && ['numeric', '2-digit'].includes(value)) {
|
|
383
381
|
regexParts.push(twoDigit);
|
|
384
382
|
lookups.push(['month', monthNumber]);
|
|
@@ -430,9 +428,9 @@ function parseDate(dateString, language, skeleton, timeZone, bUseUTC = false) {
|
|
|
430
428
|
}
|
|
431
429
|
return regexParts;
|
|
432
430
|
}, []);
|
|
433
|
-
const regex = new RegExp(regexParts.join(''));
|
|
431
|
+
const regex = new RegExp(`^${regexParts.join('')}$`);
|
|
434
432
|
const match = dateString.match(regex);
|
|
435
|
-
if (match === null) return
|
|
433
|
+
if (match === null) return null;
|
|
436
434
|
const dateObj = {year: 1972, month: 0, day: 1, hour: 0, minute: 0, second: 0, fractionalSecondDigits: 0};
|
|
437
435
|
match.slice(1).forEach((m, index) => {
|
|
438
436
|
const [element, func] = lookups[index];
|
package/lib/date/DateParser.js
CHANGED
|
@@ -15,24 +15,24 @@ exports.parseDefaultDate = parseDefaultDate;
|
|
|
15
15
|
var _SkeletonParser = require("./SkeletonParser.js");
|
|
16
16
|
|
|
17
17
|
/*************************************************************************
|
|
18
|
-
* ADOBE CONFIDENTIAL
|
|
19
|
-
* ___________________
|
|
20
|
-
*
|
|
21
|
-
* Copyright 2022 Adobe
|
|
22
|
-
* All Rights Reserved.
|
|
23
|
-
*
|
|
24
|
-
* NOTICE: All information contained herein is, and remains
|
|
25
|
-
* the property of Adobe and its suppliers, if any. The intellectual
|
|
26
|
-
* and technical concepts contained herein are proprietary to Adobe
|
|
27
|
-
* and its suppliers and are protected by all applicable intellectual
|
|
28
|
-
* property laws, including trade secret and copyright laws.
|
|
29
|
-
* Dissemination of this information or reproduction of this material
|
|
30
|
-
* is strictly forbidden unless prior written permission is obtained
|
|
31
|
-
* from Adobe.
|
|
32
|
-
|
|
33
|
-
* Adobe permits you to use and modify this file solely in accordance with
|
|
34
|
-
* the terms of the Adobe license agreement accompanying it.
|
|
35
|
-
*************************************************************************/
|
|
18
|
+
* ADOBE CONFIDENTIAL
|
|
19
|
+
* ___________________
|
|
20
|
+
*
|
|
21
|
+
* Copyright 2022 Adobe
|
|
22
|
+
* All Rights Reserved.
|
|
23
|
+
*
|
|
24
|
+
* NOTICE: All information contained herein is, and remains
|
|
25
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
26
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
27
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
28
|
+
* property laws, including trade secret and copyright laws.
|
|
29
|
+
* Dissemination of this information or reproduction of this material
|
|
30
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
31
|
+
* from Adobe.
|
|
32
|
+
|
|
33
|
+
* Adobe permits you to use and modify this file solely in accordance with
|
|
34
|
+
* the terms of the Adobe license agreement accompanying it.
|
|
35
|
+
*************************************************************************/
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* Credit: https://git.corp.adobe.com/dc/dfl/blob/master/src/patterns/dates.js
|
|
@@ -427,7 +427,7 @@ function parseDate(dateString, language, skeleton, timeZone) {
|
|
|
427
427
|
// use a generic regex pattern for all single-character separator literals.
|
|
428
428
|
// Then we'll be forgiving when it comes to separators: / vs - vs : etc
|
|
429
429
|
if (option === 'literal') {
|
|
430
|
-
|
|
430
|
+
regexParts.push(value);
|
|
431
431
|
} else if (option === 'month' && ['numeric', '2-digit'].includes(value)) {
|
|
432
432
|
regexParts.push(twoDigit);
|
|
433
433
|
lookups.push(['month', monthNumber]);
|
|
@@ -486,9 +486,9 @@ function parseDate(dateString, language, skeleton, timeZone) {
|
|
|
486
486
|
|
|
487
487
|
return regexParts;
|
|
488
488
|
}, []);
|
|
489
|
-
const regex = new RegExp(regexParts.join(''));
|
|
489
|
+
const regex = new RegExp(`^${regexParts.join('')}$`);
|
|
490
490
|
const match = dateString.match(regex);
|
|
491
|
-
if (match === null) return
|
|
491
|
+
if (match === null) return null; // now loop through all the matched pieces and build up an object we'll use to create a Date object
|
|
492
492
|
|
|
493
493
|
const dateObj = {
|
|
494
494
|
year: 1972,
|