|
1 d3.time.format.utc = function(template) { |
|
2 var local = d3.time.format(template); |
|
3 |
|
4 function format(date) { |
|
5 try { |
|
6 d3_time = d3_time_format_utc; |
|
7 var utc = new d3_time(); |
|
8 utc._ = date; |
|
9 return local(utc); |
|
10 } finally { |
|
11 d3_time = Date; |
|
12 } |
|
13 } |
|
14 |
|
15 format.parse = function(string) { |
|
16 try { |
|
17 d3_time = d3_time_format_utc; |
|
18 var date = local.parse(string); |
|
19 return date && date._; |
|
20 } finally { |
|
21 d3_time = Date; |
|
22 } |
|
23 }; |
|
24 |
|
25 format.toString = local.toString; |
|
26 |
|
27 return format; |
|
28 }; |
|
29 |
|
30 function d3_time_format_utc() { |
|
31 this._ = new Date(Date.UTC.apply(this, arguments)); |
|
32 } |
|
33 |
|
34 d3_time_format_utc.prototype = { |
|
35 getDate: function() { return this._.getUTCDate(); }, |
|
36 getDay: function() { return this._.getUTCDay(); }, |
|
37 getFullYear: function() { return this._.getUTCFullYear(); }, |
|
38 getHours: function() { return this._.getUTCHours(); }, |
|
39 getMilliseconds: function() { return this._.getUTCMilliseconds(); }, |
|
40 getMinutes: function() { return this._.getUTCMinutes(); }, |
|
41 getMonth: function() { return this._.getUTCMonth(); }, |
|
42 getSeconds: function() { return this._.getUTCSeconds(); }, |
|
43 getTimezoneOffset: function() { return 0; }, |
|
44 valueOf: function() { return this._.getTime(); }, |
|
45 setDate: function(x) { this._.setUTCDate(x); }, |
|
46 setDay: function(x) { this._.setUTCDay(x); }, |
|
47 setFullYear: function(x) { this._.setUTCFullYear(x); }, |
|
48 setHours: function(x) { this._.setUTCHours(x); }, |
|
49 setMilliseconds: function(x) { this._.setUTCMilliseconds(x); }, |
|
50 setMinutes: function(x) { this._.setUTCMinutes(x); }, |
|
51 setMonth: function(x) { this._.setUTCMonth(x); }, |
|
52 setSeconds: function(x) { this._.setUTCSeconds(x); } |
|
53 }; |