2 lines
11 KiB
JavaScript
2 lines
11 KiB
JavaScript
function m(e,t){if(t.length<e)throw new TypeError(e+" argument"+(e>1?"s":"")+" required, but only "+t.length+" present")}function l(e){m(1,arguments);var t=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&t==="[object Date]"?new Date(e.getTime()):typeof e=="number"||t==="[object Number]"?new Date(e):((typeof e=="string"||t==="[object String]")&&typeof console!="undefined"&&(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://git.io/fjule"),console.warn(new Error().stack)),new Date(NaN))}function y(e){var t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return t.setUTCFullYear(e.getFullYear()),e.getTime()-t.getTime()}function g(e,t){m(2,arguments);var a=l(e),n=l(t),i=a.getTime()-n.getTime();return i<0?-1:i>0?1:i}function N(e,t){m(2,arguments);var a=l(e),n=l(t),i=a.getFullYear()-n.getFullYear(),r=a.getMonth()-n.getMonth();return i*12+r}function F(e,t){return m(2,arguments),l(e).getTime()-l(t).getTime()}var D={ceil:Math.ceil,round:Math.round,floor:Math.floor,trunc:function(e){return e<0?Math.ceil(e):Math.floor(e)}},x="trunc";function k(e){return e?D[e]:D[x]}function A(e){m(1,arguments);var t=l(e);return t.setHours(23,59,59,999),t}function C(e){m(1,arguments);var t=l(e),a=t.getMonth();return t.setFullYear(t.getFullYear(),a+1,0),t.setHours(23,59,59,999),t}function X(e){m(1,arguments);var t=l(e);return A(t).getTime()===C(t).getTime()}function I(e,t){m(2,arguments);var a=l(e),n=l(t),i=g(a,n),r=Math.abs(N(a,n)),o;if(r<1)o=0;else{a.getMonth()===1&&a.getDate()>27&&a.setDate(30),a.setMonth(a.getMonth()-i*r);var s=g(a,n)===-i;X(l(e))&&r===1&&g(e,n)===1&&(s=!1),o=i*(r-Number(s))}return o===0?0:o}function O(e,t,a){m(2,arguments);var n=F(e,t)/1e3;return k(a==null?void 0:a.roundingMethod)(n)}var j={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"}},E=function(e,t,a){var n,i=j[e];return typeof i=="string"?n=i:t===1?n=i.one:n=i.other.replace("{{count}}",t.toString()),a!=null&&a.addSuffix?a.comparison&&a.comparison>0?"in "+n:n+" ago":n},R=E;function M(e){return function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},a=t.width?String(t.width):e.defaultWidth,n=e.formats[a]||e.formats[e.defaultWidth];return n}}var Y={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},_={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},z={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},L={date:M({formats:Y,defaultWidth:"full"}),time:M({formats:_,defaultWidth:"full"}),dateTime:M({formats:z,defaultWidth:"full"})},V=L,q={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},H=function(e,t,a,n){return q[e]},J=H;function c(e){return function(t,a){var n=a||{},i=n.context?String(n.context):"standalone",r;if(i==="formatting"&&e.formattingValues){var o=e.defaultFormattingWidth||e.defaultWidth,s=n.width?String(n.width):o;r=e.formattingValues[s]||e.formattingValues[o]}else{var d=e.defaultWidth,h=n.width?String(n.width):e.defaultWidth;r=e.values[h]||e.values[d]}var u=e.argumentCallback?e.argumentCallback(t):t;return r[u]}}var U={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Q={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},$={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"]},B={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"]},K={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"}},G={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"}},Z=function(e,t){var a=Number(e),n=a%100;if(n>20||n<10)switch(n%10){case 1:return a+"st";case 2:return a+"nd";case 3:return a+"rd"}return a+"th"},ee={ordinalNumber:Z,era:c({values:U,defaultWidth:"wide"}),quarter:c({values:Q,defaultWidth:"wide",argumentCallback:function(e){return e-1}}),month:c({values:$,defaultWidth:"wide"}),day:c({values:B,defaultWidth:"wide"}),dayPeriod:c({values:K,defaultWidth:"wide",formattingValues:G,defaultFormattingWidth:"wide"})},te=ee;function v(e){return function(t){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=a.width,i=n&&e.matchPatterns[n]||e.matchPatterns[e.defaultMatchWidth],r=t.match(i);if(!r)return null;var o=r[0],s=n&&e.parsePatterns[n]||e.parsePatterns[e.defaultParseWidth],d=Array.isArray(s)?ne(s,function(f){return f.test(o)}):ae(s,function(f){return f.test(o)}),h;h=e.valueCallback?e.valueCallback(d):d,h=a.valueCallback?a.valueCallback(h):h;var u=t.slice(o.length);return{value:h,rest:u}}}function ae(e,t){for(var a in e)if(e.hasOwnProperty(a)&&t(e[a]))return a}function ne(e,t){for(var a=0;a<e.length;a++)if(t(e[a]))return a}function re(e){return function(t){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=t.match(e.matchPattern);if(!n)return null;var i=n[0],r=t.match(e.parsePattern);if(!r)return null;var o=e.valueCallback?e.valueCallback(r[0]):r[0];o=a.valueCallback?a.valueCallback(o):o;var s=t.slice(i.length);return{value:o,rest:s}}}var ie=/^(\d+)(th|st|nd|rd)?/i,oe=/\d+/i,ue={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},se={any:[/^b/i,/^(a|c)/i]},le={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},de={any:[/1/i,/2/i,/3/i,/4/i]},fe={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]},he={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},ce={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]},ve={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},ge={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}},be={ordinalNumber:re({matchPattern:ie,parsePattern:oe,valueCallback:function(e){return parseInt(e,10)}}),era:v({matchPatterns:ue,defaultMatchWidth:"wide",parsePatterns:se,defaultParseWidth:"any"}),quarter:v({matchPatterns:le,defaultMatchWidth:"wide",parsePatterns:de,defaultParseWidth:"any",valueCallback:function(e){return e+1}}),month:v({matchPatterns:fe,defaultMatchWidth:"wide",parsePatterns:me,defaultParseWidth:"any"}),day:v({matchPatterns:he,defaultMatchWidth:"wide",parsePatterns:ce,defaultParseWidth:"any"}),dayPeriod:v({matchPatterns:ve,defaultMatchWidth:"any",parsePatterns:ge,defaultParseWidth:"any"})},Me=be,pe={code:"en-US",formatDistance:R,formatLong:V,formatRelative:J,localize:te,match:Me,options:{weekStartsOn:0,firstWeekContainsDate:1}},we=pe;function ye(e,t){if(e==null)throw new TypeError("assign requires that input parameter not be null or undefined");t=t||{};for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e}function De(e){return ye({},e)}var P=1440,Pe=2520,p=43200,Se=86400;function Te(e,t){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};m(2,arguments);var n=a.locale||we;if(!n.formatDistance)throw new RangeError("locale must contain formatDistance property");var i=g(e,t);if(isNaN(i))throw new RangeError("Invalid time value");var r=De(a);r.addSuffix=Boolean(a.addSuffix),r.comparison=i;var o,s;i>0?(o=l(t),s=l(e)):(o=l(e),s=l(t));var d=O(s,o),h=(y(s)-y(o))/1e3,u=Math.round((d-h)/60),f;if(u<2)return a.includeSeconds?d<5?n.formatDistance("lessThanXSeconds",5,r):d<10?n.formatDistance("lessThanXSeconds",10,r):d<20?n.formatDistance("lessThanXSeconds",20,r):d<40?n.formatDistance("halfAMinute",null,r):d<60?n.formatDistance("lessThanXMinutes",1,r):n.formatDistance("xMinutes",1,r):u===0?n.formatDistance("lessThanXMinutes",1,r):n.formatDistance("xMinutes",u,r);if(u<45)return n.formatDistance("xMinutes",u,r);if(u<90)return n.formatDistance("aboutXHours",1,r);if(u<P){var S=Math.round(u/60);return n.formatDistance("aboutXHours",S,r)}else{if(u<Pe)return n.formatDistance("xDays",1,r);if(u<p){var T=Math.round(u/P);return n.formatDistance("xDays",T,r)}else if(u<Se)return f=Math.round(u/p),n.formatDistance("aboutXMonths",f,r)}if(f=I(s,o),f<12){var W=Math.round(u/p);return n.formatDistance("xMonths",W,r)}else{var w=f%12,b=Math.floor(f/12);return w<3?n.formatDistance("aboutXYears",b,r):w<9?n.formatDistance("overXYears",b,r):n.formatDistance("almostXYears",b+1,r)}}export{Te as f};
|