-
Notifications
You must be signed in to change notification settings - Fork 0
/
d3.time.min.js
1 lines (1 loc) · 11.2 KB
/
d3.time.min.js
1
(function(){function U(a){return function(b){var c=a.length-1,d=a[c];while(!d[1](b))d=a[--c];return d[0](b)}}function T(a){return new Date(a)}function S(a){var b=a[0],c=a[a.length-1];return b<c?[b,c]:[c,b]}function R(a,b){function d(a){return c(a)}var c=d3.scale.linear();d.invert=function(a){return T(c.invert(a))},d.domain=function(a){if(!arguments.length)return c.domain().map(T);c.domain(a);return d},d.ticks=function(b){var c=S(d.domain()),e=c[1]-c[0],f=e/b;i=d3.bisect(V,f,1,V.length-1),Math.log(f/V[i-1])<Math.log(V[i]/f)&&--i;return a[i](c[0],c[1])},d.tickFormat=function(){return b},d.range=d3.rebind(d,c.range),d.rangeRound=d3.rebind(d,c.rangeRound),d.interpolate=d3.rebind(d,c.interpolate),d.clamp=d3.rebind(d,c.clamp);return d}function Q(a){a.setTime(a.getTime()+36e5)}function P(a,b){return function(c,d){var e=a(c),f=[];e<c&&b(e);while(e<d)f.push(new Date(+e)),b(e);return f}}function O(){this._=new Date(Date.UTC.apply(this,arguments))}function N(a){var b=a.getTimezoneOffset(),d=b>0?"-":"+",e=~~(Math.abs(b)/60),f=Math.abs(b)%60;return d+c(e)+c(f)}function M(a){var b=J(a);return c(~~(((a-b)/864e5+(b.getDay()+6)%7)/7))}function L(a){var b=J(a);return c(~~(((a-b)/864e5+b.getDay())/7))}function K(a){return d(1+~~((a-J(a))/864e5))}function J(b){return new a(b.getFullYear(),0,1)}function H(a,b,c){var d=I[b.substring(c,c+=2).toLowerCase()];return d==null?-1:(a.hour12pm=d,c)}function F(a,b,c){G.lastIndex=0;var d=G.exec(b.substring(c,c+2));return d?(a.setSeconds(+d[0]),c+=d[0].length):-1}function E(a,b,c){G.lastIndex=0;var d=G.exec(b.substring(c,c+2));return d?(a.setMinutes(+d[0]),c+=d[0].length):-1}function D(a,b,c){a.hour12=!0;return C(a,b,c)}function C(a,b,c){G.lastIndex=0;var d=G.exec(b.substring(c,c+2));return d?(a.setHours(+d[0]),c+=d[0].length):-1}function B(a,b,c){G.lastIndex=0;var d=G.exec(b.substring(c,c+2));return d?(a.setDate(+d[0]),c+=d[0].length):-1}function A(a,b,c){G.lastIndex=0;var d=G.exec(b.substring(c,c+2));return d?(a.setMonth(d[0]-1),c+=d[0].length):-1}function z(){return~~((new Date).getFullYear()/1e3)*1e3}function y(a,b,c){G.lastIndex=0;var d=G.exec(b.substring(c,c+2));return d?(a.setFullYear(z()+ +d[0]),c+=d[0].length):-1}function x(a,b,c){G.lastIndex=0;var d=G.exec(b.substring(c,c+4));return d?(a.setFullYear(d[0]),c+=d[0].length):-1}function w(a,c,d){return b(a,g.X.toString(),c,d)}function v(a,c,d){return b(a,g.x.toString(),c,d)}function u(a,c,d){return b(a,g.c.toString(),c,d)}function q(a,b,c){r.lastIndex=0;var d=r.exec(b.substring(c,c+12));return d?(a.setMonth(s[d[0].toLowerCase()]),c+=d[0].length):-1}function o(a,b,c){var d=p[b.substring(c,c+=3).toLowerCase()];return d==null?-1:(a.setMonth(d),c)}function l(a,b,c){m.lastIndex=0;var d=m.exec(b.substring(c,c+10));return d?c+=d[0].length:-1}function j(a,b,c){return b.substring(c,c+=3).toLowerCase()in k?c:-1}function b(a,b,c,d){var e,f,g=0,i=b.length,j=c.length;while(g<i){if(d>=j)return-1;e=b.charCodeAt(g++);if(e==37){f=h[b.charAt(g++)];if(!f||(d=f(a,c,d))<0)return-1}else if(e!=c.charCodeAt(d++))return-1}return d}d3.time={};var a=Date;d3.time.format=function(c){function e(a){var b=[],e=-1,f=0,h,i;while(++e<d)c.charCodeAt(e)==37&&(b.push(c.substring(f,e),(i=g[h=c.charAt(++e)])?i(a):h),f=e+1);b.push(c.substring(f,e));return b.join("")}var d=c.length;e.parse=function(d){var e=new a(1900,0,1),f=b(e,c,d,0);if(f!=d.length)return null;if(e.hour12){var g=e.getHours()%12;e.setHours(e.hour12pm?g+12:g)}delete e.hour12,delete e.hour12pm;return e},e.toString=function(){return c};return e};var c=d3.format("02d"),d=d3.format("03d"),e=d3.format("04d"),f=d3.format("2d"),g={a:function(a){return n[a.getDay()].substring(0,3)},A:function(a){return n[a.getDay()]},b:function(a){return t[a.getMonth()].substring(0,3)},B:function(a){return t[a.getMonth()]},c:d3.time.format("%a %b %e %H:%M:%S %Y"),d:function(a){return c(a.getDate())},e:function(a){return f(a.getDate())},H:function(a){return c(a.getHours())},I:function(a){return c(a.getHours()%12||12)},j:K,m:function(a){return c(a.getMonth()+1)},M:function(a){return c(a.getMinutes())},p:function(a){return a.getHours()>=12?"PM":"AM"},S:function(a){return c(a.getSeconds())},U:L,w:function(a){return a.getDay()},W:M,x:d3.time.format("%m/%d/%y"),X:d3.time.format("%H:%M:%S"),y:function(a){return c(a.getFullYear()%100)},Y:function(a){return e(a.getFullYear()%1e4)},Z:N,"%":function(a){return"%"}},h={a:j,A:l,b:o,B:q,c:u,d:B,e:B,H:C,I:D,m:A,M:E,p:H,S:F,x:v,X:w,y:y,Y:x},k={sun:3,mon:3,tue:3,wed:3,thu:3,fri:3,sat:3},m=/^(?:Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday)/ig,n=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],p={jan:0,feb:1,mar:2,apr:3,may:4,jun:5,jul:6,aug:7,sep:8,oct:9,nov:10,dec:11},r=/^(?:January|February|March|April|May|June|July|August|September|October|November|December)/ig,s={january:0,february:1,march:2,april:3,may:4,june:5,july:6,august:7,september:8,october:9,november:10,december:11},t=["January","February","March","April","May","June","July","August","September","October","November","December"],G=/\s*\d+/,I={am:0,pm:1};d3.time.format.utc=function(b){function d(a){var b=new O;b._=a;return c(b)}var c=d3.time.format(b);d.parse=function(b){try{a=O;var d=c.parse(b);return d&&d._}finally{a=Date}},d.toString=c.toString;return d},O.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()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.getTime()},setDate:function(a){this._.setUTCDate(a)},setDay:function(a){this._.setUTCDay(a)},setFullYear:function(a){this._.setUTCFullYear(a)},setHours:function(a){this._.setUTCHours(a)},setMilliseconds:function(a){this._.setUTCMilliseconds(a)},setMinutes:function(a){this._.setUTCMinutes(a)},setMonth:function(a){this._.setUTCMonth(a)},setSeconds:function(a){this._.setUTCSeconds(a)}},d3.time.format.iso=d3.time.format.utc("%Y-%m-%dT%H:%M:%SZ"),d3.time.second=function(a){return new Date(~~(a/1e3)*1e3)},d3.time.second.utc=d3.time.second,d3.time.seconds=P(d3.time.second,function(a){a.setTime(a.getTime()+1e3)}),d3.time.seconds.utc=d3.time.seconds,d3.time.minute=function(a){return new Date(~~(a/6e4)*6e4)},d3.time.minute.utc=d3.time.minute,d3.time.minutes=P(d3.time.minute,function(a){a.setTime(a.getTime()+6e4)}),d3.time.minutes.utc=d3.time.minutes,d3.time.hour=function(a){var b=a.getTimezoneOffset()/60;return new Date((~~(a/36e5-b)+b)*36e5)},d3.time.hour.utc=function(a){return new Date(~~(a/36e5)*36e5)},d3.time.hours=P(d3.time.hour,Q),d3.time.hours.utc=P(d3.time.hour.utc,Q),d3.time.day=function(a){return new Date(a.getFullYear(),a.getMonth(),a.getDate())},d3.time.day.utc=function(a){return new Date(~~(a/864e5)*864e5)},d3.time.days=P(d3.time.day,function(a){a.setDate(a.getDate()+1)}),d3.time.days.utc=P(d3.time.day.utc,function(a){a.setUTCDate(a.getUTCDate()+1)}),d3.time.week=function(a){(a=d3.time.day(a)).setDate(a.getDate()-a.getDay());return a},d3.time.week.utc=function(a){(a=d3.time.day.utc(a)).setUTCDate(a.getUTCDate()-a.getUTCDay());return a},d3.time.weeks=P(d3.time.week,function(a){a.setDate(a.getDate()+7)}),d3.time.weeks.utc=P(d3.time.week.utc,function(a){a.setUTCDate(a.getUTCDate()+7)}),d3.time.month=function(a){return new Date(a.getFullYear(),a.getMonth(),1)},d3.time.month.utc=function(a){return new Date(Date.UTC(a.getUTCFullYear(),a.getUTCMonth(),1))},d3.time.months=P(d3.time.month,function(a){a.setMonth(a.getMonth()+1)}),d3.time.months.utc=P(d3.time.month.utc,function(a){a.setUTCMonth(a.getUTCMonth()+1)}),d3.time.year=function(a){return new Date(a.getFullYear(),0,1)},d3.time.year.utc=function(a){return new Date(Date.UTC(a.getUTCFullYear(),0,1))},d3.time.years=P(d3.time.year,function(a){a.setFullYear(a.getFullYear()+1)}),d3.time.years.utc=P(d3.time.year.utc,function(a){a.setUTCFullYear(a.getUTCFullYear()+1)});var V=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,1728e6,7776e6,31536e6],W=[d3.time.seconds,function(a,b){return d3.time.seconds(a,b).filter(function(a){return!(a.getSeconds()%5)})},function(a,b){return d3.time.seconds(a,b).filter(function(a){return!(a.getSeconds()%15)})},function(a,b){return d3.time.seconds(a,b).filter(function(a){return!(a.getSeconds()%30)})},d3.time.minutes,function(a,b){return d3.time.minutes(a,b).filter(function(a){return!(a.getMinutes()%5)})},function(a,b){return d3.time.minutes(a,b).filter(function(a){return!(a.getMinutes()%15)})},function(a,b){return d3.time.minutes(a,b).filter(function(a){return!(a.getMinutes()%30)})},d3.time.hours,function(a,b){return d3.time.hours(a,b).filter(function(a){return!(a.getHours()%3)})},function(a,b){return d3.time.hours(a,b).filter(function(a){return!(a.getHours()%6)})},function(a,b){return d3.time.hours(a,b).filter(function(a){return!(a.getHours()%12)})},d3.time.days,function(a,b){return d3.time.days(a,b).filter(function(a){return a.getDate()%2})},d3.time.weeks,d3.time.months,function(a,b){return d3.time.months(a,b).filter(function(a){return!(a.getMonth()%3)})},d3.time.years],X=[[d3.time.format("%Y"),function(a){return!0}],[d3.time.format("%B"),function(a){return a.getMonth()}],[d3.time.format("%b %d"),function(a){return a.getDate()!=1}],[d3.time.format("%a %d"),function(a){return a.getDay()&&a.getDate()!=1}],[d3.time.format("%I %p"),function(a){return a.getHours()}],[d3.time.format("%I:%M"),function(a){return a.getMinutes()}],[d3.time.format(":%S"),function(a){return a.getSeconds()||a.getMilliseconds()}]],Y=U(X);d3.time.scale=function(){return R(W,Y)};var Z=[d3.time.seconds.utc,function(a,b){return d3.time.seconds.utc(a,b).filter(function(a){return!(a.getUTCSeconds()%5)})},function(a,b){return d3.time.seconds.utc(a,b).filter(function(a){return!(a.getUTCSeconds()%15)})},function(a,b){return d3.time.seconds.utc(a,b).filter(function(a){return!(a.getUTCSeconds()%30)})},d3.time.minutes.utc,function(a,b){return d3.time.minutes.utc(a,b).filter(function(a){return!(a.getUTCMinutes()%5)})},function(a,b){return d3.time.minutes.utc(a,b).filter(function(a){return!(a.getUTCMinutes()%15)})},function(a,b){return d3.time.minutes.utc(a,b).filter(function(a){return!(a.getUTCMinutes()%30)})},d3.time.hours.utc,function(a,b){return d3.time.hours.utc(a,b).filter(function(a){return!(a.getUTCHours()%3)})},function(a,b){return d3.time.hours.utc(a,b).filter(function(a){return!(a.getUTCHours()%6)})},function(a,b){return d3.time.hours.utc(a,b).filter(function(a){return!(a.getUTCHours()%12)})},d3.time.days.utc,function(a,b){return d3.time.days.utc(a,b).filter(function(a){return a.getUTCDate()%2})},d3.time.weeks.utc,d3.time.months.utc,function(a,b){return d3.time.months.utc(a,b).filter(function(a){return!(a.getUTCMonth()%3)})},d3.time.years.utc],$=[[d3.time.format.utc("%Y"),function(a){return!0}],[d3.time.format.utc("%B"),function(a){return a.getUTCMonth()}],[d3.time.format.utc("%b %d"),function(a){return a.getUTCDate()!=1}],[d3.time.format.utc("%a %d"),function(a){return a.getUTCDay()&&a.getUTCDate()!=1}],[d3.time.format.utc("%I %p"),function(a){return a.getUTCHours()}],[d3.time.format.utc("%I:%M"),function(a){return a.getUTCMinutes()}],[d3.time.format.utc(":%S"),function(a){return a.getUTCSeconds()||a.getUTCMilliseconds()}]],_=U($);d3.time.scale.utc=function(){return R(Z,_)}})()