UNPKG

date-fns

Version:

Modern JavaScript date utility library

4 lines (2 loc) 12.7 kB
(()=>{var x;function M(B,G){var J=Object.keys(B);if(Object.getOwnPropertySymbols){var X=Object.getOwnPropertySymbols(B);G&&(X=X.filter(function(Z){return Object.getOwnPropertyDescriptor(B,Z).enumerable})),J.push.apply(J,X)}return J}function A(B){for(var G=1;G<arguments.length;G++){var J=arguments[G]!=null?arguments[G]:{};G%2?M(Object(J),!0).forEach(function(X){L(B,X,J[X])}):Object.getOwnPropertyDescriptors?Object.defineProperties(B,Object.getOwnPropertyDescriptors(J)):M(Object(J)).forEach(function(X){Object.defineProperty(B,X,Object.getOwnPropertyDescriptor(J,X))})}return B}function L(B,G,J){if(G=O(G),G in B)Object.defineProperty(B,G,{value:J,enumerable:!0,configurable:!0,writable:!0});else B[G]=J;return B}function O(B){var G=P(B,"string");return K(G)=="symbol"?G:String(G)}function P(B,G){if(K(B)!="object"||!B)return B;var J=B[Symbol.toPrimitive];if(J!==void 0){var X=J.call(B,G||"default");if(K(X)!="object")return X;throw new TypeError("@@toPrimitive must return a primitive value.")}return(G==="string"?String:Number)(B)}function w(B,G){return h(B)||F(B,G)||v(B,G)||D()}function D(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function v(B,G){if(!B)return;if(typeof B==="string")return R(B,G);var J=Object.prototype.toString.call(B).slice(8,-1);if(J==="Object"&&B.constructor)J=B.constructor.name;if(J==="Map"||J==="Set")return Array.from(B);if(J==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(J))return R(B,G)}function R(B,G){if(G==null||G>B.length)G=B.length;for(var J=0,X=new Array(G);J<G;J++)X[J]=B[J];return X}function F(B,G){var J=B==null?null:typeof Symbol!="undefined"&&B[Symbol.iterator]||B["@@iterator"];if(J!=null){var X,Z,C,U,H=[],Y=!0,Q=!1;try{if(C=(J=J.call(B)).next,G===0){if(Object(J)!==J)return;Y=!1}else for(;!(Y=(X=C.call(J)).done)&&(H.push(X.value),H.length!==G);Y=!0);}catch(q){Q=!0,Z=q}finally{try{if(!Y&&J.return!=null&&(U=J.return(),Object(U)!==U))return}finally{if(Q)throw Z}}return H}}function h(B){if(Array.isArray(B))return B}function K(B){return K=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(G){return typeof G}:function(G){return G&&typeof Symbol=="function"&&G.constructor===Symbol&&G!==Symbol.prototype?"symbol":typeof G},K(B)}var k=Object.defineProperty,$B=function B(G,J){for(var X in J)k(G,X,{get:J[X],enumerable:!0,configurable:!0,set:function Z(C){return J[X]=function(){return C}}})},b={lessThanXSeconds:{one:"\u4E0D\u5230 1 \u79D2",other:"\u4E0D\u5230 {{count}} \u79D2"},xSeconds:{one:"1 \u79D2",other:"{{count}} \u79D2"},halfAMinute:"\u534A\u5206\u949F",lessThanXMinutes:{one:"\u4E0D\u5230 1 \u5206\u949F",other:"\u4E0D\u5230 {{count}} \u5206\u949F"},xMinutes:{one:"1 \u5206\u949F",other:"{{count}} \u5206\u949F"},xHours:{one:"1 \u5C0F\u65F6",other:"{{count}} \u5C0F\u65F6"},aboutXHours:{one:"\u5927\u7EA6 1 \u5C0F\u65F6",other:"\u5927\u7EA6 {{count}} \u5C0F\u65F6"},xDays:{one:"1 \u5929",other:"{{count}} \u5929"},aboutXWeeks:{one:"\u5927\u7EA6 1 \u4E2A\u661F\u671F",other:"\u5927\u7EA6 {{count}} \u4E2A\u661F\u671F"},xWeeks:{one:"1 \u4E2A\u661F\u671F",other:"{{count}} \u4E2A\u661F\u671F"},aboutXMonths:{one:"\u5927\u7EA6 1 \u4E2A\u6708",other:"\u5927\u7EA6 {{count}} \u4E2A\u6708"},xMonths:{one:"1 \u4E2A\u6708",other:"{{count}} \u4E2A\u6708"},aboutXYears:{one:"\u5927\u7EA6 1 \u5E74",other:"\u5927\u7EA6 {{count}} \u5E74"},xYears:{one:"1 \u5E74",other:"{{count}} \u5E74"},overXYears:{one:"\u8D85\u8FC7 1 \u5E74",other:"\u8D85\u8FC7 {{count}} \u5E74"},almostXYears:{one:"\u5C06\u8FD1 1 \u5E74",other:"\u5C06\u8FD1 {{count}} \u5E74"}},f=function B(G,J,X){var Z,C=b[G];if(typeof C==="string")Z=C;else if(J===1)Z=C.one;else Z=C.other.replace("{{count}}",String(J));if(X!==null&&X!==void 0&&X.addSuffix)if(X.comparison&&X.comparison>0)return Z+"\u5185";else return Z+"\u524D";return Z};function I(B){return function(){var G=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},J=G.width?String(G.width):B.defaultWidth,X=B.formats[J]||B.formats[B.defaultWidth];return X}}var y={full:"y'\u5E74'M'\u6708'd'\u65E5' EEEE",long:"y'\u5E74'M'\u6708'd'\u65E5'",medium:"yyyy-MM-dd",short:"yy-MM-dd"},_={full:"zzzz a h:mm:ss",long:"z a h:mm:ss",medium:"a h:mm:ss",short:"a h:mm"},m={full:"{{date}} {{time}}",long:"{{date}} {{time}}",medium:"{{date}} {{time}}",short:"{{date}} {{time}}"},g={date:I({formats:y,defaultWidth:"full"}),time:I({formats:_,defaultWidth:"full"}),dateTime:I({formats:m,defaultWidth:"full"})},jB=7,c=365.2425,u=Math.pow(10,8)*24*60*60*1000,LB=-u,OB=604800000,PB=86400000,wB=60000,DB=3600000,vB=1000,FB=525600,hB=43200,kB=1440,bB=60,fB=3,yB=12,_B=4,d=3600,mB=60,z=d*24,gB=z*7,p=z*c,l=p/12,cB=l*3,V=Symbol.for("constructDateFrom");function W(B,G){if(typeof B==="function")return B(G);if(B&&K(B)==="object"&&V in B)return B[V](G);if(B instanceof Date)return new B.constructor(G);return new Date(G)}function i(B){for(var G=arguments.length,J=new Array(G>1?G-1:0),X=1;X<G;X++)J[X-1]=arguments[X];var Z=W.bind(null,B||J.find(function(C){return K(C)==="object"}));return J.map(Z)}function s(){return S}function uB(B){S=B}var S={};function n(B,G){return W(G||B,B)}function $(B,G){var J,X,Z,C,U,H,Y=s(),Q=(J=(X=(Z=(C=G===null||G===void 0?void 0:G.weekStartsOn)!==null&&C!==void 0?C:G===null||G===void 0||(U=G.locale)===null||U===void 0||(U=U.options)===null||U===void 0?void 0:U.weekStartsOn)!==null&&Z!==void 0?Z:Y.weekStartsOn)!==null&&X!==void 0?X:(H=Y.locale)===null||H===void 0||(H=H.options)===null||H===void 0?void 0:H.weekStartsOn)!==null&&J!==void 0?J:0,q=n(B,G===null||G===void 0?void 0:G.in),E=q.getDay(),SB=(E<Q?7:0)+E-Q;return q.setDate(q.getDate()-SB),q.setHours(0,0,0,0),q}function r(B,G,J){var X=i(J===null||J===void 0?void 0:J.in,B,G),Z=w(X,2),C=Z[0],U=Z[1];return+$(C,J)===+$(U,J)}function j(B,G,J){var X="eeee p";if(r(B,G,J))return X;else if(B.getTime()>G.getTime())return"'\u4E0B\u4E2A'"+X;return"'\u4E0A\u4E2A'"+X}var o={lastWeek:j,yesterday:"'\u6628\u5929' p",today:"'\u4ECA\u5929' p",tomorrow:"'\u660E\u5929' p",nextWeek:j,other:"PP p"},a=function B(G,J,X,Z){var C=o[G];if(typeof C==="function")return C(J,X,Z);return C};function N(B){return function(G,J){var X=J!==null&&J!==void 0&&J.context?String(J.context):"standalone",Z;if(X==="formatting"&&B.formattingValues){var C=B.defaultFormattingWidth||B.defaultWidth,U=J!==null&&J!==void 0&&J.width?String(J.width):C;Z=B.formattingValues[U]||B.formattingValues[C]}else{var H=B.defaultWidth,Y=J!==null&&J!==void 0&&J.width?String(J.width):B.defaultWidth;Z=B.values[Y]||B.values[H]}var Q=B.argumentCallback?B.argumentCallback(G):G;return Z[Q]}}var e={narrow:["\u524D","\u516C\u5143"],abbreviated:["\u524D","\u516C\u5143"],wide:["\u516C\u5143\u524D","\u516C\u5143"]},t={narrow:["1","2","3","4"],abbreviated:["\u7B2C\u4E00\u5B63","\u7B2C\u4E8C\u5B63","\u7B2C\u4E09\u5B63","\u7B2C\u56DB\u5B63"],wide:["\u7B2C\u4E00\u5B63\u5EA6","\u7B2C\u4E8C\u5B63\u5EA6","\u7B2C\u4E09\u5B63\u5EA6","\u7B2C\u56DB\u5B63\u5EA6"]},BB={narrow:["\u4E00","\u4E8C","\u4E09","\u56DB","\u4E94","\u516D","\u4E03","\u516B","\u4E5D","\u5341","\u5341\u4E00","\u5341\u4E8C"],abbreviated:["1\u6708","2\u6708","3\u6708","4\u6708","5\u6708","6\u6708","7\u6708","8\u6708","9\u6708","10\u6708","11\u6708","12\u6708"],wide:["\u4E00\u6708","\u4E8C\u6708","\u4E09\u6708","\u56DB\u6708","\u4E94\u6708","\u516D\u6708","\u4E03\u6708","\u516B\u6708","\u4E5D\u6708","\u5341\u6708","\u5341\u4E00\u6708","\u5341\u4E8C\u6708"]},GB={narrow:["\u65E5","\u4E00","\u4E8C","\u4E09","\u56DB","\u4E94","\u516D"],short:["\u65E5","\u4E00","\u4E8C","\u4E09","\u56DB","\u4E94","\u516D"],abbreviated:["\u5468\u65E5","\u5468\u4E00","\u5468\u4E8C","\u5468\u4E09","\u5468\u56DB","\u5468\u4E94","\u5468\u516D"],wide:["\u661F\u671F\u65E5","\u661F\u671F\u4E00","\u661F\u671F\u4E8C","\u661F\u671F\u4E09","\u661F\u671F\u56DB","\u661F\u671F\u4E94","\u661F\u671F\u516D"]},JB={narrow:{am:"\u4E0A",pm:"\u4E0B",midnight:"\u51CC\u6668",noon:"\u5348",morning:"\u65E9",afternoon:"\u4E0B\u5348",evening:"\u665A",night:"\u591C"},abbreviated:{am:"\u4E0A\u5348",pm:"\u4E0B\u5348",midnight:"\u51CC\u6668",noon:"\u4E2D\u5348",morning:"\u65E9\u6668",afternoon:"\u4E2D\u5348",evening:"\u665A\u4E0A",night:"\u591C\u95F4"},wide:{am:"\u4E0A\u5348",pm:"\u4E0B\u5348",midnight:"\u51CC\u6668",noon:"\u4E2D\u5348",morning:"\u65E9\u6668",afternoon:"\u4E2D\u5348",evening:"\u665A\u4E0A",night:"\u591C\u95F4"}},XB={narrow:{am:"\u4E0A",pm:"\u4E0B",midnight:"\u51CC\u6668",noon:"\u5348",morning:"\u65E9",afternoon:"\u4E0B\u5348",evening:"\u665A",night:"\u591C"},abbreviated:{am:"\u4E0A\u5348",pm:"\u4E0B\u5348",midnight:"\u51CC\u6668",noon:"\u4E2D\u5348",morning:"\u65E9\u6668",afternoon:"\u4E2D\u5348",evening:"\u665A\u4E0A",night:"\u591C\u95F4"},wide:{am:"\u4E0A\u5348",pm:"\u4E0B\u5348",midnight:"\u51CC\u6668",noon:"\u4E2D\u5348",morning:"\u65E9\u6668",afternoon:"\u4E2D\u5348",evening:"\u665A\u4E0A",night:"\u591C\u95F4"}},ZB=function B(G,J){var X=Number(G);switch(J===null||J===void 0?void 0:J.unit){case"date":return X.toString()+"\u65E5";case"hour":return X.toString()+"\u65F6";case"minute":return X.toString()+"\u5206";case"second":return X.toString()+"\u79D2";default:return"\u7B2C "+X.toString()}},CB={ordinalNumber:ZB,era:N({values:e,defaultWidth:"wide"}),quarter:N({values:t,defaultWidth:"wide",argumentCallback:function B(G){return G-1}}),month:N({values:BB,defaultWidth:"wide"}),day:N({values:GB,defaultWidth:"wide"}),dayPeriod:N({values:JB,defaultWidth:"wide",formattingValues:XB,defaultFormattingWidth:"wide"})};function T(B){return function(G){var J=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},X=J.width,Z=X&&B.matchPatterns[X]||B.matchPatterns[B.defaultMatchWidth],C=G.match(Z);if(!C)return null;var U=C[0],H=X&&B.parsePatterns[X]||B.parsePatterns[B.defaultParseWidth],Y=Array.isArray(H)?HB(H,function(E){return E.test(U)}):UB(H,function(E){return E.test(U)}),Q;Q=B.valueCallback?B.valueCallback(Y):Y,Q=J.valueCallback?J.valueCallback(Q):Q;var q=G.slice(U.length);return{value:Q,rest:q}}}function UB(B,G){for(var J in B)if(Object.prototype.hasOwnProperty.call(B,J)&&G(B[J]))return J;return}function HB(B,G){for(var J=0;J<B.length;J++)if(G(B[J]))return J;return}function QB(B){return function(G){var J=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},X=G.match(B.matchPattern);if(!X)return null;var Z=X[0],C=G.match(B.parsePattern);if(!C)return null;var U=B.valueCallback?B.valueCallback(C[0]):C[0];U=J.valueCallback?J.valueCallback(U):U;var H=G.slice(Z.length);return{value:U,rest:H}}}var YB=/^(第\s*)?\d+(日|时|分|秒)?/i,qB=/\d+/i,KB={narrow:/^(前)/i,abbreviated:/^(前)/i,wide:/^(公元前|公元)/i},EB={any:[/^(前)/i,/^(公元)/i]},NB={narrow:/^[1234]/i,abbreviated:/^第[一二三四]刻/i,wide:/^第[一二三四]刻钟/i},TB={any:[/(1|一)/i,/(2|二)/i,/(3|三)/i,/(4|四)/i]},AB={narrow:/^(一|二|三|四|五|六|七|八|九|十[二一])/i,abbreviated:/^(一|二|三|四|五|六|七|八|九|十[二一]|\d|1[12])月/i,wide:/^(一|二|三|四|五|六|七|八|九|十[二一])月/i},xB={narrow:[/^一/i,/^二/i,/^三/i,/^四/i,/^五/i,/^六/i,/^七/i,/^八/i,/^九/i,/^十(?!(一|二))/i,/^十一/i,/^十二/i],any:[/^一|1/i,/^二|2/i,/^三|3/i,/^四|4/i,/^五|5/i,/^六|6/i,/^七|7/i,/^八|8/i,/^九|9/i,/^十(?!(一|二))|10/i,/^十一|11/i,/^十二|12/i]},IB={narrow:/^[一二三四五六日]/i,short:/^[一二三四五六日]/i,abbreviated:/^周[一二三四五六日]/i,wide:/^星期[一二三四五六日]/i},MB={any:[/日/i,/一/i,/二/i,/三/i,/四/i,/五/i,/六/i]},RB={any:/^(上午?|下午?|午夜|[中正]午|早上?|下午|晚上?|凌晨|)/i},zB={any:{am:/^上午?/i,pm:/^下午?/i,midnight:/^午夜/i,noon:/^[中正]午/i,morning:/^早上/i,afternoon:/^下午/i,evening:/^晚上?/i,night:/^凌晨/i}},VB={ordinalNumber:QB({matchPattern:YB,parsePattern:qB,valueCallback:function B(G){return parseInt(G,10)}}),era:T({matchPatterns:KB,defaultMatchWidth:"wide",parsePatterns:EB,defaultParseWidth:"any"}),quarter:T({matchPatterns:NB,defaultMatchWidth:"wide",parsePatterns:TB,defaultParseWidth:"any",valueCallback:function B(G){return G+1}}),month:T({matchPatterns:AB,defaultMatchWidth:"wide",parsePatterns:xB,defaultParseWidth:"any"}),day:T({matchPatterns:IB,defaultMatchWidth:"wide",parsePatterns:MB,defaultParseWidth:"any"}),dayPeriod:T({matchPatterns:RB,defaultMatchWidth:"any",parsePatterns:zB,defaultParseWidth:"any"})},WB={code:"zh-CN",formatDistance:f,formatLong:g,formatRelative:a,localize:CB,match:VB,options:{weekStartsOn:1,firstWeekContainsDate:4}};window.dateFns=A(A({},window.dateFns),{},{locale:A(A({},(x=window.dateFns)===null||x===void 0?void 0:x.locale),{},{zhCN:WB})})})(); //# debugId=7118A3E3748B854D64756E2164756E21