Skip to content

Commit

Permalink
Merge branch 'patch/care-pattern-in-bestmatch' of https://github.com/…
Browse files Browse the repository at this point in the history
  • Loading branch information
caridy committed Jun 17, 2016
2 parents 6eac07a + 2655473 commit e566733
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/12.datetimeformat.js
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,8 @@ function BestFitFormatMatcher (options, formats) {
// 6. Let shortMorePenalty be 3.
let shortMorePenalty = 3;

let patternPenalty = 2;

let hour12Penalty = 1;

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

let patternProp = hop.call(format._, property) ? format._[property] : undefined;

if (optionsProp !== patternProp) {
score -= patternPenalty;
}

// iv. If optionsProp is undefined and formatProp is not undefined, then decrease score by
// additionPenalty.
if (optionsProp === undefined && formatProp !== undefined)
Expand Down

0 comments on commit e566733

Please sign in to comment.