You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2 lines
8.8 KiB

5 years ago
// https://d3js.org/d3-time-format/ Version 2.1.1. Copyright 2017 Mike Bostock.
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("d3-time")):"function"==typeof define&&define.amd?define(["exports","d3-time"],t):t(e.d3=e.d3||{},e.d3)}(this,function(e,t){"use strict";function n(e){if(0<=e.y&&e.y<100){var t=new Date(-1,e.m,e.d,e.H,e.M,e.S,e.L);return t.setFullYear(e.y),t}return new Date(e.y,e.m,e.d,e.H,e.M,e.S,e.L)}function r(e){if(0<=e.y&&e.y<100){var t=new Date(Date.UTC(-1,e.m,e.d,e.H,e.M,e.S,e.L));return t.setUTCFullYear(e.y),t}return new Date(Date.UTC(e.y,e.m,e.d,e.H,e.M,e.S,e.L))}function u(e){return{y:e,m:0,d:1,H:0,M:0,S:0,L:0}}function c(e){function c(e,t){return function(n){var r,u,c,i=[],o=-1,a=0,f=e.length;for(n instanceof Date||(n=new Date(+n));++o<f;)37===e.charCodeAt(o)&&(i.push(e.slice(a,o)),null!=(u=de[r=e.charAt(++o)])?r=e.charAt(++o):u="e"===r?" ":"0",(c=t[r])&&(r=c(n,u)),i.push(r),a=o+1);return i.push(e.slice(a,o)),i.join("")}}function i(e,n){return function(c){var i,a,f=u(1900);if(o(f,e,c+="",0)!=c.length)return null;if("Q"in f)return new Date(f.Q);if("p"in f&&(f.H=f.H%12+12*f.p),"V"in f){if(f.V<1||f.V>53)return null;"w"in f||(f.w=1),"Z"in f?(i=(a=(i=r(u(f.y))).getUTCDay())>4||0===a?t.utcMonday.ceil(i):t.utcMonday(i),i=t.utcDay.offset(i,7*(f.V-1)),f.y=i.getUTCFullYear(),f.m=i.getUTCMonth(),f.d=i.getUTCDate()+(f.w+6)%7):(i=(a=(i=n(u(f.y))).getDay())>4||0===a?t.timeMonday.ceil(i):t.timeMonday(i),i=t.timeDay.offset(i,7*(f.V-1)),f.y=i.getFullYear(),f.m=i.getMonth(),f.d=i.getDate()+(f.w+6)%7)}else("W"in f||"U"in f)&&("w"in f||(f.w="u"in f?f.u%7:"W"in f?1:0),a="Z"in f?r(u(f.y)).getUTCDay():n(u(f.y)).getDay(),f.m=0,f.d="W"in f?(f.w+6)%7+7*f.W-(a+5)%7:f.w+7*f.U-(a+6)%7);return"Z"in f?(f.H+=f.Z/100|0,f.M+=f.Z%100,r(f)):n(f)}}function o(e,t,n,r){for(var u,c,i=0,o=t.length,a=n.length;i<o;){if(r>=a)return-1;if(37===(u=t.charCodeAt(i++))){if(u=t.charAt(i++),!(c=be[u in de?t.charAt(i++):u])||(r=c(e,n,r))<0)return-1}else if(u!=n.charCodeAt(r++))return-1}return r}var ge=e.dateTime,ye=e.date,he=e.time,me=e.periods,ve=e.days,Me=e.shortDays,Te=e.months,De=e.shortMonths,Ce=a(me),xe=f(me),Ue=a(ve),pe=f(ve),we=a(Me),Se=f(Me),Ye=a(Te),Fe=f(Te),He=a(De),Le=f(De),Ae={a:function(e){return Me[e.getDay()]},A:function(e){return ve[e.getDay()]},b:function(e){return De[e.getMonth()]},B:function(e){return Te[e.getMonth()]},c:null,d:H,e:H,f:W,H:L,I:A,j:Z,L:b,m:V,M:j,p:function(e){return me[+(e.getHours()>=12)]},Q:le,s:se,S:P,u:Q,U:I,V:J,w:O,W:X,x:null,X:null,y:N,Y:B,Z:_,"%":fe},Ze={a:function(e){return Me[e.getUTCDay()]},A:function(e){return ve[e.getUTCDay()]},b:function(e){return De[e.getUTCMonth()]},B:function(e){return Te[e.getUTCMonth()]},c:null,d:$,e:$,f:k,H:q,I:z,j:E,L:R,m:G,M:K,p:function(e){return me[+(e.getUTCHours()>=12)]},Q:le,s:se,S:ee,u:te,U:ne,V:re,w:ue,W:ce,x:null,X:null,y:ie,Y:oe,Z:ae,"%":fe},be={a:function(e,t,n){var r=we.exec(t.slice(n));return r?(e.w=Se[r[0].toLowerCase()],n+r[0].length):-1},A:function(e,t,n){var r=Ue.exec(t.slice(n));return r?(e.w=pe[r[0].toLowerCase()],n+r[0].length):-1},b:function(e,t,n){var r=He.exec(t.slice(n));return r?(e.m=Le[r[0].toLowerCase()],n+r[0].length):-1},B:function(e,t,n){var r=Ye.exec(t.slice(n));return r?(e.m=Fe[r[0].toLowerCase()],n+r[0].length):-1},c:function(e,t,n){return o(e,ge,t,n)},d:T,e:T,f:w,H:C,I:C,j:D,L:p,m:M,M:x,p:function(e,t,n){var r=Ce.exec(t.slice(n));return r?(e.p=xe[r[0].toLowerCase()],n+r[0].length):-1},Q:Y,s:F,S:U,u:s,U:g,V:y,w:l,W:d,x:function(e,t,n){return o(e,ye,t,n)},X:function(e,t,n){return o(e,he,t,n)},y:m,Y:h,Z:v,"%":S};return Ae.x=c(ye,Ae),Ae.X=c(he,Ae),Ae.c=c(ge,Ae),Ze.x=c(ye,Ze),Ze.X=c(he,Ze),Ze.c=c(ge,Ze),{format:function(e){var t=c(e+="",Ae);return t.toString=function(){return e},t},parse:function(e){var t=i(e+="",n);return t.toString=function(){return e},t},utcFormat:function(e){var t=c(e+="",Ze);return t.toString=function(){return e},t},utcParse:function(e){var t=i(e,r);return t.toString=function(){return e},t}}}function i(e,t,n){var r=e<0?"-":"",u=(r?-e:e)+"",c=u.length;return r+(c<n?new Array(n-c+1).join(t)+u:u)}function o(e){return e.replace(ve,"\\$&")}function a(e){return new RegExp("^(?: