date-fns
Version:
Modern JavaScript date utility library
1 lines • 12 kB
JavaScript
(()=>{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:`น้อยกว่า 1 วินาที`,other:`น้อยกว่า {{count}} วินาที`},xSeconds:{one:`1 วินาที`,other:`{{count}} วินาที`},halfAMinute:`ครึ่งนาที`,lessThanXMinutes:{one:`น้อยกว่า 1 นาที`,other:`น้อยกว่า {{count}} นาที`},xMinutes:{one:`1 นาที`,other:`{{count}} นาที`},aboutXHours:{one:`ประมาณ 1 ชั่วโมง`,other:`ประมาณ {{count}} ชั่วโมง`},xHours:{one:`1 ชั่วโมง`,other:`{{count}} ชั่วโมง`},xDays:{one:`1 วัน`,other:`{{count}} วัน`},aboutXWeeks:{one:`ประมาณ 1 สัปดาห์`,other:`ประมาณ {{count}} สัปดาห์`},xWeeks:{one:`1 สัปดาห์`,other:`{{count}} สัปดาห์`},aboutXMonths:{one:`ประมาณ 1 เดือน`,other:`ประมาณ {{count}} เดือน`},xMonths:{one:`1 เดือน`,other:`{{count}} เดือน`},aboutXYears:{one:`ประมาณ 1 ปี`,other:`ประมาณ {{count}} ปี`},xYears:{one:`1 ปี`,other:`{{count}} ปี`},overXYears:{one:`มากกว่า 1 ปี`,other:`มากกว่า {{count}} ปี`},almostXYears:{one:`เกือบ 1 ปี`,other:`เกือบ {{count}} ปี`}},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?e===`halfAMinute`?`ใน`+r:`ใน `+r:r+`ที่ผ่านมา`: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ที่ do MMMM y`,long:`do MMMM y`,medium:`d MMM y`,short:`dd/MM/yyyy`},defaultWidth:`full`}),time:c({formats:{full:`H:mm:ss น. zzzz`,long:`H:mm:ss น. z`,medium:`H:mm:ss น.`,short:`H:mm น.`},defaultWidth:`medium`}),dateTime:c({formats:{full:`{{date}} 'เวลา' {{time}}`,long:`{{date}} 'เวลา' {{time}}`,medium:`{{date}}, {{time}}`,short:`{{date}}, {{time}}`},defaultWidth:`full`})},u={lastWeek:`eeee'ที่แล้วเวลา' p`,yesterday:`'เมื่อวานนี้เวลา' p`,today:`'วันนี้เวลา' p`,tomorrow:`'พรุ่งนี้เวลา' p`,nextWeek:`eeee 'เวลา' 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){return String(e)},era:f({values:{narrow:[`B`,`คศ`],abbreviated:[`BC`,`ค.ศ.`],wide:[`ปีก่อนคริสตกาล`,`คริสต์ศักราช`]},defaultWidth:`wide`}),quarter:f({values:{narrow:[`1`,`2`,`3`,`4`],abbreviated:[`Q1`,`Q2`,`Q3`,`Q4`],wide:[`ไตรมาสแรก`,`ไตรมาสที่สอง`,`ไตรมาสที่สาม`,`ไตรมาสที่สี่`]},defaultWidth:`wide`,argumentCallback:function(e){return e-1}}),month:f({values:{narrow:[`ม.ค.`,`ก.พ.`,`มี.ค.`,`เม.ย.`,`พ.ค.`,`มิ.ย.`,`ก.ค.`,`ส.ค.`,`ก.ย.`,`ต.ค.`,`พ.ย.`,`ธ.ค.`],abbreviated:[`ม.ค.`,`ก.พ.`,`มี.ค.`,`เม.ย.`,`พ.ค.`,`มิ.ย.`,`ก.ค.`,`ส.ค.`,`ก.ย.`,`ต.ค.`,`พ.ย.`,`ธ.ค.`],wide:[`มกราคม`,`กุมภาพันธ์`,`มีนาคม`,`เมษายน`,`พฤษภาคม`,`มิถุนายน`,`กรกฎาคม`,`สิงหาคม`,`กันยายน`,`ตุลาคม`,`พฤศจิกายน`,`ธันวาคม`]},defaultWidth:`wide`}),day:f({values:{narrow:[`อา.`,`จ.`,`อ.`,`พ.`,`พฤ.`,`ศ.`,`ส.`],short:[`อา.`,`จ.`,`อ.`,`พ.`,`พฤ.`,`ศ.`,`ส.`],abbreviated:[`อา.`,`จ.`,`อ.`,`พ.`,`พฤ.`,`ศ.`,`ส.`],wide:[`อาทิตย์`,`จันทร์`,`อังคาร`,`พุธ`,`พฤหัสบดี`,`ศุกร์`,`เสาร์`]},defaultWidth:`wide`}),dayPeriod:f({values:{narrow:{am:`ก่อนเที่ยง`,pm:`หลังเที่ยง`,midnight:`เที่ยงคืน`,noon:`เที่ยง`,morning:`เช้า`,afternoon:`บ่าย`,evening:`เย็น`,night:`กลางคืน`},abbreviated:{am:`ก่อนเที่ยง`,pm:`หลังเที่ยง`,midnight:`เที่ยงคืน`,noon:`เที่ยง`,morning:`เช้า`,afternoon:`บ่าย`,evening:`เย็น`,night:`กลางคืน`},wide:{am:`ก่อนเที่ยง`,pm:`หลังเที่ยง`,midnight:`เที่ยงคืน`,noon:`เที่ยง`,morning:`เช้า`,afternoon:`บ่าย`,evening:`เย็น`,night:`กลางคืน`}},defaultWidth:`wide`,formattingValues:{narrow:{am:`ก่อนเที่ยง`,pm:`หลังเที่ยง`,midnight:`เที่ยงคืน`,noon:`เที่ยง`,morning:`ตอนเช้า`,afternoon:`ตอนกลางวัน`,evening:`ตอนเย็น`,night:`ตอนกลางคืน`},abbreviated:{am:`ก่อนเที่ยง`,pm:`หลังเที่ยง`,midnight:`เที่ยงคืน`,noon:`เที่ยง`,morning:`ตอนเช้า`,afternoon:`ตอนกลางวัน`,evening:`ตอนเย็น`,night:`ตอนกลางคืน`},wide:{am:`ก่อนเที่ยง`,pm:`หลังเที่ยง`,midnight:`เที่ยงคืน`,noon:`เที่ยง`,morning:`ตอนเช้า`,afternoon:`ตอนกลางวัน`,evening:`ตอนเย็น`,night:`ตอนกลางคืน`}},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:`th`,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:/^([bB]|[aA]|คศ)/i,abbreviated:/^([bB]\.?\s?[cC]\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?|ค\.?ศ\.?)/i,wide:/^(ก่อนคริสตกาล|คริสต์ศักราช|คริสตกาล)/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/^[bB]/i,/^(^[aA]|ค\.?ศ\.?|คริสตกาล|คริสต์ศักราช|)/i]},defaultParseWidth:`any`}),quarter:m({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^ไตรมาส(ที่)? ?[1234]/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/(1|แรก|หนึ่ง)/i,/(2|สอง)/i,/(3|สาม)/i,/(4|สี่)/i]},defaultParseWidth:`any`,valueCallback:function(e){return e+1}}),month:m({matchPatterns:{narrow:/^(ม\.?ค\.?|ก\.?พ\.?|มี\.?ค\.?|เม\.?ย\.?|พ\.?ค\.?|มิ\.?ย\.?|ก\.?ค\.?|ส\.?ค\.?|ก\.?ย\.?|ต\.?ค\.?|พ\.?ย\.?|ธ\.?ค\.?)/i,abbreviated:/^(ม\.?ค\.?|ก\.?พ\.?|มี\.?ค\.?|เม\.?ย\.?|พ\.?ค\.?|มิ\.?ย\.?|ก\.?ค\.?|ส\.?ค\.?|ก\.?ย\.?|ต\.?ค\.?|พ\.?ย\.?|ธ\.?ค\.?')/i,wide:/^(มกราคม|กุมภาพันธ์|มีนาคม|เมษายน|พฤษภาคม|มิถุนายน|กรกฎาคม|สิงหาคม|กันยายน|ตุลาคม|พฤศจิกายน|ธันวาคม)/i},defaultMatchWidth:`wide`,parsePatterns:{wide:[/^มก/i,/^กุม/i,/^มี/i,/^เม/i,/^พฤษ/i,/^มิ/i,/^กรก/i,/^ส/i,/^กัน/i,/^ต/i,/^พฤศ/i,/^ธ/i],any:[/^ม\.?ค\.?/i,/^ก\.?พ\.?/i,/^มี\.?ค\.?/i,/^เม\.?ย\.?/i,/^พ\.?ค\.?/i,/^มิ\.?ย\.?/i,/^ก\.?ค\.?/i,/^ส\.?ค\.?/i,/^ก\.?ย\.?/i,/^ต\.?ค\.?/i,/^พ\.?ย\.?/i,/^ธ\.?ค\.?/i]},defaultParseWidth:`any`}),day:m({matchPatterns:{narrow:/^(อา\.?|จ\.?|อ\.?|พฤ\.?|พ\.?|ศ\.?|ส\.?)/i,short:/^(อา\.?|จ\.?|อ\.?|พฤ\.?|พ\.?|ศ\.?|ส\.?)/i,abbreviated:/^(อา\.?|จ\.?|อ\.?|พฤ\.?|พ\.?|ศ\.?|ส\.?)/i,wide:/^(อาทิตย์|จันทร์|อังคาร|พุธ|พฤหัสบดี|ศุกร์|เสาร์)/i},defaultMatchWidth:`wide`,parsePatterns:{wide:[/^อา/i,/^จั/i,/^อั/i,/^พุธ/i,/^พฤ/i,/^ศ/i,/^เส/i],any:[/^อา/i,/^จ/i,/^อ/i,/^พ(?!ฤ)/i,/^พฤ/i,/^ศ/i,/^ส/i]},defaultParseWidth:`any`}),dayPeriod:m({matchPatterns:{any:/^(ก่อนเที่ยง|หลังเที่ยง|เที่ยงคืน|เที่ยง|(ตอน.*?)?.*(เที่ยง|เช้า|บ่าย|เย็น|กลางคืน))/i},defaultMatchWidth:`any`,parsePatterns:{any:{am:/^ก่อนเที่ยง/i,pm:/^หลังเที่ยง/i,midnight:/^เที่ยงคืน/i,noon:/^เที่ยง/i,morning:/เช้า/i,afternoon:/บ่าย/i,evening:/เย็น/i,night:/กลางคืน/i}},defaultParseWidth:`any`})},options:{weekStartsOn:0,firstWeekContainsDate:1}};window.dateFns=n(n({},window.dateFns),{},{locale:n(n({},window.dateFns?.locale),{},{th:v})}),console.log(`date-fns CDN files have moved to @date-fns/cdn. Please update your URLs. See: https://date-fns.org/docs/CDN`)})();