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

Side by Side Diff: appengine/cmd/milo/frontend/static/common/js/time.js

Issue 2109473005: Milo: Pending swarming builds (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: Cleanup, new test data, fix timing display Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The LUCI Authors. All rights reserved. 1 // Copyright 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 // A Series of time based utilites for Milo. 5 // A Series of time based utilites for Milo.
6 6
7 7
8 (function(window) { 8 (function(window) {
9 'use strict'; 9 'use strict';
10 10
11 var milo = window.milo || {}; 11 var milo = window.milo || {};
12 12
13 /** 13 /**
14 * Given a Javascript parsable time string, return a time string in the user's 14 * Given a Javascript parsable time string, return a time string in the user's
15 * local timezone 15 * local timezone
16 */ 16 */
17 milo.formatDate = function(dt) { 17 milo.formatDate = function(dt) {
18 if (!dt) { 18 if (!dt) {
19 return dt; 19 return null;
20 } 20 }
21 var shortDayNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; 21 var shortDayNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
22 var t = new Date(dt); 22 var t = new Date(dt);
23 if (t.toString() == "Invalid Date") {
24 return null;
25 }
23 var offset = -(new Date()).getTimezoneOffset(); 26 var offset = -(new Date()).getTimezoneOffset();
24 var offsetHr = Math.abs(Math.round(offset / 60)); 27 var offsetHr = Math.abs(Math.round(offset / 60));
25 var offsetMin = Math.abs(Math.abs(offset) - (offsetHr * 60)); 28 var offsetMin = Math.abs(Math.abs(offset) - (offsetHr * 60));
26 if (offsetHr < 10) { 29 if (offsetHr < 10) {
27 offsetHr = '0' + offsetHr; 30 offsetHr = '0' + offsetHr;
28 } 31 }
29 if (offsetMin < 10) { 32 if (offsetMin < 10) {
30 offsetMin = '0' + offsetMin; 33 offsetMin = '0' + offsetMin;
31 } 34 }
32 var offsetStr = 'UTC'; 35 var offsetStr = 'UTC';
(...skipping 15 matching lines...) Expand all
48 s += t.getFullYear() + '-' + month + '-' + date + ' '; 51 s += t.getFullYear() + '-' + month + '-' + date + ' ';
49 s += t.toLocaleTimeString(); 52 s += t.toLocaleTimeString();
50 s += ' (' + offsetStr + ')'; 53 s += ' (' + offsetStr + ')';
51 54
52 return s; 55 return s;
53 }; 56 };
54 57
55 window.milo = milo; 58 window.milo = milo;
56 59
57 }(window)); 60 }(window));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698