aboutsummaryrefslogtreecommitdiffstats
path: root/web/nms.gathering.org/speedometer/d3-master/src/time
diff options
context:
space:
mode:
authorKristian Lyngstol <kristian@bohemians.org>2015-04-02 19:24:45 +0200
committerKristian Lyngstol <kristian@bohemians.org>2015-04-02 19:24:45 +0200
commit0d8bba263dc195147d6fdb09662e7926f0a58b3e (patch)
tree4c570b4376c323e585120e7695b8715be7aa8881 /web/nms.gathering.org/speedometer/d3-master/src/time
parente4354b47bd8891c5b1ee591fdf74b3ca67eee461 (diff)
Bump lots of changes
Diffstat (limited to 'web/nms.gathering.org/speedometer/d3-master/src/time')
-rw-r--r--web/nms.gathering.org/speedometer/d3-master/src/time/day.js21
-rw-r--r--web/nms.gathering.org/speedometer/d3-master/src/time/format-iso.js19
-rw-r--r--web/nms.gathering.org/speedometer/d3-master/src/time/format-utc.js3
-rw-r--r--web/nms.gathering.org/speedometer/d3-master/src/time/format.js4
-rw-r--r--web/nms.gathering.org/speedometer/d3-master/src/time/hour.js14
-rw-r--r--web/nms.gathering.org/speedometer/d3-master/src/time/index.js14
-rw-r--r--web/nms.gathering.org/speedometer/d3-master/src/time/interval.js71
-rw-r--r--web/nms.gathering.org/speedometer/d3-master/src/time/minute.js13
-rw-r--r--web/nms.gathering.org/speedometer/d3-master/src/time/month.js16
-rw-r--r--web/nms.gathering.org/speedometer/d3-master/src/time/scale-utc.js25
-rw-r--r--web/nms.gathering.org/speedometer/d3-master/src/time/scale.js155
-rw-r--r--web/nms.gathering.org/speedometer/d3-master/src/time/second.js13
-rw-r--r--web/nms.gathering.org/speedometer/d3-master/src/time/time.js33
-rw-r--r--web/nms.gathering.org/speedometer/d3-master/src/time/week.js31
-rw-r--r--web/nms.gathering.org/speedometer/d3-master/src/time/year.js16
15 files changed, 448 insertions, 0 deletions
diff --git a/web/nms.gathering.org/speedometer/d3-master/src/time/day.js b/web/nms.gathering.org/speedometer/d3-master/src/time/day.js
new file mode 100644
index 0000000..3b8e7de
--- /dev/null
+++ b/web/nms.gathering.org/speedometer/d3-master/src/time/day.js
@@ -0,0 +1,21 @@
+import "interval";
+import "time";
+import "year";
+
+d3_time.day = d3_time_interval(function(date) {
+ var day = new d3_date(2000, 0);
+ day.setFullYear(date.getFullYear(), date.getMonth(), date.getDate());
+ return day;
+}, function(date, offset) {
+ date.setDate(date.getDate() + offset);
+}, function(date) {
+ return date.getDate() - 1;
+});
+
+d3_time.days = d3_time.day.range;
+d3_time.days.utc = d3_time.day.utc.range;
+
+d3_time.dayOfYear = function(date) {
+ var year = d3_time.year(date);
+ return Math.floor((date - year - (date.getTimezoneOffset() - year.getTimezoneOffset()) * 6e4) / 864e5);
+};
diff --git a/web/nms.gathering.org/speedometer/d3-master/src/time/format-iso.js b/web/nms.gathering.org/speedometer/d3-master/src/time/format-iso.js
new file mode 100644
index 0000000..1bcd860
--- /dev/null
+++ b/web/nms.gathering.org/speedometer/d3-master/src/time/format-iso.js
@@ -0,0 +1,19 @@
+import "format";
+import "format-utc";
+
+var d3_time_formatIso = d3_time_formatUtc("%Y-%m-%dT%H:%M:%S.%LZ");
+
+d3_time_format.iso = Date.prototype.toISOString && +new Date("2000-01-01T00:00:00.000Z")
+ ? d3_time_formatIsoNative
+ : d3_time_formatIso;
+
+function d3_time_formatIsoNative(date) {
+ return date.toISOString();
+}
+
+d3_time_formatIsoNative.parse = function(string) {
+ var date = new Date(string);
+ return isNaN(date) ? null : date;
+};
+
+d3_time_formatIsoNative.toString = d3_time_formatIso.toString;
diff --git a/web/nms.gathering.org/speedometer/d3-master/src/time/format-utc.js b/web/nms.gathering.org/speedometer/d3-master/src/time/format-utc.js
new file mode 100644
index 0000000..f5b4808
--- /dev/null
+++ b/web/nms.gathering.org/speedometer/d3-master/src/time/format-utc.js
@@ -0,0 +1,3 @@
+import "format";
+
+var d3_time_formatUtc = d3_time_format.utc;
diff --git a/web/nms.gathering.org/speedometer/d3-master/src/time/format.js b/web/nms.gathering.org/speedometer/d3-master/src/time/format.js
new file mode 100644
index 0000000..3ad7f5f
--- /dev/null
+++ b/web/nms.gathering.org/speedometer/d3-master/src/time/format.js
@@ -0,0 +1,4 @@
+import "../locale/en-US";
+import "time";
+
+var d3_time_format = d3_time.format = d3_locale_enUS.timeFormat;
diff --git a/web/nms.gathering.org/speedometer/d3-master/src/time/hour.js b/web/nms.gathering.org/speedometer/d3-master/src/time/hour.js
new file mode 100644
index 0000000..0c6011d
--- /dev/null
+++ b/web/nms.gathering.org/speedometer/d3-master/src/time/hour.js
@@ -0,0 +1,14 @@
+import "interval";
+import "time";
+
+d3_time.hour = d3_time_interval(function(date) {
+ var timezone = date.getTimezoneOffset() / 60;
+ return new d3_date((Math.floor(date / 36e5 - timezone) + timezone) * 36e5);
+}, function(date, offset) {
+ date.setTime(date.getTime() + Math.floor(offset) * 36e5); // DST breaks setHours
+}, function(date) {
+ return date.getHours();
+});
+
+d3_time.hours = d3_time.hour.range;
+d3_time.hours.utc = d3_time.hour.utc.range;
diff --git a/web/nms.gathering.org/speedometer/d3-master/src/time/index.js b/web/nms.gathering.org/speedometer/d3-master/src/time/index.js
new file mode 100644
index 0000000..b041fc6
--- /dev/null
+++ b/web/nms.gathering.org/speedometer/d3-master/src/time/index.js
@@ -0,0 +1,14 @@
+import "time";
+import "format";
+import "format-utc";
+import "format-iso";
+import "interval";
+import "second";
+import "minute";
+import "hour";
+import "day";
+import "week";
+import "month";
+import "year";
+import "scale";
+import "scale-utc";
diff --git a/web/nms.gathering.org/speedometer/d3-master/src/time/interval.js b/web/nms.gathering.org/speedometer/d3-master/src/time/interval.js
new file mode 100644
index 0000000..b177b20
--- /dev/null
+++ b/web/nms.gathering.org/speedometer/d3-master/src/time/interval.js
@@ -0,0 +1,71 @@
+import "time";
+
+function d3_time_interval(local, step, number) {
+
+ function round(date) {
+ var d0 = local(date), d1 = offset(d0, 1);
+ return date - d0 < d1 - date ? d0 : d1;
+ }
+
+ function ceil(date) {
+ step(date = local(new d3_date(date - 1)), 1);
+ return date;
+ }
+
+ function offset(date, k) {
+ step(date = new d3_date(+date), k);
+ return date;
+ }
+
+ function range(t0, t1, dt) {
+ var time = ceil(t0), times = [];
+ if (dt > 1) {
+ while (time < t1) {
+ if (!(number(time) % dt)) times.push(new Date(+time));
+ step(time, 1);
+ }
+ } else {
+ while (time < t1) times.push(new Date(+time)), step(time, 1);
+ }
+ return times;
+ }
+
+ function range_utc(t0, t1, dt) {
+ try {
+ d3_date = d3_date_utc;
+ var utc = new d3_date_utc();
+ utc._ = t0;
+ return range(utc, t1, dt);
+ } finally {
+ d3_date = Date;
+ }
+ }
+
+ local.floor = local;
+ local.round = round;
+ local.ceil = ceil;
+ local.offset = offset;
+ local.range = range;
+
+ var utc = local.utc = d3_time_interval_utc(local);
+ utc.floor = utc;
+ utc.round = d3_time_interval_utc(round);
+ utc.ceil = d3_time_interval_utc(ceil);
+ utc.offset = d3_time_interval_utc(offset);
+ utc.range = range_utc;
+
+ return local;
+}
+
+function d3_time_interval_utc(method) {
+ return function(date, k) {
+ try {
+ d3_date = d3_date_utc;
+ var utc = new d3_date_utc();
+ utc._ = date;
+ return method(utc, k)._;
+ } finally {
+ d3_date = Date;
+ }
+ };
+}
diff --git a/web/nms.gathering.org/speedometer/d3-master/src/time/minute.js b/web/nms.gathering.org/speedometer/d3-master/src/time/minute.js
new file mode 100644
index 0000000..ad081f6
--- /dev/null
+++ b/web/nms.gathering.org/speedometer/d3-master/src/time/minute.js
@@ -0,0 +1,13 @@
+import "interval";
+import "time";
+
+d3_time.minute = d3_time_interval(function(date) {
+ return new d3_date(Math.floor(date / 6e4) * 6e4);
+}, function(date, offset) {
+ date.setTime(date.getTime() + Math.floor(offset) * 6e4); // DST breaks setMinutes
+}, function(date) {
+ return date.getMinutes();
+});
+
+d3_time.minutes = d3_time.minute.range;
+d3_time.minutes.utc = d3_time.minute.utc.range;
diff --git a/web/nms.gathering.org/speedometer/d3-master/src/time/month.js b/web/nms.gathering.org/speedometer/d3-master/src/time/month.js
new file mode 100644
index 0000000..577d5b2
--- /dev/null
+++ b/web/nms.gathering.org/speedometer/d3-master/src/time/month.js
@@ -0,0 +1,16 @@
+import "day";
+import "interval";
+import "time";
+
+d3_time.month = d3_time_interval(function(date) {
+ date = d3_time.day(date);
+ date.setDate(1);
+ return date;
+}, function(date, offset) {
+ date.setMonth(date.getMonth() + offset);
+}, function(date) {
+ return date.getMonth();
+});
+
+d3_time.months = d3_time.month.range;
+d3_time.months.utc = d3_time.month.utc.range;
diff --git a/web/nms.gathering.org/speedometer/d3-master/src/time/scale-utc.js b/web/nms.gathering.org/speedometer/d3-master/src/time/scale-utc.js
new file mode 100644
index 0000000..1c6e30f
--- /dev/null
+++ b/web/nms.gathering.org/speedometer/d3-master/src/time/scale-utc.js
@@ -0,0 +1,25 @@
+import "../core/true";
+import "../scale/linear";
+import "scale";
+import "format-utc";
+
+var d3_time_scaleUtcMethods = d3_time_scaleLocalMethods.map(function(m) {
+ return [m[0].utc, m[1]];
+});
+
+var d3_time_scaleUtcFormat = d3_time_formatUtc.multi([
+ [".%L", function(d) { return d.getUTCMilliseconds(); }],
+ [":%S", function(d) { return d.getUTCSeconds(); }],
+ ["%I:%M", function(d) { return d.getUTCMinutes(); }],
+ ["%I %p", function(d) { return d.getUTCHours(); }],
+ ["%a %d", function(d) { return d.getUTCDay() && d.getUTCDate() != 1; }],
+ ["%b %d", function(d) { return d.getUTCDate() != 1; }],
+ ["%B", function(d) { return d.getUTCMonth(); }],
+ ["%Y", d3_true]
+]);
+
+d3_time_scaleUtcMethods.year = d3_time.year.utc;
+
+d3_time.scale.utc = function() {
+ return d3_time_scale(d3.scale.linear(), d3_time_scaleUtcMethods, d3_time_scaleUtcFormat);
+};
diff --git a/web/nms.gathering.org/speedometer/d3-master/src/time/scale.js b/web/nms.gathering.org/speedometer/d3-master/src/time/scale.js
new file mode 100644
index 0000000..90a23df
--- /dev/null
+++ b/web/nms.gathering.org/speedometer/d3-master/src/time/scale.js
@@ -0,0 +1,155 @@
+import "../arrays/bisect";
+import "../arrays/range";
+import "../core/identity";
+import "../core/true";
+import "../scale/linear";
+import "../scale/nice";
+import "format";
+import "day";
+import "hour";
+import "minute";
+import "month";
+import "second";
+import "time";
+import "week";
+import "year";
+
+function d3_time_scale(linear, methods, format) {
+
+ function scale(x) {
+ return linear(x);
+ }
+
+ scale.invert = function(x) {
+ return d3_time_scaleDate(linear.invert(x));
+ };
+
+ scale.domain = function(x) {
+ if (!arguments.length) return linear.domain().map(d3_time_scaleDate);
+ linear.domain(x);
+ return scale;
+ };
+
+ function tickMethod(extent, count) {
+ var span = extent[1] - extent[0],
+ target = span / count,
+ i = d3.bisect(d3_time_scaleSteps, target);
+ return i == d3_time_scaleSteps.length ? [methods.year, d3_scale_linearTickRange(extent.map(function(d) { return d / 31536e6; }), count)[2]]
+ : !i ? [d3_time_scaleMilliseconds, d3_scale_linearTickRange(extent, count)[2]]
+ : methods[target / d3_time_scaleSteps[i - 1] < d3_time_scaleSteps[i] / target ? i - 1 : i];
+ }
+
+ scale.nice = function(interval, skip) {
+ var domain = scale.domain(),
+ extent = d3_scaleExtent(domain),
+ method = interval == null ? tickMethod(extent, 10)
+ : typeof interval === "number" && tickMethod(extent, interval);
+
+ if (method) interval = method[0], skip = method[1];
+
+ function skipped(date) {
+ return !isNaN(date) && !interval.range(date, d3_time_scaleDate(+date + 1), skip).length;
+ }
+
+ return scale.domain(d3_scale_nice(domain, skip > 1 ? {
+ floor: function(date) {
+ while (skipped(date = interval.floor(date))) date = d3_time_scaleDate(date - 1);
+ return date;
+ },
+ ceil: function(date) {
+ while (skipped(date = interval.ceil(date))) date = d3_time_scaleDate(+date + 1);
+ return date;
+ }
+ } : interval));
+ };
+
+ scale.ticks = function(interval, skip) {
+ var extent = d3_scaleExtent(scale.domain()),
+ method = interval == null ? tickMethod(extent, 10)
+ : typeof interval === "number" ? tickMethod(extent, interval)
+ : !interval.range && [{range: interval}, skip]; // assume deprecated range function
+
+ if (method) interval = method[0], skip = method[1];
+
+ return interval.range(extent[0], d3_time_scaleDate(+extent[1] + 1), skip < 1 ? 1 : skip); // inclusive upper bound
+ };
+
+ scale.tickFormat = function() {
+ return format;
+ };
+
+ scale.copy = function() {
+ return d3_time_scale(linear.copy(), methods, format);
+ };
+
+ return d3_scale_linearRebind(scale, linear);
+}
+
+function d3_time_scaleDate(t) {
+ return new Date(t);
+}
+
+var d3_time_scaleSteps = [
+ 1e3, // 1-second
+ 5e3, // 5-second
+ 15e3, // 15-second
+ 3e4, // 30-second
+ 6e4, // 1-minute
+ 3e5, // 5-minute
+ 9e5, // 15-minute
+ 18e5, // 30-minute
+ 36e5, // 1-hour
+ 108e5, // 3-hour
+ 216e5, // 6-hour
+ 432e5, // 12-hour
+ 864e5, // 1-day
+ 1728e5, // 2-day
+ 6048e5, // 1-week
+ 2592e6, // 1-month
+ 7776e6, // 3-month
+ 31536e6 // 1-year
+];
+
+var d3_time_scaleLocalMethods = [
+ [d3_time.second, 1],
+ [d3_time.second, 5],
+ [d3_time.second, 15],
+ [d3_time.second, 30],
+ [d3_time.minute, 1],
+ [d3_time.minute, 5],
+ [d3_time.minute, 15],
+ [d3_time.minute, 30],
+ [d3_time.hour, 1],
+ [d3_time.hour, 3],
+ [d3_time.hour, 6],
+ [d3_time.hour, 12],
+ [d3_time.day, 1],
+ [d3_time.day, 2],
+ [d3_time.week, 1],
+ [d3_time.month, 1],
+ [d3_time.month, 3],
+ [d3_time.year, 1]
+];
+
+var d3_time_scaleLocalFormat = d3_time_format.multi([
+ [".%L", function(d) { return d.getMilliseconds(); }],
+ [":%S", function(d) { return d.getSeconds(); }],
+ ["%I:%M", function(d) { return d.getMinutes(); }],
+ ["%I %p", function(d) { return d.getHours(); }],
+ ["%a %d", function(d) { return d.getDay() && d.getDate() != 1; }],
+ ["%b %d", function(d) { return d.getDate() != 1; }],
+ ["%B", function(d) { return d.getMonth(); }],
+ ["%Y", d3_true]
+]);
+
+var d3_time_scaleMilliseconds = {
+ range: function(start, stop, step) { return d3.range(Math.ceil(start / step) * step, +stop, step).map(d3_time_scaleDate); },
+ floor: d3_identity,
+ ceil: d3_identity
+};
+
+d3_time_scaleLocalMethods.year = d3_time.year;
+
+d3_time.scale = function() {
+ return d3_time_scale(d3.scale.linear(), d3_time_scaleLocalMethods, d3_time_scaleLocalFormat);
+};
diff --git a/web/nms.gathering.org/speedometer/d3-master/src/time/second.js b/web/nms.gathering.org/speedometer/d3-master/src/time/second.js
new file mode 100644
index 0000000..745c4b9
--- /dev/null
+++ b/web/nms.gathering.org/speedometer/d3-master/src/time/second.js
@@ -0,0 +1,13 @@
+import "interval";
+import "time";
+
+d3_time.second = d3_time_interval(function(date) {
+ return new d3_date(Math.floor(date / 1e3) * 1e3);
+}, function(date, offset) {
+ date.setTime(date.getTime() + Math.floor(offset) * 1e3); // DST breaks setSeconds
+}, function(date) {
+ return date.getSeconds();
+});
+
+d3_time.seconds = d3_time.second.range;
+d3_time.seconds.utc = d3_time.second.utc.range;
diff --git a/web/nms.gathering.org/speedometer/d3-master/src/time/time.js b/web/nms.gathering.org/speedometer/d3-master/src/time/time.js
new file mode 100644
index 0000000..ddfc018
--- /dev/null
+++ b/web/nms.gathering.org/speedometer/d3-master/src/time/time.js
@@ -0,0 +1,33 @@
+var d3_time = d3.time = {},
+ d3_date = Date;
+
+function d3_date_utc() {
+ this._ = new Date(arguments.length > 1
+ ? Date.UTC.apply(this, arguments)
+ : arguments[0]);
+}
+
+d3_date_utc.prototype = {
+ getDate: function() { return this._.getUTCDate(); },
+ getDay: function() { return this._.getUTCDay(); },
+ getFullYear: function() { return this._.getUTCFullYear(); },
+ getHours: function() { return this._.getUTCHours(); },
+ getMilliseconds: function() { return this._.getUTCMilliseconds(); },
+ getMinutes: function() { return this._.getUTCMinutes(); },
+ getMonth: function() { return this._.getUTCMonth(); },
+ getSeconds: function() { return this._.getUTCSeconds(); },
+ getTime: function() { return this._.getTime(); },
+ getTimezoneOffset: function() { return 0; },
+ valueOf: function() { return this._.valueOf(); },
+ setDate: function() { d3_time_prototype.setUTCDate.apply(this._, arguments); },
+ setDay: function() { d3_time_prototype.setUTCDay.apply(this._, arguments); },
+ setFullYear: function() { d3_time_prototype.setUTCFullYear.apply(this._, arguments); },
+ setHours: function() { d3_time_prototype.setUTCHours.apply(this._, arguments); },
+ setMilliseconds: function() { d3_time_prototype.setUTCMilliseconds.apply(this._, arguments); },
+ setMinutes: function() { d3_time_prototype.setUTCMinutes.apply(this._, arguments); },
+ setMonth: function() { d3_time_prototype.setUTCMonth.apply(this._, arguments); },
+ setSeconds: function() { d3_time_prototype.setUTCSeconds.apply(this._, arguments); },
+ setTime: function() { d3_time_prototype.setTime.apply(this._, arguments); }
+};
+
+var d3_time_prototype = Date.prototype;
diff --git a/web/nms.gathering.org/speedometer/d3-master/src/time/week.js b/web/nms.gathering.org/speedometer/d3-master/src/time/week.js
new file mode 100644
index 0000000..8fdfe13
--- /dev/null
+++ b/web/nms.gathering.org/speedometer/d3-master/src/time/week.js
@@ -0,0 +1,31 @@
+import "day";
+import "interval";
+import "time";
+import "year";
+
+["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"].forEach(function(day, i) {
+ i = 7 - i;
+
+ var interval = d3_time[day] = d3_time_interval(function(date) {
+ (date = d3_time.day(date)).setDate(date.getDate() - (date.getDay() + i) % 7);
+ return date;
+ }, function(date, offset) {
+ date.setDate(date.getDate() + Math.floor(offset) * 7);
+ }, function(date) {
+ var day = d3_time.year(date).getDay();
+ return Math.floor((d3_time.dayOfYear(date) + (day + i) % 7) / 7) - (day !== i);
+ });
+
+ d3_time[day + "s"] = interval.range;
+ d3_time[day + "s"].utc = interval.utc.range;
+
+ d3_time[day + "OfYear"] = function(date) {
+ var day = d3_time.year(date).getDay();
+ return Math.floor((d3_time.dayOfYear(date) + (day + i) % 7) / 7);
+ };
+});
+
+d3_time.week = d3_time.sunday;
+d3_time.weeks = d3_time.sunday.range;
+d3_time.weeks.utc = d3_time.sunday.utc.range;
+d3_time.weekOfYear = d3_time.sundayOfYear;
diff --git a/web/nms.gathering.org/speedometer/d3-master/src/time/year.js b/web/nms.gathering.org/speedometer/d3-master/src/time/year.js
new file mode 100644
index 0000000..3ac02a2
--- /dev/null
+++ b/web/nms.gathering.org/speedometer/d3-master/src/time/year.js
@@ -0,0 +1,16 @@
+import "day";
+import "interval";
+import "time";
+
+d3_time.year = d3_time_interval(function(date) {
+ date = d3_time.day(date);
+ date.setMonth(0, 1);
+ return date;
+}, function(date, offset) {
+ date.setFullYear(date.getFullYear() + offset);
+}, function(date) {
+ return date.getFullYear();
+});
+
+d3_time.years = d3_time.year.range;
+d3_time.years.utc = d3_time.year.utc.range;