Intl.DateTimeFormat: formatToParts nitpicking

This commit is contained in:
Rick Waldron 2018-08-10 15:35:04 -04:00
parent c0e494eb6a
commit b893503aa8

View File

@ -52,25 +52,22 @@ const actualPartTypes = new Intl.DateTimeFormat('en-us', {
timeZone: 'UTC', timeZone: 'UTC',
timeZoneName: 'long' timeZoneName: 'long'
}).formatToParts(Date.UTC(2012, 11, 17, 3, 0, 42)) }).formatToParts(Date.UTC(2012, 11, 17, 3, 0, 42))
.map(function (part) { return part.type; }); .map(part => part.type);
const legalPartTypes = [ const legalPartTypes = [
"weekday", 'weekday',
"era", 'era',
"year", 'year',
"month", 'month',
"day", 'day',
"hour", 'hour',
"minute", 'minute',
"second", 'second',
"literal", 'literal',
"dayPeriod", 'dayPeriod',
"timeZoneName" 'timeZoneName',
]; ];
actualPartTypes.forEach( actualPartTypes.forEach(function(type) {
function (type) { assert(legalPartTypes.includes(type), `${type} is not a legal type`);
assert( });
legalPartTypes.indexOf(type) !== -1,
type + " is not a legal type");
});