UNPKG

@js-sugar/date

Version:

A multi-calendar, tree-shakable, extensible, immutable and lightweight date library for JavaScript

1 lines 2.62 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["jss-date"]=t():e["jss-date"]=t()}(this,(function(){return(this.webpackChunkjss_date=this.webpackChunkjss_date||[]).push([[918,668,695,866],{36:(e,t,o)=>{"use strict";o.r(t),o.d(t,{formatIso:()=>a});var n=o(157),r=o(891);function a(e,t){var o;if("gregory"!==(e=e.toLocale("en")).calendar.type){const t=n.Calendars.findByType("gregory");if(0==t.length)throw Error("A gregorian calendar is needed to format DateTime to ISO-8601");e=e.to(t[0])}return(0,r.format)(e,null!==(o=null==t?void 0:t.format)&&void 0!==o?o:r.Formats.iso)}},891:(e,t,o)=>{"use strict";o.r(t),o.d(t,{Formats:()=>s,format:()=>i});var n=o(913),r=o(603);const a=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|m{1,2}|s{1,2}|f{1,3}|c{1,2}|C{1,3}|a|A|z{1,3}|Z{1,3}/g;var s;function i(e,t,o){const{calendar:s,zone:i,locale:m,year:d,month:c,day:f,hour:u,minute:h,second:l,ms:g,ts:M}=e;let y,p,Y=(0,n.weekDay)(e),k=((0,r.weekDayLocale)(e),i.getOffset(M));const b={o:k,p:k>=0,s:k>=0?"+":"-",hr:Math.abs(Math.floor(k/60)),min:Math.abs(Math.floor(k%60))},w=(e,t=1)=>m.formatNumber(0===e?0:e,{minimumIntegerDigits:t}),z={Y:()=>w(d),YY:()=>w(d,4).substring(2),YYYY:()=>w(d,4),M:()=>w(c),MM:()=>w(c,4).substring(2),MMM:()=>(y||(y=m.getMonthNames(s,"short"),(null==o?void 0:o.shortMonthNameMaxLength)&&(y=y.map((e=>e.substring(0,o.shortMonthNameMaxLength))))),y[c-1]),MMMM:()=>(p||(p=m.getMonthNames(s,"long"),(null==o?void 0:o.longMonthNameMaxLength)&&(p=p.map((e=>e.substring(0,o.longMonthNameMaxLength))))),p[c-1]),d:()=>w(f),dd:()=>w(f,2),H:()=>w(u),HH:()=>w(u,2),h:()=>w(u%12),hh:()=>w(u%12,2),m:()=>w(h),mm:()=>w(h,2),s:()=>w(l),ss:()=>w(l,2),f:()=>w(g),fff:()=>w(g,3),c:()=>w(Y),cc:()=>w(Y),C:()=>m.getWeekdayNames("narrow")[Y],CC:()=>m.getWeekdayNames("short")[Y],CCC:()=>m.getWeekdayNames("long")[Y],z:()=>{const e=w(b.o);return b.p?`+${e}`:e},zz:()=>`${b.s}${w(b.hr,2)}:${w(b.min,2)}`,zzz:()=>`${b.s}${w(b.hr,2)}${w(b.min,2)}`,Z:()=>i.name,ZZ:()=>m.getZoneTitle(i.name,"short"),ZZZ:()=>m.getZoneTitle(i.name,"long")};return t.replace(a,((e,t)=>{let o;return o=t||(z[e]?z[e]():e),o}))}!function(e){e.iso="YYYY-MM-ddTHH:mm:ss.fffzz",e.isoDate="YYYY-MM-dd"}(s||(s={}))},603:(e,t,o)=>{"use strict";function n(e){return(e.locale.weekStart+e.calendar.weekDay(e.ts))%7}o.r(t),o.d(t,{weekDayLocale:()=>n})},913:(e,t,o)=>{"use strict";function n(e){return e.calendar.weekDay(e.ts+1e3*e.zone.getOffset(e.ts)*60)}o.r(t),o.d(t,{weekDay:()=>n})}},e=>{"use strict";var t;return t=36,e(e.s=t)}])}));