Skip to content
This repository was archived by the owner on Apr 14, 2021. It is now read-only.

Commit e566733

Browse files
committed
Merge branch 'patch/care-pattern-in-bestmatch' of https://github.com/watilde/Intl.js
2 parents 6eac07a + 2655473 commit e566733

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/12.datetimeformat.js

+8
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,8 @@ function BestFitFormatMatcher (options, formats) {
626626
// 6. Let shortMorePenalty be 3.
627627
let shortMorePenalty = 3;
628628

629+
let patternPenalty = 2;
630+
629631
let hour12Penalty = 1;
630632

631633
// 7. Let bestScore be -Infinity.
@@ -664,6 +666,12 @@ function BestFitFormatMatcher (options, formats) {
664666
// 1. Let formatProp be the result of calling the [[Get]] internal method of format with argument property.
665667
let formatProp = hop.call(format, property) ? format[property] : undefined;
666668

669+
let patternProp = hop.call(format._, property) ? format._[property] : undefined;
670+
671+
if (optionsProp !== patternProp) {
672+
score -= patternPenalty;
673+
}
674+
667675
// iv. If optionsProp is undefined and formatProp is not undefined, then decrease score by
668676
// additionPenalty.
669677
if (optionsProp === undefined && formatProp !== undefined)

0 commit comments

Comments
 (0)