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

// 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("^(?:"+e.map(o).join("|")+")","i")}function f(e){for(var t={},n=-1,r=e.length;++n<r;)t[e[n].toLowerCase()]=n;return t}function l(e,t,n){var r=he.exec(t.slice(n,n+1));return r?(e.w=+r[0],n+r[0].length):-1}function s(e,t,n){var r=he.exec(t.slice(n,n+1));return r?(e.u=+r[0],n+r[0].length):-1}function g(e,t,n){var r=he.exec(t.slice(n,n+2));return r?(e.U=+r[0],n+r[0].length):-1}function y(e,t,n){var r=he.exec(t.slice(n,n+2));return r?(e.V=+r[0],n+r[0].length):-1}function d(e,t,n){var r=he.exec(t.slice(n,n+2));return r?(e.W=+r[0],n+r[0].length):-1}function h(e,t,n){var r=he.exec(t.slice(n,n+4));return r?(e.y=+r[0],n+r[0].length):-1}function m(e,t,n){var r=he.exec(t.slice(n,n+2));return r?(e.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function v(e,t,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(n,n+6));return r?(e.Z=r[1]?0:-(r[2]+(r[3]||"00")),n+r[0].length):-1}function M(e,t,n){var r=he.exec(t.slice(n,n+2));return r?(e.m=r[0]-1,n+r[0].length):-1}function T(e,t,n){var r=he.exec(t.slice(n,n+2));return r?(e.d=+r[0],n+r[0].length):-1}function D(e,t,n){var r=he.exec(t.slice(n,n+3));return r?(e.m=0,e.d=+r[0],n+r[0].length):-1}function C(e,t,n){var r=he.exec(t.slice(n,n+2));return r?(e.H=+r[0],n+r[0].length):-1}function x(e,t,n){var r=he.exec(t.slice(n,n+2));return r?(e.M=+r[0],n+r[0].length):-1}function U(e,t,n){var r=he.exec(t.slice(n,n+2));return r?(e.S=+r[0],n+r[0].length):-1}function p(e,t,n){var r=he.exec(t.slice(n,n+3));return r?(e.L=+r[0],n+r[0].length):-1}function w(e,t,n){var r=he.exec(t.slice(n,n+6));return r?(e.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function S(e,t,n){var r=me.exec(t.slice(n,n+1));return r?n+r[0].length:-1}function Y(e,t,n){var r=he.exec(t.slice(n));return r?(e.Q=+r[0],n+r[0].length):-1}function F(e,t,n){var r=he.exec(t.slice(n));return r?(e.Q=1e3*+r[0],n+r[0].length):-1}function H(e,t){return i(e.getDate(),t,2)}function L(e,t){return i(e.getHours(),t,2)}function A(e,t){return i(e.getHours()%12||12,t,2)}function Z(e,n){return i(1+t.timeDay.count(t.timeYear(e),e),n,3)}function b(e,t){return i(e.getMilliseconds(),t,3)}function W(e,t){return b(e,t)+"000"}function V(e,t){return i(e.getMonth()+1,t,2)}function j(e,t){return i(e.getMinutes(),t,2)}function P(e,t){return i(e.getSeconds(),t,2)}function Q(e){var t=e.getDay();return 0===t?7:t}function I(e,n){return i(t.timeSunday.count(t.timeYear(e),e),n,2)}function J(e,n){var r=e.getDay();return e=r>=4||0===r?t.timeThursday(e):t.timeThursday.ceil(e),i(t.timeThursday.count(t.timeYear(e),e)+(4===t.timeYear(e).getDay()),n,2)}function O(e){return e.getDay()}function X(e,n){return i(t.timeMonday.count(t.timeYear(e),e),n,2)}function N(e,t){return i(e.getFullYear()%100,t,2)}function B(e,t){return i(e.getFullYear()%1e4,t,4)}function _(e){var t=e.getTimezoneOffset();return(t>0?"-":(t*=-1,"+"))+i(t/60|0,"0",2)+i(t%60,"0",2)}function $(e,t){return i(e.getUTCDate(),t,2)}function q(e,t){return i(e.getUTCHours(),t,2)}function z(e,t){return i(e.getUTCHours()%12||12,t,2)}function E(e,n){return i(1+t.utcDay.count(t.utcYear(e),e),n,3)}function R(e,t){return i(e.getUTCMilliseconds(),t,3)}function k(e,t){return R(e,t)+"000"}function G(e,t){return i(e.getUTCMonth()+1,t,2)}function K(e,t){return i(e.getUTCMinutes(),t,2)}function ee(e,t){return i(e.getUTCSeconds(),t,2)}function te(e){var t=e.getUTCDay();return 0===t?7:t}function ne(e,n){return i(t.utcSunday.count(t.utcYear(e),e),n,2)}function re(e,n){var r=e.getUTCDay();return e=r>=4||0===r?t.utcThursday(e):t.utcThursday.ceil(e),i(t.utcThursday.count(t.utcYear(e),e)+(4===t.utcYear(e).getUTCDay()),n,2)}function ue(e){return e.getUTCDay()}function ce(e,n){return i(t.utcMonday.count(t.utcYear(e),e),n,2)}function ie(e,t){return i(e.getUTCFullYear()%100,t,2)}function oe(e,t){return i(e.getUTCFullYear()%1e4,t,4)}function ae(){return"+0000"}function fe(){return"%"}function le(e){return+e}function se(e){return Math.floor(+e/1e3)}function ge(t){return ye=c(t),e.timeFormat=ye.format,e.timeParse=ye.parse,e.utcFormat=ye.utcFormat,e.utcParse=ye.utcParse,ye}var ye,de={"-":"",_:" ",0:"0"},he=/^\s*\d+/,me=/^%/,ve=/[\\^$*+?|[\]().{}]/g;ge({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});var Me=Date.prototype.toISOString?function(e){return e.toISOString()}:e.utcFormat("%Y-%m-%dT%H:%M:%S.%LZ"),Te=+new Date("2000-01-01T00:00:00.000Z")?function(e){var t=new Date(e);return isNaN(t)?null:t}:e.utcParse("%Y-%m-%dT%H:%M:%S.%LZ");e.timeFormatDefaultLocale=ge,e.timeFormatLocale=c,e.isoFormat=Me,e.isoParse=Te,Object.defineProperty(e,"__esModule",{value:!0})});