Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #34377 from zbraniecki/1278358-update-formatoparts
Browse files Browse the repository at this point in the history
Bug 1278358 - Update `dayperiod` to `dayPeriod` in DateTimeFormat formatToParts calls. r=stas
  • Loading branch information
zbraniecki committed Jun 8, 2016
2 parents cf4919c + 43e47bc commit 15935d4
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 16 deletions.
2 changes: 1 addition & 1 deletion apps/calendar/js/date_l10n.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ exports._localizeElement = function(element) {
if (format === 'week-hour-format') {
text = formatter.formatToParts(new Date(date)).map(({type, value}) => {
switch(type) {
case 'dayperiod':
case 'dayPeriod':
return `<span class="ampm" aria-hidden="true">${value}</span>`;
default: return value;
}
Expand Down
11 changes: 8 additions & 3 deletions apps/calendar/js/templates/date_span.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,14 @@ module.exports = create({
var formatter = IntlHelper.get(format);

if (this.arg('addAmPmClass')) {
displayHour = formatter.format(date, {
dayperiod: '<span class="ampm" aria-hidden="true">$&</span>',
});
displayHour = formatter.formatToParts(date).map(({type, value}) => {
switch (type) {
case 'dayPeriod':
return `<span class="ampm" aria-hidden="true">${value}</span>`;
default:
return value;
}
}).reduce((string, part) => string + part, '');
} else {
displayHour = formatter.format(date);
}
Expand Down
2 changes: 1 addition & 1 deletion apps/calendar/js/views/current_time.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ CurrentTime.prototype = {
this.element.textContent = formatter.formatToParts(now).map(
({type, value}) => {
switch(type) {
case 'dayperiod': return '';
case 'dayPeriod': return '';
default: return value;
}
}
Expand Down
2 changes: 1 addition & 1 deletion apps/clock/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ Utils.getLocalizedTimeHtml = function(date) {
var f = IntlHelper.get('time-text');
return f.formatToParts(date).map(({type, value}) => {
switch(type) {
case 'dayperiod': return `<small>${value}</small>`;
case 'dayPeriod': return `<small>${value}</small>`;
default: return value;
}
}).reduce((string, part) => string + part, '');
Expand Down
2 changes: 1 addition & 1 deletion apps/communications/dialer/js/call_screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ var CallScreen = {
if (formatter.resolvedOptions().hour12 === true) {
timeText = formatter.formatToParts(now).map(({type, value}) => {
switch (type) {
case 'dayperiod': return '';
case 'dayPeriod': return '';
default: return value;
}
}).reduce((string, part) => string + part, '');
Expand Down
2 changes: 1 addition & 1 deletion apps/communications/dialer/test/unit/call_screen_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ suite('call screen', function() {
window.navigator.mozHour12 = true;

function stubFormatToParts(d) {
return [{type: 'dayperiod', value: 'AM'}];
return [{type: 'dayPeriod', value: 'AM'}];
}
if (!Intl.DateTimeFormat.prototype.formatToParts) {
Intl.DateTimeFormat.prototype.formatToParts = stubFormatToParts;
Expand Down
2 changes: 1 addition & 1 deletion apps/system/js/time_icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
var timeParts = this.timeFormatter.formatToParts(now);
timeText = timeParts.map(({type, value}) => {
switch (type) {
case 'dayperiod':
case 'dayPeriod':
if (this.manager._ampm) {
return `<span>${value}</span>`;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
var timeText =
this.timeFormatter.formatToParts(now).map(({type, value}) => {
switch (type) {
case 'dayperiod': return '';
case 'dayPeriod': return '';
default: return value;
}
}
Expand Down
2 changes: 1 addition & 1 deletion apps/system/test/unit/time_icon_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ suite('system/TimeIcon', function() {
setup(function() {
function stubFormatToParts(d) {
return [
{type: 'dayperiod', value: 'AM'}
{type: 'dayPeriod', value: 'AM'}
];
}
if (!Intl.DateTimeFormat.prototype.formatToParts) {
Expand Down
2 changes: 1 addition & 1 deletion tv_apps/smart-home/js/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@
var dayperiod = '';

var timeWithoutDayPeriod = parts.map(({type, value}) => {
if (type === 'dayperiod') {
if (type === 'dayPeriod') {
dayperiod = value;
return '';
}
Expand Down
2 changes: 1 addition & 1 deletion tv_apps/smart-home/test/unit/home_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ suite('home', function() {
return [
{type: 'hour', value: '12'},
{type: 'minute', value: '25'},
{type: 'dayperiod', value: 'AM'}
{type: 'dayPeriod', value: 'AM'}
];
};
}
Expand Down
4 changes: 2 additions & 2 deletions tv_apps/tv-epg/js/epg.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,12 @@

var parts = formatter.formatToParts(now);

var dayperiod = parts.find(part => part.type == 'dayperiod');
var dayperiod = parts.find(part => part.type == 'dayPeriod');

var prefix = dayperiod ? dayperiod.value : '';

var timeWithoutDayPeriod = parts.map(({type, value}) => {
return type === 'dayperiod' ? '' : value;
return type === 'dayPeriod' ? '' : value;
}).join('');

return {
Expand Down
2 changes: 1 addition & 1 deletion tv_apps/tv-epg/test/unit/epg_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ suite('tv-epg/epg', function() {
return [
{type: 'hour', value: '12'},
{type: 'minute', value: '25'},
{type: 'dayperiod', value: 'AM'}
{type: 'dayPeriod', value: 'AM'}
];
};
}
Expand Down

0 comments on commit 15935d4

Please sign in to comment.