OLD | NEW |
1 <!-- | 1 <!-- |
2 Copyright 2014 The Chromium Authors. All rights reserved. | 2 Copyright 2014 The Chromium Authors. All rights reserved. |
3 Use of this source code is governed by a BSD-style license that can be | 3 Use of this source code is governed by a BSD-style license that can be |
4 found in the LICENSE file. | 4 found in the LICENSE file. |
5 --> | 5 --> |
6 | 6 |
7 <polymer-element name="ct-last-updated" attributes="date"> | 7 <polymer-element name="ct-last-updated" attributes="date"> |
8 <template> | 8 <template> |
9 Updated {{ date | _deltaMinutes }} min ago @ {{ date | _hours }}:{{ date | _
minutes }} | 9 <template if="{{ date }}"> |
| 10 Updated {{ date | _deltaMinutes }} min ago @ {{ date | _hours }}:{{ date |
_minutes }} |
| 11 </template> |
10 </template> | 12 </template> |
11 <script> | 13 <script> |
12 (function() { | 14 (function() { |
13 Polymer({ | 15 Polymer({ |
14 date: new Date(0), | 16 date: null, |
15 | 17 |
16 _deltaMinutes: function(date) { | 18 _deltaMinutes: function(date) { |
17 return date.minutesAgo(); | 19 return date.minutesAgo(); |
18 }, | 20 }, |
19 _hours: function(date) { | 21 _hours: function(date) { |
20 return date.getHours(); | 22 return date.getHours(); |
21 }, | 23 }, |
22 _minutes: function(date) { | 24 _minutes: function(date) { |
23 return date.getMinutes(); | 25 var s = date.getMinutes().toString(); |
| 26 if (s.length == 1) |
| 27 s = "0" + s; |
| 28 return s; |
24 }, | 29 }, |
25 }); | 30 }); |
26 })(); | 31 })(); |
27 | 32 |
28 </script> | 33 </script> |
29 </polymer-element> | 34 </polymer-element> |
OLD | NEW |