Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @fileoverview | 6 * @fileoverview |
| 7 * night-light-slider is used to set the custom automatic schedule of the | 7 * night-light-slider is used to set the custom automatic schedule of the |
| 8 * Night Light feature, so that users can set their desired start and end | 8 * Night Light feature, so that users can set their desired start and end |
| 9 * times. | 9 * times. |
| 10 */ | 10 */ |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 | 207 |
| 208 /** | 208 /** |
| 209 * Converts the |offsetMinutes| value (which the number of minutes since | 209 * Converts the |offsetMinutes| value (which the number of minutes since |
| 210 * 00:00) to its string representation in the format 6:30 PM. | 210 * 00:00) to its string representation in the format 6:30 PM. |
| 211 * @param {number} offsetMinutes The time of day represented as the number of | 211 * @param {number} offsetMinutes The time of day represented as the number of |
| 212 * minutes from 00:00. | 212 * minutes from 00:00. |
| 213 * @return {string} | 213 * @return {string} |
| 214 * @private | 214 * @private |
| 215 */ | 215 */ |
| 216 offsetMinutesToTimeString_: function(offsetMinutes) { | 216 offsetMinutesToTimeString_: function(offsetMinutes) { |
| 217 // TODO(afakhry): Check if these values need to be localized. | |
| 218 var hour = Math.floor(offsetMinutes / 60); | 217 var hour = Math.floor(offsetMinutes / 60); |
| 219 var amPm = hour >= 12 ? ' PM' : ' AM'; | 218 var amPm = hour >= 12 ? this.i18n('displayNightLightTimePm') |
| 219 : this.i18n('displayNightLightTimeAm'); | |
| 220 hour %= 12; | 220 hour %= 12; |
| 221 hour = hour == 0 ? 12 : hour; | 221 hour = hour == 0 ? 12 : hour; |
| 222 var minute = Math.floor(offsetMinutes % 60); | 222 var minute = Math.floor(offsetMinutes % 60); |
| 223 return hour + ':' + this.pad2_(minute) + amPm; | 223 return hour + ':' + this.pad2_(minute) + ' ' + amPm; |
|
stevenjb
2017/06/20 00:36:43
Looking around, it seems like we should be using D
afakhry
2017/06/20 16:47:43
Oh Wow, I had no idea about this. Thank you very m
| |
| 224 }, | 224 }, |
| 225 | 225 |
| 226 /** | 226 /** |
| 227 * Handles changes in the start and end times prefs. | 227 * Handles changes in the start and end times prefs. |
| 228 * @private | 228 * @private |
| 229 */ | 229 */ |
| 230 customTimesChanged_: function() { | 230 customTimesChanged_: function() { |
| 231 var startOffsetMinutes = /** @type {number} */( | 231 var startOffsetMinutes = /** @type {number} */( |
| 232 this.getPref('ash.night_light.custom_start_time').value); | 232 this.getPref('ash.night_light.custom_start_time').value); |
| 233 this.startTime_ = this.offsetMinutesToTimeString_(startOffsetMinutes); | 233 this.startTime_ = this.offsetMinutesToTimeString_(startOffsetMinutes); |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 440 */ | 440 */ |
| 441 onRightKey_: function(e) { | 441 onRightKey_: function(e) { |
| 442 e.preventDefault(); | 442 e.preventDefault(); |
| 443 var knobPref = this.getFocusedKnobPrefPathIfAny_(); | 443 var knobPref = this.getFocusedKnobPrefPathIfAny_(); |
| 444 if (!knobPref) | 444 if (!knobPref) |
| 445 return; | 445 return; |
| 446 | 446 |
| 447 this.incrementPref_(knobPref, 1); | 447 this.incrementPref_(knobPref, 1); |
| 448 }, | 448 }, |
| 449 }); | 449 }); |
| OLD | NEW |