UNPKG

date-fns

Version:

Modern JavaScript date utility library

1 lines 10.5 kB
(()=>{function e(t){"@babel/helpers - typeof";return e=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},e(t)}function t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function n(e){for(var n=1;n<arguments.length;n++){var i=arguments[n]==null?{}:arguments[n];n%2?t(Object(i),!0).forEach(function(t){r(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):t(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}function r(e,t,n){return(t=i(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(t){var n=a(t,`string`);return e(n)==`symbol`?n:n+``}function a(t,n){if(e(t)!=`object`||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var i=r.call(t,n||`default`);if(e(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(n===`string`?String:Number)(t)}var o={lessThanXSeconds:{one:`dưới 1 giây`,other:`dưới {{count}} giây`},xSeconds:{one:`1 giây`,other:`{{count}} giây`},halfAMinute:`nửa phút`,lessThanXMinutes:{one:`dưới 1 phút`,other:`dưới {{count}} phút`},xMinutes:{one:`1 phút`,other:`{{count}} phút`},aboutXHours:{one:`khoảng 1 giờ`,other:`khoảng {{count}} giờ`},xHours:{one:`1 giờ`,other:`{{count}} giờ`},xDays:{one:`1 ngày`,other:`{{count}} ngày`},aboutXWeeks:{one:`khoảng 1 tuần`,other:`khoảng {{count}} tuần`},xWeeks:{one:`1 tuần`,other:`{{count}} tuần`},aboutXMonths:{one:`khoảng 1 tháng`,other:`khoảng {{count}} tháng`},xMonths:{one:`1 tháng`,other:`{{count}} tháng`},aboutXYears:{one:`khoảng 1 năm`,other:`khoảng {{count}} năm`},xYears:{one:`1 năm`,other:`{{count}} năm`},overXYears:{one:`hơn 1 năm`,other:`hơn {{count}} năm`},almostXYears:{one:`gần 1 năm`,other:`gần {{count}} năm`}},s=function(e,t,n){var r,i=o[e];return r=typeof i==`string`?i:t===1?i.one:i.other.replace(`{{count}}`,String(t)),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?r+` nữa`:r+` trước`:r};function c(e){return function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}var l={date:c({formats:{full:`EEEE, 'ngày' d MMMM 'năm' y`,long:`'ngày' d MMMM 'năm' y`,medium:`d MMM 'năm' y`,short:`dd/MM/y`},defaultWidth:`full`}),time:c({formats:{full:`HH:mm:ss zzzz`,long:`HH:mm:ss z`,medium:`HH:mm:ss`,short:`HH:mm`},defaultWidth:`full`}),dateTime:c({formats:{full:`{{date}} {{time}}`,long:`{{date}} {{time}}`,medium:`{{date}} {{time}}`,short:`{{date}} {{time}}`},defaultWidth:`full`})},u={lastWeek:`eeee 'tuần trước vào lúc' p`,yesterday:`'hôm qua vào lúc' p`,today:`'hôm nay vào lúc' p`,tomorrow:`'ngày mai vào lúc' p`,nextWeek:`eeee 'tới vào lúc' p`,other:`P`},d=function(e,t,n,r){return u[e]};function f(e){return function(t,n){var r=n!=null&&n.context?String(n.context):`standalone`,i;if(r===`formatting`&&e.formattingValues){var a=e.defaultFormattingWidth||e.defaultWidth,o=n!=null&&n.width?String(n.width):a;i=e.formattingValues[o]||e.formattingValues[a]}else{var s=e.defaultWidth,c=n!=null&&n.width?String(n.width):e.defaultWidth;i=e.values[c]||e.values[s]}var l=e.argumentCallback?e.argumentCallback(t):t;return i[l]}}var p={ordinalNumber:function(e,t){var n=Number(e),r=t?.unit;if(r===`quarter`)switch(n){case 1:return`I`;case 2:return`II`;case 3:return`III`;case 4:return`IV`}else if(r===`day`)switch(n){case 1:return`thứ 2`;case 2:return`thứ 3`;case 3:return`thứ 4`;case 4:return`thứ 5`;case 5:return`thứ 6`;case 6:return`thứ 7`;case 7:return`chủ nhật`}else if(r===`week`)return n===1?`thứ nhất`:`thứ `+n;else if(r===`dayOfYear`)return n===1?`đầu tiên`:`thứ `+n;return String(n)},era:f({values:{narrow:[`TCN`,`SCN`],abbreviated:[`trước CN`,`sau CN`],wide:[`trước Công Nguyên`,`sau Công Nguyên`]},defaultWidth:`wide`}),quarter:f({values:{narrow:[`1`,`2`,`3`,`4`],abbreviated:[`Q1`,`Q2`,`Q3`,`Q4`],wide:[`Quý 1`,`Quý 2`,`Quý 3`,`Quý 4`]},defaultWidth:`wide`,formattingValues:{narrow:[`1`,`2`,`3`,`4`],abbreviated:[`Q1`,`Q2`,`Q3`,`Q4`],wide:[`quý I`,`quý II`,`quý III`,`quý IV`]},defaultFormattingWidth:`wide`,argumentCallback:function(e){return e-1}}),month:f({values:{narrow:[`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`10`,`11`,`12`],abbreviated:[`Thg 1`,`Thg 2`,`Thg 3`,`Thg 4`,`Thg 5`,`Thg 6`,`Thg 7`,`Thg 8`,`Thg 9`,`Thg 10`,`Thg 11`,`Thg 12`],wide:[`Tháng Một`,`Tháng Hai`,`Tháng Ba`,`Tháng Tư`,`Tháng Năm`,`Tháng Sáu`,`Tháng Bảy`,`Tháng Tám`,`Tháng Chín`,`Tháng Mười`,`Tháng Mười Một`,`Tháng Mười Hai`]},defaultWidth:`wide`,formattingValues:{narrow:[`01`,`02`,`03`,`04`,`05`,`06`,`07`,`08`,`09`,`10`,`11`,`12`],abbreviated:[`thg 1`,`thg 2`,`thg 3`,`thg 4`,`thg 5`,`thg 6`,`thg 7`,`thg 8`,`thg 9`,`thg 10`,`thg 11`,`thg 12`],wide:[`tháng 01`,`tháng 02`,`tháng 03`,`tháng 04`,`tháng 05`,`tháng 06`,`tháng 07`,`tháng 08`,`tháng 09`,`tháng 10`,`tháng 11`,`tháng 12`]},defaultFormattingWidth:`wide`}),day:f({values:{narrow:[`CN`,`T2`,`T3`,`T4`,`T5`,`T6`,`T7`],short:[`CN`,`Th 2`,`Th 3`,`Th 4`,`Th 5`,`Th 6`,`Th 7`],abbreviated:[`CN`,`Thứ 2`,`Thứ 3`,`Thứ 4`,`Thứ 5`,`Thứ 6`,`Thứ 7`],wide:[`Chủ Nhật`,`Thứ Hai`,`Thứ Ba`,`Thứ Tư`,`Thứ Năm`,`Thứ Sáu`,`Thứ Bảy`]},defaultWidth:`wide`}),dayPeriod:f({values:{narrow:{am:`am`,pm:`pm`,midnight:`nửa đêm`,noon:`tr`,morning:`sg`,afternoon:`ch`,evening:`tối`,night:`đêm`},abbreviated:{am:`AM`,pm:`PM`,midnight:`nửa đêm`,noon:`trưa`,morning:`sáng`,afternoon:`chiều`,evening:`tối`,night:`đêm`},wide:{am:`SA`,pm:`CH`,midnight:`nửa đêm`,noon:`trưa`,morning:`sáng`,afternoon:`chiều`,evening:`tối`,night:`đêm`}},defaultWidth:`wide`,formattingValues:{narrow:{am:`am`,pm:`pm`,midnight:`nửa đêm`,noon:`tr`,morning:`sg`,afternoon:`ch`,evening:`tối`,night:`đêm`},abbreviated:{am:`AM`,pm:`PM`,midnight:`nửa đêm`,noon:`trưa`,morning:`sáng`,afternoon:`chiều`,evening:`tối`,night:`đêm`},wide:{am:`SA`,pm:`CH`,midnight:`nửa đêm`,noon:`giữa trưa`,morning:`vào buổi sáng`,afternoon:`vào buổi chiều`,evening:`vào buổi tối`,night:`vào ban đêm`}},defaultFormattingWidth:`wide`})};function m(e){return function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=n.width,i=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],a=t.match(i);if(!a)return null;var o=a[0],s=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(s)?g(s,function(e){return e.test(o)}):h(s,function(e){return e.test(o)}),l=e.valueCallback?e.valueCallback(c):c;l=n.valueCallback?n.valueCallback(l):l;var u=t.slice(o.length);return{value:l,rest:u}}}function h(e,t){for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function g(e,t){for(var n=0;n<e.length;n++)if(t(e[n]))return n}function _(e){return function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=t.match(e.matchPattern);if(!r)return null;var i=r[0],a=t.match(e.parsePattern);if(!a)return null;var o=e.valueCallback?e.valueCallback(a[0]):a[0];o=n.valueCallback?n.valueCallback(o):o;var s=t.slice(i.length);return{value:o,rest:s}}}var v={code:`vi`,formatDistance:s,formatLong:l,formatRelative:d,localize:p,match:{ordinalNumber:_({matchPattern:/^(\d+)/i,parsePattern:/\d+/i,valueCallback:function(e){return parseInt(e,10)}}),era:m({matchPatterns:{narrow:/^(tcn|scn)/i,abbreviated:/^(trước CN|sau CN)/i,wide:/^(trước Công Nguyên|sau Công Nguyên)/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/^t/i,/^s/i]},defaultParseWidth:`any`}),quarter:m({matchPatterns:{narrow:/^([1234]|i{1,3}v?)/i,abbreviated:/^q([1234]|i{1,3}v?)/i,wide:/^quý ([1234]|i{1,3}v?)/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/(1|i)$/i,/(2|ii)$/i,/(3|iii)$/i,/(4|iv)$/i]},defaultParseWidth:`any`,valueCallback:function(e){return e+1}}),month:m({matchPatterns:{narrow:/^(0?[2-9]|10|11|12|0?1)/i,abbreviated:/^thg[ _]?(0?[1-9](?!\d)|10|11|12)/i,wide:/^tháng ?(Một|Hai|Ba|Tư|Năm|Sáu|Bảy|Tám|Chín|Mười|Mười ?Một|Mười ?Hai|0?[1-9](?!\d)|10|11|12)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/0?1$/i,/0?2/i,/3/,/4/,/5/,/6/,/7/,/8/,/9/,/10/,/11/,/12/],abbreviated:[/^thg[ _]?0?1(?!\d)/i,/^thg[ _]?0?2/i,/^thg[ _]?0?3/i,/^thg[ _]?0?4/i,/^thg[ _]?0?5/i,/^thg[ _]?0?6/i,/^thg[ _]?0?7/i,/^thg[ _]?0?8/i,/^thg[ _]?0?9/i,/^thg[ _]?10/i,/^thg[ _]?11/i,/^thg[ _]?12/i],wide:[/^tháng ?(Một|0?1(?!\d))/i,/^tháng ?(Hai|0?2)/i,/^tháng ?(Ba|0?3)/i,/^tháng ?(Tư|0?4)/i,/^tháng ?(Năm|0?5)/i,/^tháng ?(Sáu|0?6)/i,/^tháng ?(Bảy|0?7)/i,/^tháng ?(Tám|0?8)/i,/^tháng ?(Chín|0?9)/i,/^tháng ?(Mười|10)/i,/^tháng ?(Mười ?Một|11)/i,/^tháng ?(Mười ?Hai|12)/i]},defaultParseWidth:`wide`}),day:m({matchPatterns:{narrow:/^(CN|T2|T3|T4|T5|T6|T7)/i,short:/^(CN|Th ?2|Th ?3|Th ?4|Th ?5|Th ?6|Th ?7)/i,abbreviated:/^(CN|Th ?2|Th ?3|Th ?4|Th ?5|Th ?6|Th ?7)/i,wide:/^(Chủ ?Nhật|Chúa ?Nhật|thứ ?Hai|thứ ?Ba|thứ ?Tư|thứ ?Năm|thứ ?Sáu|thứ ?Bảy)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/CN/i,/2/i,/3/i,/4/i,/5/i,/6/i,/7/i],short:[/CN/i,/2/i,/3/i,/4/i,/5/i,/6/i,/7/i],abbreviated:[/CN/i,/2/i,/3/i,/4/i,/5/i,/6/i,/7/i],wide:[/(Chủ|Chúa) ?Nhật/i,/Hai/i,/Ba/i,/Tư/i,/Năm/i,/Sáu/i,/Bảy/i]},defaultParseWidth:`wide`}),dayPeriod:m({matchPatterns:{narrow:/^(a|p|nửa đêm|trưa|(giờ) (sáng|chiều|tối|đêm))/i,abbreviated:/^(am|pm|nửa đêm|trưa|(giờ) (sáng|chiều|tối|đêm))/i,wide:/^(ch[^i]*|sa|nửa đêm|trưa|(giờ) (sáng|chiều|tối|đêm))/i},defaultMatchWidth:`wide`,parsePatterns:{any:{am:/^(a|sa)/i,pm:/^(p|ch[^i]*)/i,midnight:/nửa đêm/i,noon:/trưa/i,morning:/sáng/i,afternoon:/chiều/i,evening:/tối/i,night:/^đêm/i}},defaultParseWidth:`any`})},options:{weekStartsOn:1,firstWeekContainsDate:1}};window.dateFns=n(n({},window.dateFns),{},{locale:n(n({},window.dateFns?.locale),{},{vi:v})}),console.log(`date-fns CDN files have moved to @date-fns/cdn. Please update your URLs. See: https://date-fns.org/docs/CDN`)})();