UNPKG

dayjs-ext

Version:

2KB immutable date time library alternative to Moment.js with the same modern API

3 lines (2 loc) 1.49 kB
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):t.dayjs_plugin_localizableFormat=n()}(this,function(){"use strict";var o=function(t,n,e){var r=String(t);return!r||r.length>=n?t:""+Array(n+1-r.length).join(e)+t},f={padStart:o,padZoneStr:function(t){var n=Math.abs(t),e=Math.floor(n/60),r=n%60;return(t<=0?"+":"-")+o(e,2,"0")+":"+o(r,2,"0")},monthDiff:function(t,n){var e=12*(n.year()-t.year())+(n.month()-t.month()),r=t.clone().add(e,"months"),o=n-r<0,a=t.clone().add(e+(o?-1:1),"months"),i=Number(-(e+(n-r)/(o?r-a:a-r)));return 0===Math.abs(i)?0:i},absFloor:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},prettyUnit:function(t){return{M:"month",y:"year",w:"week",d:"day",h:"hour",m:"minute",s:"second",ms:"millisecond"}[t]||String(t||"").toLowerCase().replace(/s$/,"")},isUndefined:function(t){return void 0===t}};return function(t,n,e){var r=n.prototype,o=r.parse,a=r.format,i={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"};e.en.formats=i,r.parse=function(t){var n=t&&t.format;if(n){var e=f.getLocale(t.locale).formats||{};t.format=n.replace(/LTS|LT|L/g,function(t){return e[t]||i[t]})}o.call(this,t)},r.format=function(t){var n=this.$locale().formats||{},e=(t||"YYYY-MM-DDTHH:mm:ssZ").replace(/LTS|LT|L{1,4}/g,function(t){return n[t]||i[t]});return a.call(this,e)}}}); //# sourceMappingURL=localizableFormat.js.map