limit the range to 1 to 3 only

This commit is contained in:
Frank Yung-Fong Tang 2020-07-09 17:51:53 -07:00 committed by Rick Waldron
parent 19653bdfc8
commit e620226cd7
1 changed files with 16 additions and 1 deletions

View File

@ -31,8 +31,23 @@ function assertParts(parts, minute, second, fractionalSecond, message) {
}
}
let dtf = new Intl.DateTimeFormat(
assert.throws(RangeError, () => {
new Intl.DateTimeFormat(
'en', { minute: "numeric", second: "numeric", fractionalSecondDigits: 0});
}, "fractionalSecondDigits 0 should throw RangeError for out of range");
assert.throws(RangeError, () => {
new Intl.DateTimeFormat(
'en', { minute: "numeric", second: "numeric", fractionalSecondDigits: 4});
}, "fractionalSecondDigits 4 should throw RangeError for out of range");
let dtf = new Intl.DateTimeFormat(
'en', { minute: "numeric", second: "numeric"});
assertParts(dtf.formatToParts(d1), "02", "03", null, "no fractionalSecondDigits round down");
assertParts(dtf.formatToParts(d2), "02", "03", null, "no fractionalSecondDigits round down");
dtf = new Intl.DateTimeFormat(
'en', { minute: "numeric", second: "numeric", fractionalSecondDigits: undefined});
assertParts(dtf.formatToParts(d1), "02", "03", null, "no fractionalSecondDigits round down");
assertParts(dtf.formatToParts(d2), "02", "03", null, "no fractionalSecondDigits round down");