Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1952)

Unified Diff: chrome/browser/resources/settings/device_page/night_light_slider.js

Issue 2951483003: [Night Light] CL9: Add localization for time's AM and PM (Closed)
Patch Set: No need for translations Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/settings/device_page/night_light_slider.js
diff --git a/chrome/browser/resources/settings/device_page/night_light_slider.js b/chrome/browser/resources/settings/device_page/night_light_slider.js
index 64e3aa5ac0648791c9254318c4054f488fe1015d..8c7077aa641e5a76d6176181bcc316eeb37465ee 100644
--- a/chrome/browser/resources/settings/device_page/night_light_slider.js
+++ b/chrome/browser/resources/settings/device_page/night_light_slider.js
@@ -190,37 +190,25 @@ Polymer({
return parseFloat(knob.style.left) / this.$.sliderBar.offsetWidth;
},
- /**
- * Pads the given number |num| with leading zeros such that its length as a
- * string is 2.
- * @param {number} num
- * @return {string}
- * @private
- */
- pad2_: function(num) {
- var s = String(num);
- if (s.length == 2)
- return s;
-
- return '0' + s;
- },
-
/**
* Converts the |offsetMinutes| value (which the number of minutes since
- * 00:00) to its string representation in the format 6:30 PM.
+ * 00:00) to its language-sensitive time string representation.
* @param {number} offsetMinutes The time of day represented as the number of
* minutes from 00:00.
* @return {string}
* @private
*/
offsetMinutesToTimeString_: function(offsetMinutes) {
- // TODO(afakhry): Check if these values need to be localized.
var hour = Math.floor(offsetMinutes / 60);
- var amPm = hour >= 12 ? ' PM' : ' AM';
- hour %= 12;
- hour = hour == 0 ? 12 : hour;
var minute = Math.floor(offsetMinutes % 60);
- return hour + ':' + this.pad2_(minute) + amPm;
+
+ var d = new Date();
+ d.setHours(hour);
+ d.setMinutes(minute);
+ d.setSeconds(0);
+ d.setMilliseconds(0);
+
+ return d.toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'});
},
/**

Powered by Google App Engine
This is Rietveld 408576698