Skip to content

Commit 7bea75b

Browse files
JAMSUPREMEmattbaileyuk
authored andcommittedNov 2, 2021
MandatoryDigits notes
1 parent 3dae0e6 commit 7bea75b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed
 

‎src/datetime.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1025,8 +1025,12 @@ const dateTime = (function () {
10251025
return res;
10261026
});
10271027
} else { // type === 'integer'
1028+
// MYTODO
1029+
// It seems that _formatInteger accounts for mandatoryDigits but here it does not
1030+
// Note, syntax based on https://www.w3.org/TR/xpath-functions-31/#date-time-examples
10281031
matcher.type = 'integer';
10291032
const isUpper = formatSpec.case === tcase.UPPER;
1033+
const mandatoryDigits = formatSpec.mandatoryDigits && formatSpec.mandatoryDigits > 0 ? formatSpec.mandatoryDigits.toString() : '+';
10301034
switch (formatSpec.primary) {
10311035
case formats.LETTERS:
10321036
matcher.regex = isUpper ? '[A-Z]+' : '[a-z]+';
@@ -1047,7 +1051,7 @@ const dateTime = (function () {
10471051
};
10481052
break;
10491053
case formats.DECIMAL:
1050-
matcher.regex = '[0-9]+';
1054+
matcher.regex = `[0-9]{${mandatoryDigits}}`;
10511055
if (formatSpec.ordinal) {
10521056
// ordinals
10531057
matcher.regex += '(?:th|st|nd|rd)';

0 commit comments

Comments
 (0)
Please sign in to comment.