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

Commit 88fe478

Browse files
committed
fixes #152, fixes #179: improving support for best bit on datatimeformat, follow up on PR #186
1 parent e566733 commit 88fe478

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/12.datetimeformat.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -666,10 +666,11 @@ function BestFitFormatMatcher (options, formats) {
666666
// 1. Let formatProp be the result of calling the [[Get]] internal method of format with argument property.
667667
let formatProp = hop.call(format, property) ? format[property] : undefined;
668668

669+
// Diverging: using the default properties produced by the pattern/skeleton
670+
// to match it with user options, and apply a penalty
669671
let patternProp = hop.call(format._, property) ? format._[property] : undefined;
670-
671672
if (optionsProp !== patternProp) {
672-
score -= patternPenalty;
673+
score -= patternPenalty;
673674
}
674675

675676
// iv. If optionsProp is undefined and formatProp is not undefined, then decrease score by

tests/sanity.js

+17
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,20 @@ assert(new IntlPolyfill.DateTimeFormat('en', {
2525
month:'numeric',
2626
day: 'numeric'
2727
}).format(new Date('2016/05/16')), '5/16', 'month and day');
28+
29+
// Issue #152
30+
assert(new IntlPolyfill.DateTimeFormat('en-US', {
31+
hour: 'numeric',
32+
minute: 'numeric'
33+
}).format(new Date(1456859319008)), '2:08 PM', 'missing leading 0 on minutes');
34+
assert(new IntlPolyfill.DateTimeFormat('en-GB', {
35+
hour: '2-digit',
36+
hour12: false,
37+
minute: 'numeric'
38+
}).format(new Date(1983, 9, 13)), '00:00', 'GB should use 2-digits for hours and minutes without hour12');
39+
40+
// issue #179
41+
assert(new IntlPolyfill.DateTimeFormat('en', {
42+
month:'long',
43+
year: 'numeric'
44+
}).format(new Date('2016/01/16')), 'January 2016', 'month should be long');

0 commit comments

Comments
 (0)