Skip to content

Commit

Permalink
Merge pull request mozilla-b2g#24051 from gmarty/Bug-1057977-Status-B…
Browse files Browse the repository at this point in the history
…ar-Remove-AM-PM-indicator

Bug 1057977 - [Status Bar] Remove AM/PM indicator
  • Loading branch information
gmarty committed Sep 24, 2014
2 parents 97b2558 + 3592a73 commit 8756efc
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
16 changes: 14 additions & 2 deletions apps/system/js/statusbar.js
Expand Up @@ -108,7 +108,8 @@ var StatusBar = {
'vibration.enabled': ['vibration'],
'ril.cf.enabled': ['callForwarding'],
'operatorResources.data.icon': ['iconData'],
'statusbar.network-activity.disabled': ['networkActivity']
'statusbar.network-activity.disabled': ['networkActivity'],
'statusbar.show-am-pm': ['time']
},

/* Track which settings are observed, so we don't add multiple listeners. */
Expand Down Expand Up @@ -621,6 +622,16 @@ var StatusBar = {
return iconWidth;
},

_getTimeFormat: function sb_getTimeFormat(timeFormat) {
if (this.settingValues['statusbar.show-am-pm']) {
timeFormat = timeFormat.replace('%p', '<span>%p</span>');
} else {
timeFormat = timeFormat.replace('%p', '').trim();
}

return timeFormat;
},

panelHandler: function sb_panelHandler(evt) {
var app = AppWindowManager.getActiveApp().getTopMostWindow();
var chromeBar = app.element.querySelector('.chrome');
Expand Down Expand Up @@ -918,12 +929,13 @@ var StatusBar = {
},

time: function sb_updateTime(now) {
now = now || new Date();
var _ = navigator.mozL10n.get;
var f = new navigator.mozL10n.DateTimeFormat();

var timeFormat = window.navigator.mozHour12 ?
_('shortTimeFormat12') : _('shortTimeFormat24');
timeFormat = timeFormat.replace('%p', '<span>%p</span>');
timeFormat = this._getTimeFormat(timeFormat);
var formatted = f.localeFormat(now, timeFormat);
this.icons.time.innerHTML = formatted;

Expand Down
21 changes: 21 additions & 0 deletions apps/system/test/unit/statusbar_test.js
Expand Up @@ -1818,6 +1818,27 @@ suite('system/Statusbar', function() {
});
});

suite('Time format', function() {
test('should be 24 hour', function() {
var timeFormat = StatusBar._getTimeFormat('shortTimeFormat24');
assert.equal(timeFormat, 'shortTimeFormat24');
});

test('should be 12 hour with AM/PM', function() {
StatusBar.settingValues['statusbar.show-am-pm'] = true;

var timeFormat = StatusBar._getTimeFormat('123 %p');
assert.equal(timeFormat, '123 <span>%p</span>');
});

test('should be 12 hour without AM/PM', function() {
StatusBar.settingValues['statusbar.show-am-pm'] = false;

var timeFormat = StatusBar._getTimeFormat('123 %p');
assert.equal(timeFormat, '123');
});
});

suite('Icons', function() {
test('visibility should be updated on screen resize', function() {
var spyUpdateIconVisibility =
Expand Down
1 change: 1 addition & 0 deletions build/config/common-settings.json
Expand Up @@ -193,6 +193,7 @@
"homegesture.enabled": false,
"edgesgesture.enabled": true,
"continuous-transition.enabled": false,
"statusbar.show-am-pm": true,
"support.onlinesupport.title": "",
"support.onlinesupport.href": "",
"support.callsupport1.title": "",
Expand Down

0 comments on commit 8756efc

Please sign in to comment.