any-date-parser
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -1,1 +0,1 @@ | ||
!function(){var e,t,r,n=e={};function o(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function i(e){if(t===setTimeout)return setTimeout(e,0);if((t===o||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:o}catch(e){t=o}try{r="function"==typeof clearTimeout?clearTimeout:a}catch(e){r=a}}();var u,l=[],s=!1,c=-1;function f(){s&&u&&(s=!1,u.length?l=u.concat(l):c=-1,l.length&&m())}function m(){if(!s){var e=i(f);s=!0;for(var t=l.length;t;){for(u=l,l=[];++c<t;)u&&u[c].run();c=-1,t=l.length}u=null,s=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===a||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function T(e,t){this.fun=e,this.array=t}function y(){}n.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];l.push(new T(e,t)),1!==l.length||s||i(m)},T.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=y,n.addListener=y,n.once=y,n.off=y,n.removeListener=y,n.removeAllListeners=y,n.emit=y,n.prependListener=y,n.prependOnceListener=y,n.listeners=function(e){return[]},n.binding=function(e){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(e){throw new Error("process.chdir is not supported")},n.umask=function(){return 0};var h={};function d(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return v(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?v(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,u=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return i=e.done,e},e:function(e){u=!0,a=e},f:function(){try{i||null==r.return||r.return()}finally{if(u)throw a}}}}function v(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function p(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(function(e){(function(){"use strict";var t;if("undefined"!=typeof navigator){var r=navigator;t=Array.isArray(r.languages)?r.languages[0]:r.language}else if(void 0!==e){var n=e.env;t=n.LC_ALL||n.LC_MESSAGES||n.LANG||n.LANGUAGE}t||(t="en-US"),h=t}).call(this)}).call(this,e);for(var b=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.formats=[]}var t,r;return t=e,(r=[{key:"addFormat",value:function(e){return this.formats.push(e),e.parser=this,this}},{key:"addFormats",value:function(e){var t=this;return e.forEach((function(e){return t.addFormat(e)})),this}},{key:"removeFormat",value:function(e){var t=this.formats.indexOf(e);if(t>-1){var r=this.formats[t];return this.formats.splice(t,1),r.parser=null,!0}return!1}},{key:"attempt",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:h,n=d(this.formats);try{for(n.s();!(t=n.n()).done;){var o=t.value.attempt(e,r);if(o)return o}}catch(i){n.e(i)}finally{n.f()}var a=String(e).slice(0,200);return{invalid:"Unable to parse ".concat(a)}}}])&&p(t.prototype,r),e}(),g={},S=1;S<100;S++)g[(S<9?"0":"")+S]=S+(S>51?1900:2e3);var w={"Eastern Daylight Time":-240,"Eastern Standard Time":-300,"Central Daylight Time":-300,"Central Standard Time":-360,"Mountain Daylight Time":-360,"Mountain Standard Time":-420,"Pacific Daylight Time":-420,"Pacific Standard Time":-480,ACDT:630,ACST:570,ACT:480,ADT:-180,AEDT:660,AEST:600,AFT:270,AKDT:-480,AKST:-540,AMST:-180,AMT:-240,ART:-180,AST:180,AWDT:540,AWST:480,AZOST:-60,AZT:240,BDT:360,BIOT:360,BIT:-720,BOT:-240,BRST:-120,BRT:-180,BTT:360,CAT:120,CCT:390,CDT:-300,CEDT:120,CEST:120,CET:60,CHADT:825,CHAST:765,CHOT:480,ChST:600,CHUT:600,CIST:-480,CIT:480,CKT:-600,CLST:-180,CLT:-240,COST:-240,COT:-300,CST:-360,CT:480,CVT:-60,CXT:420,DAVT:420,DDUT:600,DFT:60,EASST:-300,EAST:-360,EAT:180,ECT:-300,EDT:-240,EEDT:180,EEST:180,EET:120,EGST:0,EGT:-60,EIT:540,EST:-300,FET:180,FJT:720,FKST:-180,FKT:-240,FNT:-120,GALT:-360,GAMT:-540,GET:240,GFT:-180,GILT:720,GIT:-540,GMT:0,GST:-120,GYT:-240,HADT:-540,HAEC:120,HAST:-600,HKT:480,HMT:300,HOVT:420,HST:-600,IBST:0,ICT:420,IDT:180,IOT:180,IRDT:270,IRKT:480,IRST:210,IST:120,JST:540,KGT:360,KOST:660,KRAT:420,KST:540,LHST:630,LINT:840,MAGT:720,MART:-510,MAWT:300,MDT:-360,MET:60,MEST:120,MHT:720,MIST:660,MIT:-510,MMT:390,MSK:180,MST:-420,MUT:240,MVT:300,MYT:480,NCT:660,NDT:-90,NFT:660,NPT:345,NST:-150,NT:-150,NUT:-660,NZDT:780,NZST:720,OMST:360,ORAT:300,PDT:-420,PET:-300,PETT:720,PGT:600,PHOT:780,PKT:300,PMDT:-120,PMST:-180,PONT:660,PST:-480,PYST:-180,PYT:-240,RET:240,ROTT:-180,SAKT:660,SAMT:240,SAST:120,SBT:660,SCT:240,SGT:480,SLST:330,SRET:660,SRT:-180,SST:480,SYOT:180,TAHT:-600,THA:420,TFT:300,TJT:300,TKT:780,TLT:540,TMT:300,TOT:780,TVT:720,UCT:0,ULAT:480,USZ1:120,UTC:0,UYST:-120,UYT:-180,UZT:300,VET:-240,VLAT:600,VOLT:240,VOST:360,VUT:660,WAKT:720,WAST:120,WAT:60,WEDT:60,WEST:60,WET:0,WIT:420,WST:480,YAKT:540,YEKT:300,Z:0},A={zone:w,year:g,meridiem:{am:0,pm:12,"a.m.":0,"p.m.":12},month:{january:1,jan:1,february:2,feb:2,march:3,mar:3,april:4,apr:4,may:5,june:6,jun:6,july:7,jul:7,august:8,aug:8,september:9,sep:9,october:10,oct:10,november:11,nov:11,december:12,dec:12},dayname:{sunday:0,sun:0,monday:1,mon:1,tuesday:2,tue:2,wednesday:3,wed:3,thursday:4,thu:4,friday:5,fri:5,saturday:6,sat:6},digit:{}};function O(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function C(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?O(Object(r),!0).forEach((function(t){M(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):O(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function M(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var E={MONTHNAME:"january|february|march|april|may|june|july|august|september|october|november|december|jan\\.?|feb\\.?|mar\\.?|apr\\.?|may\\.?|jun\\.?|jul\\.?|aug\\.?|sep\\.?|oct\\.?|nov\\.?|dec\\.?",DAYNAME:"sunday|monday|tuesday|wednesday|thursday|friday|saturday|sun\\.?|mon\\.?|tue\\.?|wed\\.?|thu\\.?|fri\\.?|sat\\.?",ZONE:Object.keys(w).join("|"),MERIDIEM:"[ap]\\.?m?\\.?",ORDINAL:"st|nd|rd|th|\\.",YEAR:"[1-9]\\d{3}|\\d{2}",MONTH:"1[0-2]|0?[1-9]",MONTH2:"1[0-2]|0[1-9]",DAY:"3[01]|[12]\\d|0?[1-9]",DAY2:"3[01]|[12]\\d|0[1-9]",OFFSET:"[+-][01]?\\d?\\:?(?:[0-5]\\d)?",H24:"[01]\\d|2[0-3]",H12:"0?[1-9]|1[012]",MIN:"[0-5]\\d",SEC:"[0-5]\\d|60",MS:"\\d{9}|\\d{6}|\\d{3}"},D={latn:E,other:C(C({},E),{},{YEAR:"*{4}|*{2}",MONTH:"*{1,2}",MONTH2:"*{2}",DAY:"*{1,2}",DAY2:"*{2}",OFFSET:"[+-]*{1,2}\\:?*{0,2}",H24:"*{2}",H12:"*{1,2}",MIN:"*{2}",SEC:"*{2}",MS:"*{9}|*{6}|*{3}"})};function _(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function j(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?_(Object(r),!0).forEach((function(t){U(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):_(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function U(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var I={arab:1632,arabext:1776,bali:6992,beng:2534,deva:2406,fullwide:65296,gujr:2790,khmr:6112,knda:3302,laoo:3792,limb:6470,mlym:3430,mong:6160,mymr:4160,orya:2918,tamldec:3046,telu:3174,thai:3664,tibt:3872},N={0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9","\uff10":"0","\uff11":"1","\uff12":"2","\uff13":"3","\uff14":"4","\uff15":"5","\uff16":"6","\uff17":"7","\uff18":"8","\uff19":"9","\u3007":"0","\u4e00":"1","\u4e8c":"2","\u4e09":"3","\u56db":"4","\u4e94":"5","\u516d":"6","\u4e03":"7","\u516b":"8","\u4e5d":"9"},k={},P="[\uff10\uff11\uff12\uff13\uff14\uff15\uff16\uff17\uff18\uff19\u3007\u4e00\u4e8c\u4e09\u56db\u4e94\u516d\u4e03\u516b\u4e5d\\d]",H=["year","month","day","hour","minute","second","millisecond"];function Y(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function L(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function F(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?L(Object(r),!0).forEach((function(t){R(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):L(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function R(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function $(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function G(e,t,r){return t&&$(e.prototype,t),r&&$(e,r),e}var x=D.latn,K=D.other,B=function(e){if(k[e])return k[e];if("fullwide"===e||"hanidec"===e)return{group:"[\uff10\uff11\uff12\uff13\uff14\uff15\uff16\uff17\uff18\uff19\u3007\u4e00\u4e8c\u4e09\u56db\u4e94\u516d\u4e03\u516b\u4e5d\\d]",lookup:j({},N)};var t=I[e];if(!t)return{group:"\\d",lookup:j({},N)};for(var r=String.fromCharCode(t),n=String.fromCharCode(t+10),o={},a=0;a<10;a++)o[String.fromCharCode(t+a)]=a;return k[e]={group:"[".concat(r,"-").concat(n,"]"),lookup:o},k[e]},W={},V=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:h;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.locale=t,this.lookups=F({},A),this.vars=F({},x);var r=new Intl.NumberFormat(this.locale);this.numberingSystem=r.resolvedOptions().numberingSystem,this.build()}return G(e,null,[{key:"factory",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:h;return W[t.toLowerCase()]||(W[t.toLowerCase()]=new e(t)),W[t.toLowerCase()]}}]),G(e,[{key:"toInt",value:function(e){if("number"==typeof e)return e;if("latn"===this.numberingSystem)return parseInt(e,10);for(var t="",r=0;r<e.length;r++)t+=String(this.lookups.digit[e[r]]);return parseInt(t,10)}},{key:"build",value:function(){"latn"!==this.numberingSystem&&this.buildNumbers(),/^en/i.test(this.locale)||(this.buildMonthNames(),this.buildDaynames(),this.buildMeridiems())}},{key:"buildNumbers",value:function(){var e=this.numberingSystem,t=B(e),r=t.group,n=t.lookup;for(var o in this.lookups.digit=n,K)K.hasOwnProperty(o)&&(this.vars[o]=K[o].replace(/\*/g,r))}},{key:"buildMonthNames",value:function(){var e={},t={};if(/^fi/i.test(this.locale))"tammi|helmi|maalis|huhti|touko|kes\xe4|hein\xe4|elo|syys|loka|marras|joulu".split("|").forEach((function(r,n){["","k","kuu","kuuta"].forEach((function(o,a){e[r+o+(a<2?"\\.?":"")]=!0,t[r+o]=n+1}))}));else{for(var r=[],n=function(e){return"month"===e.type},o=0;o<12;o++)r.push(new Date(2017,o,1));for(var a=0,i=["full","long","medium"];a<i.length;a++)for(var u=i[a],l=Intl.DateTimeFormat(this.locale,{dateStyle:u}),s=0;s<12;s++){var c=l.formatToParts(r[s]).find(n).value.toLowerCase();if(/^ko/i.test(this.locale)&&(c+="\uc6d4"),"medium"===u){if(/^ar|zh/i.test(this.locale))return;c=c.replace(/\.$/,""),e["".concat(c,"\\.?")]=!0}else e[c]=!0;t[c]=s+1}for(var f=Intl.DateTimeFormat(this.locale,{month:"short"}),m=0;m<12;m++){var T=f.formatToParts(r[m]).find(n).value.toLowerCase();T=T.replace(/\.$/,""),e["".concat(T,"\\.?")]=!0,t[T]=m+1}}this.vars.MONTHNAME=Object.keys(e).join("|"),this.lookups.month=t}},{key:"buildDaynames",value:function(){for(var e=[],t=function(e){return"weekday"===e.type},r=0;r<7;r++)e.push(new Date(2017,0,r+1));for(var n=[],o={},a=0,i=["long","short"];a<i.length;a++)for(var u=i[a],l=Intl.DateTimeFormat(this.locale,{weekday:u}),s=0;s<7;s++){var c=l.formatToParts(e[s]).find(t).value.toLowerCase();"short"===u?(c=c.replace(/\.$/,""),n.push("".concat(c,"\\.?"))):n.push(c),o[c]=s}this.vars.DAYNAME=n.join("|"),this.lookups.dayname=o}},{key:"buildMeridiems",value:function(){for(var e=[new Date(2017,0,1),new Date(2017,0,1,23,0,0)],t=function(e){return"dayPeriod"===e.type},r=[],n={},o=Intl.DateTimeFormat(this.locale,{timeStyle:"long"}),a=0;a<2;a++){var i=o.formatToParts(e[a]).find(t);if(!i)return;var u=i.value.toLowerCase();r.push(u),n[u]=12*a}this.vars.MERIDIEM=r.join("|"),this.lookups.meridiem=n}},{key:"getObject",value:function(e,t){var r=this,n={};return e.forEach((function(e,o){if(e){var a=t[o+1];a=(a=a.toLowerCase()).replace(/\.$/,""),"offset"===e?n.offset=r.offsetToMinutes(a):r.lookups[e]?n[e]=r.lookups[e][a]||r.toInt(a):n[e]=r.toInt(a)}})),n}},{key:"castObject",value:function(e){var t=this,r={};return H.forEach((function(n){n in e&&(r[n]=t.toInt(e[n]))})),"string"==typeof e.offset?r.offset=this.offsetToMinutes(e.offset):"number"==typeof e.offset&&(r.offset=e.offset),r}},{key:"offsetToMinutes",value:function(e){var t=e.match(/^([+-])(..?):?(..)?$/);if(t){var r=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var r=[],n=!0,o=!1,a=void 0;try{for(var i,u=e[Symbol.iterator]();!(n=(i=u.next()).done)&&(r.push(i.value),!t||r.length!==t);n=!0);}catch(l){o=!0,a=l}finally{try{n||null==u.return||u.return()}finally{if(o)throw a}}return r}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Y(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Y(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(t,4),n=r[1],o=r[2],a=r[3];return("-"===n?-1:1)*(60*this.toInt(o)+this.toInt(a||0))}return 0}},{key:"compile",value:function(e){var t=this,r=e.replace(/_([A-Z0-9]+)_/g,(function(e,r){if(!t.vars[r])throw new Error("Template string contains invalid variable _".concat(r,"_"));return t.vars[r]}));return new RegExp(r,"i")}}]),e}();function Z(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var z=function(){function e(t){var r=t.template,n=void 0===r?null:r,o=t.matcher,a=void 0===o?null:o,i=t.units,u=void 0===i?null:i,l=t.handler,s=void 0===l?null:l;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!Array.isArray(u)&&"function"!=typeof s)throw new Error('new Format must receive a "units" array or "handler" function');if("string"!=typeof n&&!(a instanceof RegExp))throw new Error('new Format must receive a "template" string or "matcher" RegExp');this.template=n,this.units=u,this.matcher=a,this.handler=s,this.regexByLocale={}}var t,r;return t=e,(r=[{key:"getRegExp",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:h;return this.template?(this.regexByLocale[e]||(this.regexByLocale[e]=V.factory(e).compile(this.template)),this.regexByLocale[e]):this.matcher}},{key:"getMatches",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:h;return e.match(this.getRegExp(t))}},{key:"toDateTime",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:h,r=V.factory(t);if(this.units)return r.getObject(this.units,e);var n=this.handler(e,t);return!n||n.invalid?n:r.castObject(n)}},{key:"attempt",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:h;e=String(e).trim();var r=this.getMatches(e,t);if(r){var n=this.toDateTime(r,t);if(n&&!n.invalid)return n}return null}},{key:"now",value:function(){return new Date}}])&&Z(t.prototype,r),e}(),J=new z({template:"^@(\\d+)$",handler:function(e){var t=parseInt(e[1],10),r=new Date(1e3*t);return{year:r.getUTCFullYear(),month:r.getUTCMonth()+1,day:r.getUTCDate(),hour:r.getUTCHours(),minute:r.getUTCMinutes(),second:r.getUTCSeconds()}}}),X=new z({matcher:/^\/Date\((\d+)([+-]\d{4})?\)\/$/,handler:function(e){var t=parseInt(e[1],10),r=new Date(t);return{year:r.getUTCFullYear(),month:r.getUTCMonth()+1,day:r.getUTCDate(),hour:r.getUTCHours(),minute:r.getUTCMinutes(),second:r.getUTCSeconds(),millisecond:r.getUTCMilliseconds(),offset:e[2]||0}}});function q(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var Q=new z({matcher:/^(\+|-|in |)(\d+) (year|month|week|day|hour|minute|second|millisecond)s?( ago)?$/i,handler:function(e){var t=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var r=[],n=!0,o=!1,a=void 0;try{for(var i,u=e[Symbol.iterator]();!(n=(i=u.next()).done)&&(r.push(i.value),!t||r.length!==t);n=!0);}catch(l){o=!0,a=l}finally{try{n||null==u.return||u.return()}finally{if(o)throw a}}return r}}(e,t)||function(e,t){if(e){if("string"==typeof e)return q(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?q(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(e,5),r=t[1],n=t[2],o=t[3],a=t[4];n=parseFloat(n),"week"===(o=o.toLowerCase())&&(o="day",n*=7),("-"===r||a)&&(n*=-1);var i=this.now();"millisecond"===o?i.setUTCMilliseconds(i.getUTCMilliseconds()+n):"second"===o?i.setUTCSeconds(i.getUTCSeconds()+n):"minute"===o?i.setUTCMinutes(i.getUTCMinutes()+n):"hour"===o?i.setUTCHours(i.getUTCHours()+n):"day"===o?i.setUTCDate(i.getUTCDate()+n):"month"===o?i.setUTCMonth(i.getUTCMonth()+n):"year"===o&&i.setUTCFullYear(i.getUTCFullYear()+n);var u={};switch(o){case"millisecond":u.millisecond=i.getUTCMilliseconds();case"second":u.second=i.getUTCSeconds();case"minute":u.minute=i.getUTCMinutes();case"hour":u.hour=i.getUTCHours();case"day":u.day=i.getUTCDate();case"month":u.month=i.getUTCMonth()+1;case"year":u.year=i.getUTCFullYear()}return u}});function ee(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var te,re=P,ne=new z({template:"^(".concat(re,"{4}|").concat(re,"{2})\\s*\u5e74\\s*(").concat(re,"{1,2})\\s*\u6708\\s*(").concat(re,"{1,2})\\s*\u65e5$"),handler:function(e){var t=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var r=[],n=!0,o=!1,a=void 0;try{for(var i,u=e[Symbol.iterator]();!(n=(i=u.next()).done)&&(r.push(i.value),!t||r.length!==t);n=!0);}catch(l){o=!0,a=l}finally{try{n||null==u.return||u.return()}finally{if(o)throw a}}return r}}(e,t)||function(e,t){if(e){if("string"==typeof e)return ee(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ee(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(e,4),r=t[1],n=t[2],o=t[3];return te||((te=new V("zh")).numberingSystem="hanidec",te.buildNumbers()),te.castObject({year:r,month:n,day:o})}}),oe=new z({template:"^(_DAY_)[\\/. ](_MONTH_)$",units:["day","month"]}),ae=new z({template:"^(_DAY_)(?:_ORDINAL_)?[ -](_MONTHNAME_)$",units:["day","month"]}),ie=new z({template:"^(?:(?:_DAYNAME_),? )?(_DAY_)(?:_ORDINAL_)?([ -])(_MONTHNAME_)\\2(_YEAR_)$",units:["day",null,"month","year"]}),ue=new z({template:"^(_DAY_)([\\/. ])(_MONTH_)\\2(_YEAR_)$",units:["day",null,"month","year"]}),le=new z({template:"^(_MONTH_)(?:[\\/-])(_DAY_)$",units:["month","day"]}),se=new z({template:"^(_MONTH_)([\\/-])(_DAY_)\\2(_YEAR_)$",units:["month",null,"day","year"]}),ce=new z({template:"^(?:(?:_DAYNAME_),? )?(_MONTHNAME_)? (_DAY_)(?:_ORDINAL_)?$",units:["month","day"]}),fe=new z({template:"^(?:(?:_DAYNAME_),? )?(_MONTHNAME_)? (_DAY_)(?:_ORDINAL_)?,? (_YEAR_)$",units:["month","day","year"]});function me(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var Te=new z({template:"^(?:(.+?) )?(?:at )?(_H12_)(?:\\:(_MIN_)(?:\\:(_SEC_))?)? ?(_MERIDIEM_)$",handler:function(e,t){var r,n=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var r=[],n=!0,o=!1,a=void 0;try{for(var i,u=e[Symbol.iterator]();!(n=(i=u.next()).done)&&(r.push(i.value),!t||r.length!==t);n=!0);}catch(l){o=!0,a=l}finally{try{n||null==u.return||u.return()}finally{if(o)throw a}}return r}}(e,t)||function(e,t){if(e){if("string"==typeof e)return me(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?me(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(e,6),o=n[1],a=n[2],i=n[3],u=n[4],l=n[5];if(o){if((r=this.parser.attempt(o,t)).invalid)return null}else{var s=new Date;r={year:s.getUTCFullYear(),month:s.getUTCMonth(),day:s.getUTCDate()}}var c=V.factory(t);if(l){var f=c.lookups.meridiem[l.toLowerCase()]||0;a=parseFloat(a)+f}return r.hour=a,i&&(r.minute=i),u&&(r.second=u),r}});function ye(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var he,de=new z({template:"^(?:(.+?)[ T])?(_H24_)\\:(_MIN_)(?:\\:(_SEC_)(?:[\\.,](_MS_))?)? ?(?:GMT)? ?(_OFFSET_)? ?(_ZONE_)?$",handler:function(e,t){var r=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var r=[],n=!0,o=!1,a=void 0;try{for(var i,u=e[Symbol.iterator]();!(n=(i=u.next()).done)&&(r.push(i.value),!t||r.length!==t);n=!0);}catch(l){o=!0,a=l}finally{try{n||null==u.return||u.return()}finally{if(o)throw a}}return r}}(e,t)||function(e,t){if(e){if("string"==typeof e)return ye(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ye(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(e,8),n=r[1],o=r[2],a=r[3],i=r[4],u=r[5],l=r[6],s=r[7],c={};if(n&&(c=this.parser.attempt(n,t)).invalid)return c;if(c.hour=o,c.minute=a,i&&(c.second=i),u&&u.length>3?c.millisecond=u.slice(0,3):u&&(c.millisecond=u),s&&!l&&s in w)c.offset=w[s];else if(l){var f=V.factory(t);c.offset=f.offsetToMinutes(l)}return c}}),ve=new z({matcher:/^(now|today|tomorrow|yesterday)/i,handler:function(e){var t=this.now(),r=e[1].toLowerCase();switch(r){case"tomorrow":t.setUTCDate(t.getUTCDate()+1);break;case"yesterday":t.setUTCDate(t.getUTCDate()-1)}var n={year:t.getUTCFullYear(),month:t.getUTCMonth()+1,day:t.getUTCDate()};return"now"===r&&(n.hour=t.getUTCHours(),n.minute=t.getUTCMinutes(),n.second=t.getUTCSeconds(),n.millisecond=t.getUTCMilliseconds()),n}}),pe=new z({template:"^(?:_DAYNAME_) (_MONTHNAME_) (_DAY_) (_H24_):(_MIN_):(_SEC_) (_OFFSET_) (_YEAR_)$",units:["month","day","hour","minute","second","offset","year"]}),be=new z({template:"^(_YEAR_)(-?)(_MONTH_)\\2(_DAY_)$",units:["year",null,"month","day"]}),ge=new b;ge.addFormats([de,Te,be,ie,fe,se,ue,ne,pe,ve,Q,ce,ae,le,oe,J,X]),ge.Parser=b,ge.Format=z,ge.LocaleHelper=V,Date.fromString=function(e,t){return function(r){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,o=e.attempt(r,n);if(o.invalid)return o;var a=new Date;return o.year&&a.setUTCFullYear(o.year),a.setUTCMonth(o.month?o.month-1:0),a.setUTCDate(o.day||1),a.setUTCHours(o.hour||0),a.setUTCMinutes(o.minute||0),a.setUTCSeconds(o.second||0),a.setUTCMilliseconds(o.millisecond||0),"number"==typeof o.offset?new Date(a-60*o.offset*1e3):a}}(ge,h),Date.fromAny=(he=Date.fromString,function(e,t){return e instanceof Date?e:"number"==typeof e?new Date(e):he(e,t)})}(); | ||
!function(){var e,t,r,n=e={};function o(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function i(e){if(t===setTimeout)return setTimeout(e,0);if((t===o||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:o}catch(e){t=o}try{r="function"==typeof clearTimeout?clearTimeout:a}catch(e){r=a}}();var u,l=[],s=!1,c=-1;function f(){s&&u&&(s=!1,u.length?l=u.concat(l):c=-1,l.length&&m())}function m(){if(!s){var e=i(f);s=!0;for(var t=l.length;t;){for(u=l,l=[];++c<t;)u&&u[c].run();c=-1,t=l.length}u=null,s=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===a||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function y(e,t){this.fun=e,this.array=t}function T(){}n.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];l.push(new y(e,t)),1!==l.length||s||i(m)},y.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=T,n.addListener=T,n.once=T,n.off=T,n.removeListener=T,n.removeAllListeners=T,n.emit=T,n.prependListener=T,n.prependOnceListener=T,n.listeners=function(e){return[]},n.binding=function(e){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(e){throw new Error("process.chdir is not supported")},n.umask=function(){return 0};var h={};function d(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return p(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?p(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,u=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return i=e.done,e},e:function(e){u=!0,a=e},f:function(){try{i||null==r.return||r.return()}finally{if(u)throw a}}}}function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function v(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(function(e){(function(){"use strict";var t;if("undefined"!=typeof navigator){var r=navigator;t=Array.isArray(r.languages)?r.languages[0]:r.language}else if(void 0!==e){var n=e.env;t=n.LC_ALL||n.LC_MESSAGES||n.LANG||n.LANGUAGE}t||(t="en-US"),h=t}).call(this)}).call(this,e);for(var b=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.formats=[]}var t,r;return t=e,(r=[{key:"addFormat",value:function(e){return this.formats.push(e),e.parser=this,this}},{key:"addFormats",value:function(e){var t=this;return e.forEach((function(e){return t.addFormat(e)})),this}},{key:"removeFormat",value:function(e){var t=this.formats.indexOf(e);if(t>-1){var r=this.formats[t];return this.formats.splice(t,1),r.parser=null,!0}return!1}},{key:"attempt",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:h,n=d(this.formats);try{for(n.s();!(t=n.n()).done;){var o=t.value.attempt(e,r);if(o)return o}}catch(i){n.e(i)}finally{n.f()}var a=String(e).slice(0,200);return{invalid:"Unable to parse ".concat(a)}}}])&&v(t.prototype,r),e}(),g={},S=1;S<100;S++)g[(S<9?"0":"")+S]=S+(S>51?1900:2e3);var A={"Eastern Daylight Time":-240,"Eastern Standard Time":-300,"Central Daylight Time":-300,"Central Standard Time":-360,"Mountain Daylight Time":-360,"Mountain Standard Time":-420,"Pacific Daylight Time":-420,"Pacific Standard Time":-480,ACDT:630,ACST:570,ACT:480,ADT:-180,AEDT:660,AEST:600,AFT:270,AKDT:-480,AKST:-540,AMST:-180,AMT:-240,ART:-180,AST:180,AWDT:540,AWST:480,AZOST:-60,AZT:240,BDT:360,BIOT:360,BIT:-720,BOT:-240,BRST:-120,BRT:-180,BTT:360,CAT:120,CCT:390,CDT:-300,CEDT:120,CEST:120,CET:60,CHADT:825,CHAST:765,CHOT:480,ChST:600,CHUT:600,CIST:-480,CIT:480,CKT:-600,CLST:-180,CLT:-240,COST:-240,COT:-300,CST:-360,CT:480,CVT:-60,CXT:420,DAVT:420,DDUT:600,DFT:60,EASST:-300,EAST:-360,EAT:180,ECT:-300,EDT:-240,EEDT:180,EEST:180,EET:120,EGST:0,EGT:-60,EIT:540,EST:-300,FET:180,FJT:720,FKST:-180,FKT:-240,FNT:-120,GALT:-360,GAMT:-540,GET:240,GFT:-180,GILT:720,GIT:-540,GMT:0,GST:-120,GYT:-240,HADT:-540,HAEC:120,HAST:-600,HKT:480,HMT:300,HOVT:420,HST:-600,IBST:0,ICT:420,IDT:180,IOT:180,IRDT:270,IRKT:480,IRST:210,IST:120,JST:540,KGT:360,KOST:660,KRAT:420,KST:540,LHST:630,LINT:840,MAGT:720,MART:-510,MAWT:300,MDT:-360,MET:60,MEST:120,MHT:720,MIST:660,MIT:-510,MMT:390,MSK:180,MST:-420,MUT:240,MVT:300,MYT:480,NCT:660,NDT:-90,NFT:660,NPT:345,NST:-150,NT:-150,NUT:-660,NZDT:780,NZST:720,OMST:360,ORAT:300,PDT:-420,PET:-300,PETT:720,PGT:600,PHOT:780,PKT:300,PMDT:-120,PMST:-180,PONT:660,PST:-480,PYST:-180,PYT:-240,RET:240,ROTT:-180,SAKT:660,SAMT:240,SAST:120,SBT:660,SCT:240,SGT:480,SLST:330,SRET:660,SRT:-180,SST:480,SYOT:180,TAHT:-600,THA:420,TFT:300,TJT:300,TKT:780,TLT:540,TMT:300,TOT:780,TVT:720,UCT:0,ULAT:480,USZ1:120,UTC:0,UYST:-120,UYT:-180,UZT:300,VET:-240,VLAT:600,VOLT:240,VOST:360,VUT:660,WAKT:720,WAST:120,WAT:60,WEDT:60,WEST:60,WET:0,WIT:420,WST:480,YAKT:540,YEKT:300,Z:0},w={zone:A,year:g,meridiem:{am:0,pm:12,"a.m.":0,"p.m.":12},month:{january:1,jan:1,february:2,feb:2,march:3,mar:3,april:4,apr:4,may:5,june:6,jun:6,july:7,jul:7,august:8,aug:8,september:9,sep:9,october:10,oct:10,november:11,nov:11,december:12,dec:12},dayname:{sunday:0,sun:0,monday:1,mon:1,tuesday:2,tue:2,wednesday:3,wed:3,thursday:4,thu:4,friday:5,fri:5,saturday:6,sat:6},digit:{}};function O(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function C(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?O(Object(r),!0).forEach((function(t){E(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):O(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function E(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var M={MONTHNAME:"january|february|march|april|may|june|july|august|september|october|november|december|jan\\.?|feb\\.?|mar\\.?|apr\\.?|may\\.?|jun\\.?|jul\\.?|aug\\.?|sep\\.?|oct\\.?|nov\\.?|dec\\.?",DAYNAME:"sunday|monday|tuesday|wednesday|thursday|friday|saturday|sun\\.?|mon\\.?|tue\\.?|wed\\.?|thu\\.?|fri\\.?|sat\\.?",ZONE:Object.keys(A).join("|"),MERIDIEM:"[ap]\\.?m?\\.?",ORDINAL:"st|nd|rd|th|\\.",YEAR:"[1-9]\\d{3}|\\d{2}",MONTH:"1[0-2]|0?[1-9]",MONTH2:"1[0-2]|0[1-9]",DAY:"3[01]|[12]\\d|0?[1-9]",DAY2:"3[01]|[12]\\d|0[1-9]",OFFSET:"[+-][01]?\\d?\\:?(?:[0-5]\\d)?",H24:"[01]\\d|2[0-3]",H12:"0?[1-9]|1[012]",MIN:"[0-5]\\d",SEC:"[0-5]\\d|60",MS:"\\d{9}|\\d{6}|\\d{3}"},D={latn:M,other:C(C({},M),{},{YEAR:"*{4}|*{2}",MONTH:"*{1,2}",MONTH2:"*{2}",DAY:"*{1,2}",DAY2:"*{2}",OFFSET:"[+-]*{1,2}\\:?*{0,2}",H24:"*{2}",H12:"*{1,2}",MIN:"*{2}",SEC:"*{2}",MS:"*{9}|*{6}|*{3}"})};function _(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function j(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?_(Object(r),!0).forEach((function(t){U(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):_(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function U(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var I={arab:1632,arabext:1776,bali:6992,beng:2534,deva:2406,fullwide:65296,gujr:2790,khmr:6112,knda:3302,laoo:3792,limb:6470,mlym:3430,mong:6160,mymr:4160,orya:2918,tamldec:3046,telu:3174,thai:3664,tibt:3872},N={0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9","\uff10":"0","\uff11":"1","\uff12":"2","\uff13":"3","\uff14":"4","\uff15":"5","\uff16":"6","\uff17":"7","\uff18":"8","\uff19":"9","\u3007":"0","\u4e00":"1","\u4e8c":"2","\u4e09":"3","\u56db":"4","\u4e94":"5","\u516d":"6","\u4e03":"7","\u516b":"8","\u4e5d":"9"},k={},P="[\uff10\uff11\uff12\uff13\uff14\uff15\uff16\uff17\uff18\uff19\u3007\u4e00\u4e8c\u4e09\u56db\u4e94\u516d\u4e03\u516b\u4e5d\\d]",H=["year","month","day","hour","minute","second","millisecond"];function Y(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function L(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function F(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?L(Object(r),!0).forEach((function(t){R(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):L(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function R(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function $(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function G(e,t,r){return t&&$(e.prototype,t),r&&$(e,r),e}var x=D.latn,K=D.other,B=function(e){if(k[e])return k[e];if("fullwide"===e||"hanidec"===e)return{group:"[\uff10\uff11\uff12\uff13\uff14\uff15\uff16\uff17\uff18\uff19\u3007\u4e00\u4e8c\u4e09\u56db\u4e94\u516d\u4e03\u516b\u4e5d\\d]",lookup:j({},N)};var t=I[e];if(!t)return{group:"\\d",lookup:j({},N)};for(var r=String.fromCharCode(t),n=String.fromCharCode(t+10),o={},a=0;a<10;a++)o[String.fromCharCode(t+a)]=a;return k[e]={group:"[".concat(r,"-").concat(n,"]"),lookup:o},k[e]},W={},V=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:h;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.locale=t,this.lookups=F({},w),this.vars=F({},x);var r=new Intl.NumberFormat(this.locale);this.numberingSystem=r.resolvedOptions().numberingSystem,this.build()}return G(e,null,[{key:"factory",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:h;return W[t.toLowerCase()]||(W[t.toLowerCase()]=new e(t)),W[t.toLowerCase()]}}]),G(e,[{key:"toInt",value:function(e){if("number"==typeof e)return e;if("latn"===this.numberingSystem)return parseInt(e,10);for(var t="",r=0;r<e.length;r++)t+=String(this.lookups.digit[e[r]]);return parseInt(t,10)}},{key:"build",value:function(){"latn"!==this.numberingSystem&&this.buildNumbers(),/^en/i.test(this.locale)||(this.buildMonthNames(),this.buildDaynames(),this.buildMeridiems())}},{key:"buildNumbers",value:function(){var e=this.numberingSystem,t=B(e),r=t.group,n=t.lookup;for(var o in this.lookups.digit=n,K)K.hasOwnProperty(o)&&(this.vars[o]=K[o].replace(/\*/g,r))}},{key:"buildMonthNames",value:function(){var e={},t={};if(/^fi/i.test(this.locale))"tammi|helmi|maalis|huhti|touko|kes\xe4|hein\xe4|elo|syys|loka|marras|joulu".split("|").forEach((function(r,n){["","k","kuu","kuuta"].forEach((function(o,a){e[r+o+(a<2?"\\.?":"")]=!0,t[r+o]=n+1}))}));else{for(var r=[],n=function(e){return"month"===e.type},o=0;o<12;o++)r.push(new Date(2017,o,1));for(var a=0,i=["full","long","medium"];a<i.length;a++)for(var u=i[a],l=Intl.DateTimeFormat(this.locale,{dateStyle:u}),s=0;s<12;s++){var c=l.formatToParts(r[s]).find(n).value.toLowerCase();if(/^ko/i.test(this.locale)&&(c+="\uc6d4"),"medium"===u){if(/^ar|zh/i.test(this.locale))return;c=c.replace(/\.$/,""),e["".concat(c,"\\.?")]=!0}else e[c]=!0;t[c]=s+1}for(var f=Intl.DateTimeFormat(this.locale,{month:"short"}),m=0;m<12;m++){var y=f.formatToParts(r[m]).find(n).value.toLowerCase();y=y.replace(/\.$/,""),e["".concat(y,"\\.?")]=!0,t[y]=m+1}}this.vars.MONTHNAME=Object.keys(e).join("|"),this.lookups.month=t}},{key:"buildDaynames",value:function(){for(var e=[],t=function(e){return"weekday"===e.type},r=0;r<7;r++)e.push(new Date(2017,0,r+1));for(var n=[],o={},a=0,i=["long","short"];a<i.length;a++)for(var u=i[a],l=Intl.DateTimeFormat(this.locale,{weekday:u}),s=0;s<7;s++){var c=l.formatToParts(e[s]).find(t).value.toLowerCase();"short"===u?(c=c.replace(/\.$/,""),n.push("".concat(c,"\\.?"))):n.push(c),o[c]=s}this.vars.DAYNAME=n.join("|"),this.lookups.dayname=o}},{key:"buildMeridiems",value:function(){for(var e=[new Date(2017,0,1),new Date(2017,0,1,23,0,0)],t=function(e){return"dayPeriod"===e.type},r=[],n={},o=Intl.DateTimeFormat(this.locale,{timeStyle:"long"}),a=0;a<2;a++){var i=o.formatToParts(e[a]).find(t);if(!i)return;var u=i.value.toLowerCase();r.push(u),n[u]=12*a}this.vars.MERIDIEM=r.join("|"),this.lookups.meridiem=n}},{key:"getObject",value:function(e,t){var r=this,n={};return e.forEach((function(e,o){if(e){var a=t[o+1];a=(a=a.toLowerCase()).replace(/\.$/,""),"offset"===e?n.offset=r.offsetToMinutes(a):r.lookups[e]?n[e]=r.lookups[e][a]||r.toInt(a):n[e]=r.toInt(a)}})),n}},{key:"castObject",value:function(e){var t=this,r={};return H.forEach((function(n){n in e&&(r[n]=t.toInt(e[n]))})),"string"==typeof e.offset?r.offset=this.offsetToMinutes(e.offset):"number"==typeof e.offset&&(r.offset=e.offset),r}},{key:"offsetToMinutes",value:function(e){var t=e.match(/^([+-])(..?):?(..)?$/);if(t){var r=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var r=[],n=!0,o=!1,a=void 0;try{for(var i,u=e[Symbol.iterator]();!(n=(i=u.next()).done)&&(r.push(i.value),!t||r.length!==t);n=!0);}catch(l){o=!0,a=l}finally{try{n||null==u.return||u.return()}finally{if(o)throw a}}return r}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Y(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Y(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(t,4),n=r[1],o=r[2],a=r[3];return("-"===n?-1:1)*(60*this.toInt(o)+this.toInt(a||0))}return 0}},{key:"compile",value:function(e){var t=this,r=e.replace(/_([A-Z0-9]+)_/g,(function(e,r){if(!t.vars[r])throw new Error("Template string contains invalid variable _".concat(r,"_"));return t.vars[r]}));return new RegExp(r,"i")}}]),e}();function Z(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var z=function(){function e(t){var r=t.template,n=void 0===r?null:r,o=t.matcher,a=void 0===o?null:o,i=t.units,u=void 0===i?null:i,l=t.handler,s=void 0===l?null:l;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!Array.isArray(u)&&"function"!=typeof s)throw new Error('new Format must receive a "units" array or "handler" function');if("string"!=typeof n&&!(a instanceof RegExp))throw new Error('new Format must receive a "template" string or "matcher" RegExp');this.template=n,this.units=u,this.matcher=a,this.handler=s,this.regexByLocale={}}var t,r;return t=e,(r=[{key:"getRegExp",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:h;return this.template?(this.regexByLocale[e]||(this.regexByLocale[e]=V.factory(e).compile(this.template)),this.regexByLocale[e]):this.matcher}},{key:"getMatches",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:h;return e.match(this.getRegExp(t))}},{key:"toDateTime",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:h,r=V.factory(t);if(this.units)return r.getObject(this.units,e);var n=this.handler(e,t);return!n||n.invalid?n:r.castObject(n)}},{key:"attempt",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:h;e=String(e).trim();var r=this.getMatches(e,t);if(r){var n=this.toDateTime(r,t);if(n&&!n.invalid)return n}return null}},{key:"now",value:function(){return new Date}}])&&Z(t.prototype,r),e}(),J=new z({template:"^@(\\d+)$",handler:function(e){var t=parseInt(e[1],10),r=new Date(1e3*t);return{year:r.getUTCFullYear(),month:r.getUTCMonth()+1,day:r.getUTCDate(),hour:r.getUTCHours(),minute:r.getUTCMinutes(),second:r.getUTCSeconds()}}}),X=new z({matcher:/^\/Date\((\d+)([+-]\d{4})?\)\/$/,handler:function(e){var t=parseInt(e[1],10),r=new Date(t);return{year:r.getUTCFullYear(),month:r.getUTCMonth()+1,day:r.getUTCDate(),hour:r.getUTCHours(),minute:r.getUTCMinutes(),second:r.getUTCSeconds(),millisecond:r.getUTCMilliseconds(),offset:e[2]||0}}});function q(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var Q=new z({matcher:/^(\+|-|in |)(\d+) (year|month|week|day|hour|minute|second|millisecond)s?( ago)?$/i,handler:function(e){var t=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var r=[],n=!0,o=!1,a=void 0;try{for(var i,u=e[Symbol.iterator]();!(n=(i=u.next()).done)&&(r.push(i.value),!t||r.length!==t);n=!0);}catch(l){o=!0,a=l}finally{try{n||null==u.return||u.return()}finally{if(o)throw a}}return r}}(e,t)||function(e,t){if(e){if("string"==typeof e)return q(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?q(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(e,5),r=t[1],n=t[2],o=t[3],a=t[4];n=parseFloat(n),"week"===(o=o.toLowerCase())&&(o="day",n*=7),("-"===r||a)&&(n*=-1);var i=this.now();"millisecond"===o?i.setUTCMilliseconds(i.getUTCMilliseconds()+n):"second"===o?i.setUTCSeconds(i.getUTCSeconds()+n):"minute"===o?i.setUTCMinutes(i.getUTCMinutes()+n):"hour"===o?i.setUTCHours(i.getUTCHours()+n):"day"===o?i.setUTCDate(i.getUTCDate()+n):"month"===o?i.setUTCMonth(i.getUTCMonth()+n):"year"===o&&i.setUTCFullYear(i.getUTCFullYear()+n);var u={};switch(o){case"millisecond":u.millisecond=i.getUTCMilliseconds();case"second":u.second=i.getUTCSeconds();case"minute":u.minute=i.getUTCMinutes();case"hour":u.hour=i.getUTCHours();case"day":u.day=i.getUTCDate();case"month":u.month=i.getUTCMonth()+1;case"year":u.year=i.getUTCFullYear()}return u}});function ee(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var te,re=P,ne=new z({template:"^(".concat(re,"{4}|").concat(re,"{2})\\s*\u5e74\\s*(").concat(re,"{1,2})\\s*\u6708\\s*(").concat(re,"{1,2})\\s*\u65e5$"),handler:function(e){var t=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var r=[],n=!0,o=!1,a=void 0;try{for(var i,u=e[Symbol.iterator]();!(n=(i=u.next()).done)&&(r.push(i.value),!t||r.length!==t);n=!0);}catch(l){o=!0,a=l}finally{try{n||null==u.return||u.return()}finally{if(o)throw a}}return r}}(e,t)||function(e,t){if(e){if("string"==typeof e)return ee(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ee(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(e,4),r=t[1],n=t[2],o=t[3];return te||((te=new V("zh")).numberingSystem="hanidec",te.buildNumbers()),te.castObject({year:r,month:n,day:o})}}),oe=new z({template:"^(_DAY_)[\\/. ](_MONTH_)$",units:["day","month"]}),ae=new z({template:"^(_DAY_)(?:_ORDINAL_)?[ -](_MONTHNAME_)$",units:["day","month"]}),ie=new z({template:"^(?:(?:_DAYNAME_),? )?(_DAY_)(?:_ORDINAL_)?([ -])(_MONTHNAME_)\\2(_YEAR_)$",units:["day",null,"month","year"]}),ue=new z({template:"^(_DAY_)([\\/. ])(_MONTH_)\\2(_YEAR_)$",units:["day",null,"month","year"]}),le=new z({template:"^(_MONTH_)(?:[\\/-])(_DAY_)$",units:["month","day"]}),se=new z({template:"^(_MONTH_)([\\/-])(_DAY_)\\2(_YEAR_)$",units:["month",null,"day","year"]}),ce=new z({template:"^(?:(?:_DAYNAME_),? )?(_MONTHNAME_)? (_DAY_)(?:_ORDINAL_)?$",units:["month","day"]}),fe=new z({template:"^(?:(?:_DAYNAME_),? )?(_MONTHNAME_)? (_DAY_)(?:_ORDINAL_)?,? (_YEAR_)$",units:["month","day","year"]});function me(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var ye=new z({template:"^(?:(.+?) )?(?:at )?(_H12_)(?:\\:(_MIN_)(?:\\:(_SEC_))?)? ?(_MERIDIEM_)$",handler:function(e,t){var r=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var r=[],n=!0,o=!1,a=void 0;try{for(var i,u=e[Symbol.iterator]();!(n=(i=u.next()).done)&&(r.push(i.value),!t||r.length!==t);n=!0);}catch(l){o=!0,a=l}finally{try{n||null==u.return||u.return()}finally{if(o)throw a}}return r}}(e,t)||function(e,t){if(e){if("string"==typeof e)return me(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?me(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(e,6),n=r[1],o=r[2],a=r[3],i=r[4],u=r[5],l={};if(n&&(l=this.parser.attempt(n,t)).invalid)return null;var s=V.factory(t);if(u){var c=s.lookups.meridiem[u.toLowerCase()]||0;o=parseFloat(o)+c}return l.hour=o,a&&(l.minute=a),i&&(l.second=i),l}});function Te(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var he,de=new z({template:"^(?:(.+?)[ T])?(_H24_)\\:(_MIN_)(?:\\:(_SEC_)(?:[\\.,](_MS_))?)? ?(?:GMT)? ?(_OFFSET_)? ?(_ZONE_)?$",handler:function(e,t){var r=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var r=[],n=!0,o=!1,a=void 0;try{for(var i,u=e[Symbol.iterator]();!(n=(i=u.next()).done)&&(r.push(i.value),!t||r.length!==t);n=!0);}catch(l){o=!0,a=l}finally{try{n||null==u.return||u.return()}finally{if(o)throw a}}return r}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Te(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Te(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(e,8),n=r[1],o=r[2],a=r[3],i=r[4],u=r[5],l=r[6],s=r[7],c={};if(n&&(c=this.parser.attempt(n,t)).invalid)return c;if(c.hour=o,c.minute=a,i&&(c.second=i),u&&u.length>3?c.millisecond=u.slice(0,3):u&&(c.millisecond=u),s&&!l&&s in A)c.offset=A[s];else if(l){var f=V.factory(t);c.offset=f.offsetToMinutes(l)}return c}}),pe=new z({matcher:/^(now|today|tomorrow|yesterday)/i,handler:function(e){var t=this.now(),r=e[1].toLowerCase();switch(r){case"tomorrow":t.setUTCDate(t.getUTCDate()+1);break;case"yesterday":t.setUTCDate(t.getUTCDate()-1)}var n={year:t.getUTCFullYear(),month:t.getUTCMonth()+1,day:t.getUTCDate()};return"now"===r&&(n.hour=t.getUTCHours(),n.minute=t.getUTCMinutes(),n.second=t.getUTCSeconds(),n.millisecond=t.getUTCMilliseconds()),n}}),ve=new z({template:"^(?:_DAYNAME_) (_MONTHNAME_) (_DAY_) (_H24_):(_MIN_):(_SEC_) (_OFFSET_) (_YEAR_)$",units:["month","day","hour","minute","second","offset","year"]}),be=new z({template:"^(_YEAR_)(-?)(_MONTH_)\\2(_DAY_)$",units:["year",null,"month","day"]}),ge=new b;ge.addFormats([de,ye,be,ie,fe,se,ue,ne,ve,pe,Q,ce,ae,le,oe,J,X]),ge.Parser=b,ge.Format=z,ge.LocaleHelper=V,Date.fromString=function(e,t){return function(r){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,o=e.attempt(r,n);if(o.invalid)return o;var a=new Date;return"number"==typeof o.year&&a.setUTCFullYear(o.year),"number"==typeof o.month&&a.setUTCMonth(o.month-1),"number"==typeof o.day&&a.setUTCDate(o.day),a.setUTCHours(o.hour||0),a.setUTCMinutes(o.minute||0),a.setUTCSeconds(o.second||0),a.setUTCMilliseconds(o.millisecond||0),"number"==typeof o.offset?new Date(a-60*o.offset*1e3):a}}(ge,h),Date.fromAny=(he=Date.fromString,function(e,t){return e instanceof Date?e:"number"==typeof e?new Date(e):he(e,t)})}(); |
{ | ||
"name": "any-date-parser", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Parse a wide range of date formats including human-input dates", | ||
@@ -5,0 +5,0 @@ "tags": [ |
# any-date-parser | ||
[![Build Status](https://travis-ci.org/kensnyder/any-date-parser.svg?branch=master&v=1.0.1)](https://travis-ci.org/kensnyder/any-date-parser) | ||
[![Code Coverage](https://codecov.io/gh/kensnyder/any-date-parser/branch/master/graph/badge.svg?v=1.0.1)](https://codecov.io/gh/kensnyder/any-date-parser) | ||
[![ISC License](https://img.shields.io/npm/l/any-date-parser.svg?v=1.0.1)](https://opensource.org/licenses/ISC) | ||
[![Build Status](https://travis-ci.org/kensnyder/any-date-parser.svg?branch=master&v=1.1.0)](https://travis-ci.org/kensnyder/any-date-parser) | ||
[![Code Coverage](https://codecov.io/gh/kensnyder/any-date-parser/branch/master/graph/badge.svg?v=1.1.0)](https://codecov.io/gh/kensnyder/any-date-parser) | ||
[![ISC License](https://img.shields.io/npm/l/any-date-parser.svg?v=1.1.0)](https://opensource.org/licenses/ISC) | ||
@@ -18,3 +18,3 @@ Parse a wide range of date formats including human-input dates. | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/any-date-parser@1.0.1/dist/browser-bundle.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/any-date-parser@1.1.0/dist/browser-bundle.js"></script> | ||
``` | ||
@@ -21,0 +21,0 @@ |
function fromString(parser, defaultLocale) { | ||
return function fromString(string, locale = defaultLocale) { | ||
return function fromStringFunction(string, locale = defaultLocale) { | ||
const parsed = parser.attempt(string, locale); | ||
@@ -8,9 +8,13 @@ if (parsed.invalid) { | ||
const date = new Date(); | ||
if (parsed.year) { | ||
// default to current year | ||
// default to current year, month and day | ||
if (typeof parsed.year === 'number') { | ||
date.setUTCFullYear(parsed.year); | ||
} | ||
// default to first period for other units | ||
date.setUTCMonth(parsed.month ? parsed.month - 1 : 0); | ||
date.setUTCDate(parsed.day || 1); | ||
if (typeof parsed.month === 'number') { | ||
date.setUTCMonth(parsed.month - 1); | ||
} | ||
if (typeof parsed.day === 'number') { | ||
date.setUTCDate(parsed.day); | ||
} | ||
// default to first unit for time components | ||
date.setUTCHours(parsed.hour || 0); | ||
@@ -17,0 +21,0 @@ date.setUTCMinutes(parsed.minute || 0); |
const fromString = require('./fromString.js'); | ||
const now = new Date(); | ||
describe('fromString', () => { | ||
@@ -10,14 +11,16 @@ it('should return invalid dates', () => { | ||
}); | ||
it('should reset all but year', () => { | ||
it('should use current month and day', () => { | ||
const result = { year: 2020 }; | ||
const parser = { attempt: jest.fn(() => result) }; | ||
const fromFn = fromString(parser); | ||
const jan1 = new Date(Date.UTC(2020, 0, 1, 0, 0, 0, 0)); | ||
const jan1 = new Date( | ||
Date.UTC(2020, now.getUTCMonth(), now.getUTCDate(), 0, 0, 0, 0) | ||
); | ||
expect(fromFn()).toEqual(jan1); | ||
}); | ||
it('should reset all but month', () => { | ||
it('should use current month', () => { | ||
const result = { year: 2020, month: 5 }; | ||
const parser = { attempt: jest.fn(() => result) }; | ||
const fromFn = fromString(parser); | ||
const may1 = new Date(Date.UTC(2020, 4, 1, 0, 0, 0, 0)); | ||
const may1 = new Date(Date.UTC(2020, 4, now.getUTCDate(), 0, 0, 0, 0)); | ||
expect(fromFn()).toEqual(may1); | ||
@@ -24,0 +27,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
123572
2874