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

Commit 43e47bc

Browse files
author
Zibi Braniecki
committed
Bug 1278358 - Update dayperiod to dayPeriod in DateTimeFormat formatToParts calls
1 parent daad32f commit 43e47bc

File tree

13 files changed

+21
-16
lines changed

13 files changed

+21
-16
lines changed

apps/calendar/js/date_l10n.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ exports._localizeElement = function(element) {
5353
if (format === 'week-hour-format') {
5454
text = formatter.formatToParts(new Date(date)).map(({type, value}) => {
5555
switch(type) {
56-
case 'dayperiod':
56+
case 'dayPeriod':
5757
return `<span class="ampm" aria-hidden="true">${value}</span>`;
5858
default: return value;
5959
}

apps/calendar/js/templates/date_span.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,14 @@ module.exports = create({
2929
var formatter = IntlHelper.get(format);
3030

3131
if (this.arg('addAmPmClass')) {
32-
displayHour = formatter.format(date, {
33-
dayperiod: '<span class="ampm" aria-hidden="true">$&</span>',
34-
});
32+
displayHour = formatter.formatToParts(date).map(({type, value}) => {
33+
switch (type) {
34+
case 'dayPeriod':
35+
return `<span class="ampm" aria-hidden="true">${value}</span>`;
36+
default:
37+
return value;
38+
}
39+
}).reduce((string, part) => string + part, '');
3540
} else {
3641
displayHour = formatter.format(date);
3742
}

apps/calendar/js/views/current_time.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ CurrentTime.prototype = {
112112
this.element.textContent = formatter.formatToParts(now).map(
113113
({type, value}) => {
114114
switch(type) {
115-
case 'dayperiod': return '';
115+
case 'dayPeriod': return '';
116116
default: return value;
117117
}
118118
}

apps/clock/js/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ Utils.getLocalizedTimeHtml = function(date) {
204204
var f = IntlHelper.get('time-text');
205205
return f.formatToParts(date).map(({type, value}) => {
206206
switch(type) {
207-
case 'dayperiod': return `<small>${value}</small>`;
207+
case 'dayPeriod': return `<small>${value}</small>`;
208208
default: return value;
209209
}
210210
}).reduce((string, part) => string + part, '');

apps/communications/dialer/js/call_screen.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ var CallScreen = {
396396
if (formatter.resolvedOptions().hour12 === true) {
397397
timeText = formatter.formatToParts(now).map(({type, value}) => {
398398
switch (type) {
399-
case 'dayperiod': return '';
399+
case 'dayPeriod': return '';
400400
default: return value;
401401
}
402402
}).reduce((string, part) => string + part, '');

apps/communications/dialer/test/unit/call_screen_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ suite('call screen', function() {
903903
window.navigator.mozHour12 = true;
904904

905905
function stubFormatToParts(d) {
906-
return [{type: 'dayperiod', value: 'AM'}];
906+
return [{type: 'dayPeriod', value: 'AM'}];
907907
}
908908
if (!Intl.DateTimeFormat.prototype.formatToParts) {
909909
Intl.DateTimeFormat.prototype.formatToParts = stubFormatToParts;

apps/system/js/time_icon.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
var timeParts = this.timeFormatter.formatToParts(now);
4343
timeText = timeParts.map(({type, value}) => {
4444
switch (type) {
45-
case 'dayperiod':
45+
case 'dayPeriod':
4646
if (this.manager._ampm) {
4747
return `<span>${value}</span>`;
4848
}

apps/system/lockscreen/js/widgets/clock/lockscreen_clock_widget.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
var timeText =
4646
this.timeFormatter.formatToParts(now).map(({type, value}) => {
4747
switch (type) {
48-
case 'dayperiod': return '';
48+
case 'dayPeriod': return '';
4949
default: return value;
5050
}
5151
}

apps/system/test/unit/time_icon_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ suite('system/TimeIcon', function() {
3333
setup(function() {
3434
function stubFormatToParts(d) {
3535
return [
36-
{type: 'dayperiod', value: 'AM'}
36+
{type: 'dayPeriod', value: 'AM'}
3737
];
3838
}
3939
if (!Intl.DateTimeFormat.prototype.formatToParts) {

tv_apps/smart-home/js/home.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@
765765
var dayperiod = '';
766766

767767
var timeWithoutDayPeriod = parts.map(({type, value}) => {
768-
if (type === 'dayperiod') {
768+
if (type === 'dayPeriod') {
769769
dayperiod = value;
770770
return '';
771771
}

0 commit comments

Comments
 (0)