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

Side by Side Diff: static/js/main/main.js

Issue 134403003: chromium-status: fix interpretation of week days when localizing timestamps (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/chromium-status
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 * Code for the main user-visible status page. 6 * Code for the main user-visible status page.
7 */ 7 */
8 8
9 window.onload = function() { 9 window.onload = function() {
10 document.add_new_message.message.focus(); 10 document.add_new_message.message.focus();
(...skipping 23 matching lines...) Expand all
34 } 34 }
35 35
36 function long_date(date) { // RFC2822 36 function long_date(date) { // RFC2822
37 return format(date, 'EEE, dd MMM yyyy', 'HH:mm:ss z'); 37 return format(date, 'EEE, dd MMM yyyy', 'HH:mm:ss z');
38 } 38 }
39 39
40 function short_date(date) { 40 function short_date(date) {
41 return format(date, 'EEE, dd MMM', 'HH:mm'); 41 return format(date, 'EEE, dd MMM', 'HH:mm');
42 } 42 }
43 43
44 var tzname = locale.format(new Date(), { 44 var now = new Date();
45 var curr_year = now.getFullYear();
46
47 var tzname = locale.format(now, {
45 selector: 'time', 48 selector: 'time',
46 timePattern: 'z' 49 timePattern: 'z'
47 }); 50 });
48 51
49 var i, elements; 52 var i, elements;
50 53
51 // Convert all the fields that have a timezone already. 54 // Convert all the fields that have a timezone already.
52 elements = document.getElementsByName('date.datetz'); 55 elements = document.getElementsByName('date.datetz');
53 for (i = 0; i < elements.length; ++i) 56 for (i = 0; i < elements.length; ++i)
54 elements[i].innerText = long_date(elements[i].innerText); 57 elements[i].innerText = long_date(elements[i].innerText);
55 58
56 // Convert all the fields that lack a timezone (which we know is UTC). 59 // Convert all the fields that lack a timezone (which we know is UTC).
60 // We'll assume the timestamps represent the current year as it'll only
61 // really affect the short day-of-week name, and even then it'll only be
62 // slightly off during the ~1st week of January.
57 elements = document.getElementsByName('date.date'); 63 elements = document.getElementsByName('date.date');
58 for (i = 0; i < elements.length; ++i) 64 for (i = 0; i < elements.length; ++i)
59 elements[i].innerText = short_date(elements[i].innerText + ' UTC'); 65 elements[i].innerText = short_date(elements[i].innerText + ' ' + curr_year
66 + ' UTC');
60 67
61 // Convert all the fields that are just a timezone. 68 // Convert all the fields that are just a timezone.
62 elements = document.getElementsByName('date.tz'); 69 elements = document.getElementsByName('date.tz');
63 for (i = 0; i < elements.length; ++i) 70 for (i = 0; i < elements.length; ++i)
64 elements[i].innerText = tzname; 71 elements[i].innerText = tzname;
65 }); 72 });
66 } 73 }
67 74
68 /* 75 /*
69 * Functions for managing the help text. 76 * Functions for managing the help text.
(...skipping 16 matching lines...) Expand all
86 var help = document.getElementById('help'); 93 var help = document.getElementById('help');
87 help.style.left = message.offsetLeft + 'px'; 94 help.style.left = message.offsetLeft + 'px';
88 help.style.top = message.offsetTop + message.offsetHeight + 'px'; 95 help.style.top = message.offsetTop + message.offsetHeight + 'px';
89 help.hidden = false; 96 help.hidden = false;
90 } 97 }
91 98
92 function help_hide() { 99 function help_hide() {
93 var help = document.getElementById('help'); 100 var help = document.getElementById('help');
94 help.hidden = true; 101 help.hidden = true;
95 } 102 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698