2 lines
11 KiB
JavaScript
2 lines
11 KiB
JavaScript
function h(e,a){if(a.length<e)throw new TypeError(e+" argument"+(e>1?"s":"")+" required, but only "+a.length+" present")}function s(e){h(1,arguments);var a=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&a==="[object Date]"?new Date(e.getTime()):typeof e=="number"||a==="[object Number]"?new Date(e):((typeof e=="string"||a==="[object String]")&&typeof console<"u"&&(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments"),console.warn(new Error().stack)),new Date(NaN))}var k={};function A(){return k}function P(e){var a=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return a.setUTCFullYear(e.getFullYear()),e.getTime()-a.getTime()}function M(e,a){h(2,arguments);var t=s(e),n=s(a),i=t.getTime()-n.getTime();return i<0?-1:i>0?1:i}function C(e,a){h(2,arguments);var t=s(e),n=s(a),i=t.getFullYear()-n.getFullYear(),u=t.getMonth()-n.getMonth();return i*12+u}function X(e,a){return h(2,arguments),s(e).getTime()-s(a).getTime()}var S={ceil:Math.ceil,round:Math.round,floor:Math.floor,trunc:function(e){return e<0?Math.ceil(e):Math.floor(e)}},I="trunc";function _(e){return e?S[e]:S[I]}function j(e){h(1,arguments);var a=s(e);return a.setHours(23,59,59,999),a}function E(e){h(1,arguments);var a=s(e),t=a.getMonth();return a.setFullYear(a.getFullYear(),t+1,0),a.setHours(23,59,59,999),a}function R(e){h(1,arguments);var a=s(e);return j(a).getTime()===E(a).getTime()}function Y(e,a){h(2,arguments);var t=s(e),n=s(a),i=M(t,n),u=Math.abs(C(t,n)),r;if(u<1)r=0;else{t.getMonth()===1&&t.getDate()>27&&t.setDate(30),t.setMonth(t.getMonth()-i*u);var l=M(t,n)===-i;R(s(e))&&u===1&&M(e,n)===1&&(l=!1),r=i*(u-Number(l))}return r===0?0:r}function z(e,a,t){h(2,arguments);var n=X(e,a)/1e3;return _(t==null?void 0:t.roundingMethod)(n)}var L={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},V=function(e,a,t){var n,i=L[e];return typeof i=="string"?n=i:a===1?n=i.one:n=i.other.replace("{{count}}",a.toString()),t!=null&&t.addSuffix?t.comparison&&t.comparison>0?"in "+n:n+" ago":n};const q=V;function w(e){return function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=a.width?String(a.width):e.defaultWidth,n=e.formats[t]||e.formats[e.defaultWidth];return n}}var H={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},J={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},U={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},$={date:w({formats:H,defaultWidth:"full"}),time:w({formats:J,defaultWidth:"full"}),dateTime:w({formats:U,defaultWidth:"full"})};const Q=$;var B={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},G=function(e,a,t,n){return B[e]};const K=G;function g(e){return function(a,t){var n=t!=null&&t.context?String(t.context):"standalone",i;if(n==="formatting"&&e.formattingValues){var u=e.defaultFormattingWidth||e.defaultWidth,r=t!=null&&t.width?String(t.width):u;i=e.formattingValues[r]||e.formattingValues[u]}else{var l=e.defaultWidth,o=t!=null&&t.width?String(t.width):e.defaultWidth;i=e.values[o]||e.values[l]}var f=e.argumentCallback?e.argumentCallback(a):a;return i[f]}}var Z={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},ee={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},te={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},ae={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},ne={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},re={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},ie=function(e,a){var t=Number(e),n=t%100;if(n>20||n<10)switch(n%10){case 1:return t+"st";case 2:return t+"nd";case 3:return t+"rd"}return t+"th"},oe={ordinalNumber:ie,era:g({values:Z,defaultWidth:"wide"}),quarter:g({values:ee,defaultWidth:"wide",argumentCallback:function(e){return e-1}}),month:g({values:te,defaultWidth:"wide"}),day:g({values:ae,defaultWidth:"wide"}),dayPeriod:g({values:ne,defaultWidth:"wide",formattingValues:re,defaultFormattingWidth:"wide"})};const ue=oe;function b(e){return function(a){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=t.width,i=n&&e.matchPatterns[n]||e.matchPatterns[e.defaultMatchWidth],u=a.match(i);if(!u)return null;var r=u[0],l=n&&e.parsePatterns[n]||e.parsePatterns[e.defaultParseWidth],o=Array.isArray(l)?le(l,function(m){return m.test(r)}):se(l,function(m){return m.test(r)}),f;f=e.valueCallback?e.valueCallback(o):o,f=t.valueCallback?t.valueCallback(f):f;var c=a.slice(r.length);return{value:f,rest:c}}}function se(e,a){for(var t in e)if(e.hasOwnProperty(t)&&a(e[t]))return t}function le(e,a){for(var t=0;t<e.length;t++)if(a(e[t]))return t}function de(e){return function(a){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=a.match(e.matchPattern);if(!n)return null;var i=n[0],u=a.match(e.parsePattern);if(!u)return null;var r=e.valueCallback?e.valueCallback(u[0]):u[0];r=t.valueCallback?t.valueCallback(r):r;var l=a.slice(i.length);return{value:r,rest:l}}}var fe=/^(\d+)(th|st|nd|rd)?/i,me=/\d+/i,he={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},ce={any:[/^b/i,/^(a|c)/i]},ve={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},ge={any:[/1/i,/2/i,/3/i,/4/i]},be={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},Me={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},ye={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},we={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},pe={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},De={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},Pe={ordinalNumber:de({matchPattern:fe,parsePattern:me,valueCallback:function(e){return parseInt(e,10)}}),era:b({matchPatterns:he,defaultMatchWidth:"wide",parsePatterns:ce,defaultParseWidth:"any"}),quarter:b({matchPatterns:ve,defaultMatchWidth:"wide",parsePatterns:ge,defaultParseWidth:"any",valueCallback:function(e){return e+1}}),month:b({matchPatterns:be,defaultMatchWidth:"wide",parsePatterns:Me,defaultParseWidth:"any"}),day:b({matchPatterns:ye,defaultMatchWidth:"wide",parsePatterns:we,defaultParseWidth:"any"}),dayPeriod:b({matchPatterns:pe,defaultMatchWidth:"any",parsePatterns:De,defaultParseWidth:"any"})};const Se=Pe;var Te={code:"en-US",formatDistance:q,formatLong:Q,formatRelative:K,localize:ue,match:Se,options:{weekStartsOn:0,firstWeekContainsDate:1}};const We=Te;function W(e,a){if(e==null)throw new TypeError("assign requires that input parameter not be null or undefined");for(var t in a)Object.prototype.hasOwnProperty.call(a,t)&&(e[t]=a[t]);return e}function Ne(e){return W({},e)}var T=1440,Oe=2520,p=43200,Fe=86400;function xe(e,a,t){var n,i;h(2,arguments);var u=A(),r=(n=(i=t==null?void 0:t.locale)!==null&&i!==void 0?i:u.locale)!==null&&n!==void 0?n:We;if(!r.formatDistance)throw new RangeError("locale must contain formatDistance property");var l=M(e,a);if(isNaN(l))throw new RangeError("Invalid time value");var o=W(Ne(t),{addSuffix:Boolean(t==null?void 0:t.addSuffix),comparison:l}),f,c;l>0?(f=s(a),c=s(e)):(f=s(e),c=s(a));var m=z(c,f),N=(P(c)-P(f))/1e3,d=Math.round((m-N)/60),v;if(d<2)return t!=null&&t.includeSeconds?m<5?r.formatDistance("lessThanXSeconds",5,o):m<10?r.formatDistance("lessThanXSeconds",10,o):m<20?r.formatDistance("lessThanXSeconds",20,o):m<40?r.formatDistance("halfAMinute",0,o):m<60?r.formatDistance("lessThanXMinutes",1,o):r.formatDistance("xMinutes",1,o):d===0?r.formatDistance("lessThanXMinutes",1,o):r.formatDistance("xMinutes",d,o);if(d<45)return r.formatDistance("xMinutes",d,o);if(d<90)return r.formatDistance("aboutXHours",1,o);if(d<T){var O=Math.round(d/60);return r.formatDistance("aboutXHours",O,o)}else{if(d<Oe)return r.formatDistance("xDays",1,o);if(d<p){var F=Math.round(d/T);return r.formatDistance("xDays",F,o)}else if(d<Fe)return v=Math.round(d/p),r.formatDistance("aboutXMonths",v,o)}if(v=Y(c,f),v<12){var x=Math.round(d/p);return r.formatDistance("xMonths",x,o)}else{var D=v%12,y=Math.floor(v/12);return D<3?r.formatDistance("aboutXYears",y,o):D<9?r.formatDistance("overXYears",y,o):r.formatDistance("almostXYears",y+1,o)}}export{xe as f};
|