source: Dev/trunk/d3/src/time/format-utc.js @ 76

Last change on this file since 76 was 76, checked in by fpvanagthoven, 14 years ago

d3

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