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

Unified Diff: static/js/common/utc-to-local-time.js

Issue 17953003: Make UTC times into local times for eroman@ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/chromium-status/
Patch Set: Created 7 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
« no previous file with comments | « no previous file | templates/main.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: static/js/common/utc-to-local-time.js
===================================================================
--- static/js/common/utc-to-local-time.js (revision 0)
+++ static/js/common/utc-to-local-time.js (revision 0)
@@ -0,0 +1,42 @@
+(function(doc) {
+
+function filter(list, predicate) {
+ var filtered = [];
+ for (var i = 0; i < list.length; ++i) {
+ if (predicate(list[i]))
+ filtered.push(list[i]);
+ }
+ return filtered;
+}
+
+function hasBorder(el) {
+ return !!el.border;
+}
+
+function elementType(node) {
+ return node.nodeType == 1; // Node.ELEMENT_NODE
+}
+
+var indexOf = Array.prototype.indexOf;
+function secondKid(el) {
+ return indexOf.call(filter(el.parentNode.childNodes, elementType), el) == 1;
+}
+
+var on = window.attachEvent ? 'on' : '';
+(window.addEventListener || window.attachEvent)(on + 'load', function() {
+ var tables = filter(doc.getElementsByTagName('table'), hasBorder);
+ if (!tables.length)
+ return;
+
+ var whens = filter(tables[0].getElementsByTagName('td'), secondKid).slice(1);
+ if (!whens.length)
+ return;
+
+ for (var i = 0; i < whens.length; ++i) {
+ var when = whens[i];
+ var time = new Date(when.innerText || when.textContent).toLocaleString();
+ when.textContent = when.innerText = time.replace(':00 ', '');
+ }
+});
+
+}(this.document));
Property changes on: static/js/common/utc-to-local-time.js
___________________________________________________________________
Added: svn:mime-type
+ text/javascript
Added: svn:eol-style
+ LF
« no previous file with comments | « no previous file | templates/main.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698