@leancodepl/api-date-dayjs 9.7.2 → 9.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +663 -0
- package/LICENSE +201 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +689 -0
- package/dist/index.umd.cjs +1 -0
- package/{src → dist}/lib/date/fromApiDate.d.ts +3 -2
- package/dist/lib/date/fromApiDate.d.ts.map +1 -0
- package/{src → dist}/lib/date/toApiDate.d.ts +3 -2
- package/dist/lib/date/toApiDate.d.ts.map +1 -0
- package/{src → dist}/lib/dateTimeOffset/fromApiDateTimeOffset.d.ts +3 -2
- package/dist/lib/dateTimeOffset/fromApiDateTimeOffset.d.ts.map +1 -0
- package/{src → dist}/lib/dateTimeOffset/toApiDateTimeOffset.d.ts +3 -2
- package/dist/lib/dateTimeOffset/toApiDateTimeOffset.d.ts.map +1 -0
- package/{src → dist}/lib/time/fromApiTime.d.ts +3 -2
- package/dist/lib/time/fromApiTime.d.ts.map +1 -0
- package/{src → dist}/lib/time/toApiTime.d.ts +3 -2
- package/dist/lib/time/toApiTime.d.ts.map +1 -0
- package/{src → dist}/lib/timeSpan/fromApiTimeSpan.d.ts +3 -2
- package/dist/lib/timeSpan/fromApiTimeSpan.d.ts.map +1 -0
- package/{src → dist}/lib/timeSpan/toApiTimeSpan.d.ts +3 -2
- package/dist/lib/timeSpan/toApiTimeSpan.d.ts.map +1 -0
- package/{src → dist}/lib/utils/dropLocalOffset.d.ts +2 -1
- package/dist/lib/utils/dropLocalOffset.d.ts.map +1 -0
- package/package.json +21 -16
- package/index.cjs.default.js +0 -1
- package/index.cjs.js +0 -108
- package/index.cjs.mjs +0 -2
- package/index.d.ts +0 -1
- package/index.esm.js +0 -92
- package/src/index.d.ts +0 -10
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(W,Q){typeof exports=="object"&&typeof module<"u"?Q(exports):typeof define=="function"&&define.amd?define(["exports"],Q):(W=typeof globalThis<"u"?globalThis:W||self,Q(W["@leancodepl/api-date-dayjs"]={}))})(this,(function(W){"use strict";function Q(l){return l&&l.__esModule&&Object.prototype.hasOwnProperty.call(l,"default")?l.default:l}var tt={exports:{}},pt=tt.exports,ft;function Mt(){return ft||(ft=1,(function(l,Z){(function(k,y){l.exports=y()})(pt,(function(){var k=1e3,y=6e4,P=36e5,I="millisecond",O="second",H="minute",D="hour",C="day",w="week",A="month",N="quarter",L="year",j="date",c="Invalid Date",u=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,m=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,g={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(s){var n=["th","st","nd","rd"],t=s%100;return"["+s+(n[(t-20)%10]||n[t]||n[0])+"]"}},v=function(s,n,t){var o=String(s);return!o||o.length>=n?s:""+Array(n+1-o.length).join(t)+s},U={s:v,z:function(s){var n=-s.utcOffset(),t=Math.abs(n),o=Math.floor(t/60),r=t%60;return(n<=0?"+":"-")+v(o,2,"0")+":"+v(r,2,"0")},m:function s(n,t){if(n.date()<t.date())return-s(t,n);var o=12*(t.year()-n.year())+(t.month()-n.month()),r=n.clone().add(o,A),f=t-r<0,h=n.clone().add(o+(f?-1:1),A);return+(-(o+(t-r)/(f?r-h:h-r))||0)},a:function(s){return s<0?Math.ceil(s)||0:Math.floor(s)},p:function(s){return{M:A,y:L,w,d:C,D:j,h:D,m:H,s:O,ms:I,Q:N}[s]||String(s||"").toLowerCase().replace(/s$/,"")},u:function(s){return s===void 0}},b="en",p={};p[b]=g;var i="$isDayjsObject",e=function(s){return s instanceof S||!(!s||!s[i])},$=function s(n,t,o){var r;if(!n)return b;if(typeof n=="string"){var f=n.toLowerCase();p[f]&&(r=f),t&&(p[f]=t,r=f);var h=n.split("-");if(!r&&h.length>1)return s(h[0])}else{var M=n.name;p[M]=n,r=M}return!o&&r&&(b=r),r||!o&&b},d=function(s,n){if(e(s))return s.clone();var t=typeof n=="object"?n:{};return t.date=s,t.args=arguments,new S(t)},a=U;a.l=$,a.i=e,a.w=function(s,n){return d(s,{locale:n.$L,utc:n.$u,x:n.$x,$offset:n.$offset})};var S=(function(){function s(t){this.$L=$(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[i]=!0}var n=s.prototype;return n.parse=function(t){this.$d=(function(o){var r=o.date,f=o.utc;if(r===null)return new Date(NaN);if(a.u(r))return new Date;if(r instanceof Date)return new Date(r);if(typeof r=="string"&&!/Z$/i.test(r)){var h=r.match(u);if(h){var M=h[2]-1||0,T=(h[7]||"0").substring(0,3);return f?new Date(Date.UTC(h[1],M,h[3]||1,h[4]||0,h[5]||0,h[6]||0,T)):new Date(h[1],M,h[3]||1,h[4]||0,h[5]||0,h[6]||0,T)}}return new Date(r)})(t),this.init()},n.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},n.$utils=function(){return a},n.isValid=function(){return this.$d.toString()!==c},n.isSame=function(t,o){var r=d(t);return this.startOf(o)<=r&&r<=this.endOf(o)},n.isAfter=function(t,o){return d(t)<this.startOf(o)},n.isBefore=function(t,o){return this.endOf(o)<d(t)},n.$g=function(t,o,r){return a.u(t)?this[o]:this.set(r,t)},n.unix=function(){return Math.floor(this.valueOf()/1e3)},n.valueOf=function(){return this.$d.getTime()},n.startOf=function(t,o){var r=this,f=!!a.u(o)||o,h=a.p(t),M=function(J,F){var q=a.w(r.$u?Date.UTC(r.$y,F,J):new Date(r.$y,F,J),r);return f?q:q.endOf(C)},T=function(J,F){return a.w(r.toDate()[J].apply(r.toDate("s"),(f?[0,0,0,0]:[23,59,59,999]).slice(F)),r)},x=this.$W,_=this.$M,z=this.$D,X="set"+(this.$u?"UTC":"");switch(h){case L:return f?M(1,0):M(31,11);case A:return f?M(1,_):M(0,_+1);case w:var R=this.$locale().weekStart||0,G=(x<R?x+7:x)-R;return M(f?z-G:z+(6-G),_);case C:case j:return T(X+"Hours",0);case D:return T(X+"Minutes",1);case H:return T(X+"Seconds",2);case O:return T(X+"Milliseconds",3);default:return this.clone()}},n.endOf=function(t){return this.startOf(t,!1)},n.$set=function(t,o){var r,f=a.p(t),h="set"+(this.$u?"UTC":""),M=(r={},r[C]=h+"Date",r[j]=h+"Date",r[A]=h+"Month",r[L]=h+"FullYear",r[D]=h+"Hours",r[H]=h+"Minutes",r[O]=h+"Seconds",r[I]=h+"Milliseconds",r)[f],T=f===C?this.$D+(o-this.$W):o;if(f===A||f===L){var x=this.clone().set(j,1);x.$d[M](T),x.init(),this.$d=x.set(j,Math.min(this.$D,x.daysInMonth())).$d}else M&&this.$d[M](T);return this.init(),this},n.set=function(t,o){return this.clone().$set(t,o)},n.get=function(t){return this[a.p(t)]()},n.add=function(t,o){var r,f=this;t=Number(t);var h=a.p(o),M=function(_){var z=d(f);return a.w(z.date(z.date()+Math.round(_*t)),f)};if(h===A)return this.set(A,this.$M+t);if(h===L)return this.set(L,this.$y+t);if(h===C)return M(1);if(h===w)return M(7);var T=(r={},r[H]=y,r[D]=P,r[O]=k,r)[h]||1,x=this.$d.getTime()+t*T;return a.w(x,this)},n.subtract=function(t,o){return this.add(-1*t,o)},n.format=function(t){var o=this,r=this.$locale();if(!this.isValid())return r.invalidDate||c;var f=t||"YYYY-MM-DDTHH:mm:ssZ",h=a.z(this),M=this.$H,T=this.$m,x=this.$M,_=r.weekdays,z=r.months,X=r.meridiem,R=function(F,q,V,B){return F&&(F[q]||F(o,f))||V[q].slice(0,B)},G=function(F){return a.s(M%12||12,F,"0")},J=X||function(F,q,V){var B=F<12?"AM":"PM";return V?B.toLowerCase():B};return f.replace(m,(function(F,q){return q||(function(V){switch(V){case"YY":return String(o.$y).slice(-2);case"YYYY":return a.s(o.$y,4,"0");case"M":return x+1;case"MM":return a.s(x+1,2,"0");case"MMM":return R(r.monthsShort,x,z,3);case"MMMM":return R(z,x);case"D":return o.$D;case"DD":return a.s(o.$D,2,"0");case"d":return String(o.$W);case"dd":return R(r.weekdaysMin,o.$W,_,2);case"ddd":return R(r.weekdaysShort,o.$W,_,3);case"dddd":return _[o.$W];case"H":return String(M);case"HH":return a.s(M,2,"0");case"h":return G(1);case"hh":return G(2);case"a":return J(M,T,!0);case"A":return J(M,T,!1);case"m":return String(T);case"mm":return a.s(T,2,"0");case"s":return String(o.$s);case"ss":return a.s(o.$s,2,"0");case"SSS":return a.s(o.$ms,3,"0");case"Z":return h}return null})(F)||h.replace(":","")}))},n.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},n.diff=function(t,o,r){var f,h=this,M=a.p(o),T=d(t),x=(T.utcOffset()-this.utcOffset())*y,_=this-T,z=function(){return a.m(h,T)};switch(M){case L:f=z()/12;break;case A:f=z();break;case N:f=z()/3;break;case w:f=(_-x)/6048e5;break;case C:f=(_-x)/864e5;break;case D:f=_/P;break;case H:f=_/y;break;case O:f=_/k;break;default:f=_}return r?f:a.a(f)},n.daysInMonth=function(){return this.endOf(A).$D},n.$locale=function(){return p[this.$L]},n.locale=function(t,o){if(!t)return this.$L;var r=this.clone(),f=$(t,o,!0);return f&&(r.$L=f),r},n.clone=function(){return a.w(this.$d,this)},n.toDate=function(){return new Date(this.valueOf())},n.toJSON=function(){return this.isValid()?this.toISOString():null},n.toISOString=function(){return this.$d.toISOString()},n.toString=function(){return this.$d.toUTCString()},s})(),Y=S.prototype;return d.prototype=Y,[["$ms",I],["$s",O],["$m",H],["$H",D],["$W",C],["$M",A],["$y",L],["$D",j]].forEach((function(s){Y[s[1]]=function(n){return this.$g(n,s[0],s[1])}})),d.extend=function(s,n){return s.$i||(s(n,S,d),s.$i=!0),d},d.locale=$,d.isDayjs=e,d.unix=function(s){return d(1e3*s)},d.en=p[b],d.Ls=p,d.p={},d}))})(tt)),tt.exports}var Dt=Mt();const E=Q(Dt);var et={exports:{}},yt=et.exports,ht;function gt(){return ht||(ht=1,(function(l,Z){(function(k,y){l.exports=y()})(yt,(function(){var k={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"},y=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|Q|YYYY|YY?|ww?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,P=/\d/,I=/\d\d/,O=/\d\d?/,H=/\d*[^-_:/,()\s\d]+/,D={},C=function(u){return(u=+u)+(u>68?1900:2e3)},w=function(u){return function(m){this[u]=+m}},A=[/[+-]\d\d:?(\d\d)?|Z/,function(u){(this.zone||(this.zone={})).offset=(function(m){if(!m||m==="Z")return 0;var g=m.match(/([+-]|\d\d)/g),v=60*g[1]+(+g[2]||0);return v===0?0:g[0]==="+"?-v:v})(u)}],N=function(u){var m=D[u];return m&&(m.indexOf?m:m.s.concat(m.f))},L=function(u,m){var g,v=D.meridiem;if(v){for(var U=1;U<=24;U+=1)if(u.indexOf(v(U,0,m))>-1){g=U>12;break}}else g=u===(m?"pm":"PM");return g},j={A:[H,function(u){this.afternoon=L(u,!1)}],a:[H,function(u){this.afternoon=L(u,!0)}],Q:[P,function(u){this.month=3*(u-1)+1}],S:[P,function(u){this.milliseconds=100*+u}],SS:[I,function(u){this.milliseconds=10*+u}],SSS:[/\d{3}/,function(u){this.milliseconds=+u}],s:[O,w("seconds")],ss:[O,w("seconds")],m:[O,w("minutes")],mm:[O,w("minutes")],H:[O,w("hours")],h:[O,w("hours")],HH:[O,w("hours")],hh:[O,w("hours")],D:[O,w("day")],DD:[I,w("day")],Do:[H,function(u){var m=D.ordinal,g=u.match(/\d+/);if(this.day=g[0],m)for(var v=1;v<=31;v+=1)m(v).replace(/\[|\]/g,"")===u&&(this.day=v)}],w:[O,w("week")],ww:[I,w("week")],M:[O,w("month")],MM:[I,w("month")],MMM:[H,function(u){var m=N("months"),g=(N("monthsShort")||m.map((function(v){return v.slice(0,3)}))).indexOf(u)+1;if(g<1)throw new Error;this.month=g%12||g}],MMMM:[H,function(u){var m=N("months").indexOf(u)+1;if(m<1)throw new Error;this.month=m%12||m}],Y:[/[+-]?\d+/,w("year")],YY:[I,function(u){this.year=C(u)}],YYYY:[/\d{4}/,w("year")],Z:A,ZZ:A};function c(u){var m,g;m=u,g=D&&D.formats;for(var v=(u=m.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(d,a,S){var Y=S&&S.toUpperCase();return a||g[S]||k[S]||g[Y].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(s,n,t){return n||t.slice(1)}))}))).match(y),U=v.length,b=0;b<U;b+=1){var p=v[b],i=j[p],e=i&&i[0],$=i&&i[1];v[b]=$?{regex:e,parser:$}:p.replace(/^\[|\]$/g,"")}return function(d){for(var a={},S=0,Y=0;S<U;S+=1){var s=v[S];if(typeof s=="string")Y+=s.length;else{var n=s.regex,t=s.parser,o=d.slice(Y),r=n.exec(o)[0];t.call(a,r),d=d.replace(r,"")}}return(function(f){var h=f.afternoon;if(h!==void 0){var M=f.hours;h?M<12&&(f.hours+=12):M===12&&(f.hours=0),delete f.afternoon}})(a),a}}return function(u,m,g){g.p.customParseFormat=!0,u&&u.parseTwoDigitYear&&(C=u.parseTwoDigitYear);var v=m.prototype,U=v.parse;v.parse=function(b){var p=b.date,i=b.utc,e=b.args;this.$u=i;var $=e[1];if(typeof $=="string"){var d=e[2]===!0,a=e[3]===!0,S=d||a,Y=e[2];a&&(Y=e[2]),D=this.$locale(),!d&&Y&&(D=g.Ls[Y]),this.$d=(function(o,r,f,h){try{if(["x","X"].indexOf(r)>-1)return new Date((r==="X"?1e3:1)*o);var M=c(r)(o),T=M.year,x=M.month,_=M.day,z=M.hours,X=M.minutes,R=M.seconds,G=M.milliseconds,J=M.zone,F=M.week,q=new Date,V=_||(T||x?1:q.getDate()),B=T||q.getFullYear(),st=0;T&&!x||(st=x>0?x-1:q.getMonth());var it,ot=z||0,ut=X||0,at=R||0,ct=G||0;return J?new Date(Date.UTC(B,st,V,ot,ut,at,ct+60*J.offset*1e3)):f?new Date(Date.UTC(B,st,V,ot,ut,at,ct)):(it=new Date(B,st,V,ot,ut,at,ct),F&&(it=h(it).week(F).toDate()),it)}catch{return new Date("")}})(p,$,i,g),this.init(),Y&&Y!==!0&&(this.$L=this.locale(Y).$L),S&&p!=this.format($)&&(this.$d=new Date("")),D={}}else if($ instanceof Array)for(var s=$.length,n=1;n<=s;n+=1){e[1]=$[n-1];var t=g.apply(this,e);if(t.isValid()){this.$d=t.$d,this.$L=t.$L,this.init();break}n===s&&(this.$d=new Date(""))}else U.call(this,b)}}}))})(et)),et.exports}var St=gt();const dt=Q(St);E.extend(dt);function Yt(l){if(l)return E(l,"HH:mm:ss.SSS")}function wt(l){if(l)return l.format("HH:mm:ss.SSS")}function Ot(l){if(l)return E(l)}var nt={exports:{}},Tt=nt.exports,lt;function xt(){return lt||(lt=1,(function(l,Z){(function(k,y){l.exports=y()})(Tt,(function(){var k="minute",y=/[+-]\d\d(?::?\d\d)?/g,P=/([+-]|\d\d)/g;return function(I,O,H){var D=O.prototype;H.utc=function(c){var u={date:c,utc:!0,args:arguments};return new O(u)},D.utc=function(c){var u=H(this.toDate(),{locale:this.$L,utc:!0});return c?u.add(this.utcOffset(),k):u},D.local=function(){return H(this.toDate(),{locale:this.$L,utc:!1})};var C=D.parse;D.parse=function(c){c.utc&&(this.$u=!0),this.$utils().u(c.$offset)||(this.$offset=c.$offset),C.call(this,c)};var w=D.init;D.init=function(){if(this.$u){var c=this.$d;this.$y=c.getUTCFullYear(),this.$M=c.getUTCMonth(),this.$D=c.getUTCDate(),this.$W=c.getUTCDay(),this.$H=c.getUTCHours(),this.$m=c.getUTCMinutes(),this.$s=c.getUTCSeconds(),this.$ms=c.getUTCMilliseconds()}else w.call(this)};var A=D.utcOffset;D.utcOffset=function(c,u){var m=this.$utils().u;if(m(c))return this.$u?0:m(this.$offset)?A.call(this):this.$offset;if(typeof c=="string"&&(c=(function(b){b===void 0&&(b="");var p=b.match(y);if(!p)return null;var i=(""+p[0]).match(P)||["-",0,0],e=i[0],$=60*+i[1]+ +i[2];return $===0?0:e==="+"?$:-$})(c),c===null))return this;var g=Math.abs(c)<=16?60*c:c,v=this;if(u)return v.$offset=g,v.$u=c===0,v;if(c!==0){var U=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(v=this.local().add(g+U,k)).$offset=g,v.$x.$localOffset=U}else v=this.utc();return v};var N=D.format;D.format=function(c){var u=c||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return N.call(this,u)},D.valueOf=function(){var c=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*c},D.isUTC=function(){return!!this.$u},D.toISOString=function(){return this.toDate().toISOString()},D.toString=function(){return this.toDate().toUTCString()};var L=D.toDate;D.toDate=function(c){return c==="s"&&this.$offset?H(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():L.call(this)};var j=D.diff;D.diff=function(c,u,m){if(c&&this.$u===c.$u)return j.call(this,c,u,m);var g=this.local(),v=H(c).local();return j.call(g,v,u,m)}}}))})(nt)),nt.exports}var Ht=xt();const bt=Q(Ht);E.extend(bt);function mt(l){return l.clone().utc(!0)}function kt(l){if(l)return mt(l).startOf("day").format("YYYY-MM-DD")}E.extend(dt);function At(l){if(l)return E(l,"YYYY-MM-DDTHH:mm:ss.SSSZ")}function Lt(l){if(l)return l.format("YYYY-MM-DDTHH:mm:ss.SSSZ")}var rt={exports:{}},_t=rt.exports,$t;function Ct(){return $t||($t=1,(function(l,Z){(function(k,y){l.exports=y()})(_t,(function(){var k,y,P=1e3,I=6e4,O=36e5,H=864e5,D=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,C=31536e6,w=2628e6,A=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,N={years:C,months:w,days:H,hours:O,minutes:I,seconds:P,milliseconds:1,weeks:6048e5},L=function(p){return p instanceof U},j=function(p,i,e){return new U(p,e,i.$l)},c=function(p){return y.p(p)+"s"},u=function(p){return p<0},m=function(p){return u(p)?Math.ceil(p):Math.floor(p)},g=function(p){return Math.abs(p)},v=function(p,i){return p?u(p)?{negative:!0,format:""+g(p)+i}:{negative:!1,format:""+p+i}:{negative:!1,format:""}},U=(function(){function p(e,$,d){var a=this;if(this.$d={},this.$l=d,e===void 0&&(this.$ms=0,this.parseFromMilliseconds()),$)return j(e*N[c($)],this);if(typeof e=="number")return this.$ms=e,this.parseFromMilliseconds(),this;if(typeof e=="object")return Object.keys(e).forEach((function(s){a.$d[c(s)]=e[s]})),this.calMilliseconds(),this;if(typeof e=="string"){var S=e.match(A);if(S){var Y=S.slice(2).map((function(s){return s!=null?Number(s):0}));return this.$d.years=Y[0],this.$d.months=Y[1],this.$d.weeks=Y[2],this.$d.days=Y[3],this.$d.hours=Y[4],this.$d.minutes=Y[5],this.$d.seconds=Y[6],this.calMilliseconds(),this}}return this}var i=p.prototype;return i.calMilliseconds=function(){var e=this;this.$ms=Object.keys(this.$d).reduce((function($,d){return $+(e.$d[d]||0)*N[d]}),0)},i.parseFromMilliseconds=function(){var e=this.$ms;this.$d.years=m(e/C),e%=C,this.$d.months=m(e/w),e%=w,this.$d.days=m(e/H),e%=H,this.$d.hours=m(e/O),e%=O,this.$d.minutes=m(e/I),e%=I,this.$d.seconds=m(e/P),e%=P,this.$d.milliseconds=e},i.toISOString=function(){var e=v(this.$d.years,"Y"),$=v(this.$d.months,"M"),d=+this.$d.days||0;this.$d.weeks&&(d+=7*this.$d.weeks);var a=v(d,"D"),S=v(this.$d.hours,"H"),Y=v(this.$d.minutes,"M"),s=this.$d.seconds||0;this.$d.milliseconds&&(s+=this.$d.milliseconds/1e3,s=Math.round(1e3*s)/1e3);var n=v(s,"S"),t=e.negative||$.negative||a.negative||S.negative||Y.negative||n.negative,o=S.format||Y.format||n.format?"T":"",r=(t?"-":"")+"P"+e.format+$.format+a.format+o+S.format+Y.format+n.format;return r==="P"||r==="-P"?"P0D":r},i.toJSON=function(){return this.toISOString()},i.format=function(e){var $=e||"YYYY-MM-DDTHH:mm:ss",d={Y:this.$d.years,YY:y.s(this.$d.years,2,"0"),YYYY:y.s(this.$d.years,4,"0"),M:this.$d.months,MM:y.s(this.$d.months,2,"0"),D:this.$d.days,DD:y.s(this.$d.days,2,"0"),H:this.$d.hours,HH:y.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:y.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:y.s(this.$d.seconds,2,"0"),SSS:y.s(this.$d.milliseconds,3,"0")};return $.replace(D,(function(a,S){return S||String(d[a])}))},i.as=function(e){return this.$ms/N[c(e)]},i.get=function(e){var $=this.$ms,d=c(e);return d==="milliseconds"?$%=1e3:$=d==="weeks"?m($/N[d]):this.$d[d],$||0},i.add=function(e,$,d){var a;return a=$?e*N[c($)]:L(e)?e.$ms:j(e,this).$ms,j(this.$ms+a*(d?-1:1),this)},i.subtract=function(e,$){return this.add(e,$,!0)},i.locale=function(e){var $=this.clone();return $.$l=e,$},i.clone=function(){return j(this.$ms,this)},i.humanize=function(e){return k().add(this.$ms,"ms").locale(this.$l).fromNow(!e)},i.valueOf=function(){return this.asMilliseconds()},i.milliseconds=function(){return this.get("milliseconds")},i.asMilliseconds=function(){return this.as("milliseconds")},i.seconds=function(){return this.get("seconds")},i.asSeconds=function(){return this.as("seconds")},i.minutes=function(){return this.get("minutes")},i.asMinutes=function(){return this.as("minutes")},i.hours=function(){return this.get("hours")},i.asHours=function(){return this.as("hours")},i.days=function(){return this.get("days")},i.asDays=function(){return this.as("days")},i.weeks=function(){return this.get("weeks")},i.asWeeks=function(){return this.as("weeks")},i.months=function(){return this.get("months")},i.asMonths=function(){return this.as("months")},i.years=function(){return this.get("years")},i.asYears=function(){return this.as("years")},p})(),b=function(p,i,e){return p.add(i.years()*e,"y").add(i.months()*e,"M").add(i.days()*e,"d").add(i.hours()*e,"h").add(i.minutes()*e,"m").add(i.seconds()*e,"s").add(i.milliseconds()*e,"ms")};return function(p,i,e){k=e,y=e().$utils(),e.duration=function(a,S){var Y=e.locale();return j(a,{$l:Y},S)},e.isDuration=L;var $=i.prototype.add,d=i.prototype.subtract;i.prototype.add=function(a,S){return L(a)?b(this,a,1):$.bind(this)(a,S)},i.prototype.subtract=function(a,S){return L(a)?b(this,a,-1):d.bind(this)(a,S)}}}))})(rt)),rt.exports}var jt=Ct();const vt=Q(jt),K=l=>Number.parseInt(l??"0");function Ut(l){const Z=l.match(/^(-)?(\d+)?\.?(\d{2}):(\d{2}):(\d{2})\.?(\d{3})?$/);return{sign:Z?.[1],values:{days:K(Z?.[2]),hours:K(Z?.[3]),minutes:K(Z?.[4]),seconds:K(Z?.[5]),milliseconds:K(Z?.[6])}}}E.extend(vt);function Ft(l){if(!l)return;const Z=Ut(l),k=Z.sign==="-",y=E.duration(Z.values);return k?E.duration(-y.asMilliseconds()):y}E.extend(vt);function Pt(l){if(!l)return;const Z=l.asMilliseconds()<0,k=E.duration(Math.abs(l.asMilliseconds())),y=Math.floor(k.asDays());let P="";return Z&&(P+="-"),y>0&&(P+=`${y}.`),P+=k.format("HH:mm:ss.SSS"),P}W.dropLocalOffset=mt,W.fromApiDate=Ot,W.fromApiDateTimeOffset=At,W.fromApiTime=Yt,W.fromApiTimeSpan=Ft,W.toApiDate=kt,W.toApiDateTimeOffset=Lt,W.toApiTime=wt,W.toApiTimeSpan=Pt,Object.defineProperty(W,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import dayjs from
|
|
2
|
-
import
|
|
1
|
+
import { default as dayjs } from 'dayjs';
|
|
2
|
+
import { ApiDateOnly } from '@leancodepl/api-date';
|
|
3
3
|
/**
|
|
4
4
|
* Converts ApiDateOnly to Day.js object.
|
|
5
5
|
*
|
|
@@ -18,3 +18,4 @@ import type { ApiDateOnly } from "@leancodepl/api-date";
|
|
|
18
18
|
*/
|
|
19
19
|
export declare function fromApiDate(date: ApiDateOnly): dayjs.Dayjs;
|
|
20
20
|
export declare function fromApiDate(date: ApiDateOnly | undefined): dayjs.Dayjs | undefined;
|
|
21
|
+
//# sourceMappingURL=fromApiDate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fromApiDate.d.ts","sourceRoot":"","sources":["../../../src/lib/date/fromApiDate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAEvD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,WAAW,GAAG,KAAK,CAAC,KAAK,CAAA;AAC3D,wBAAgB,WAAW,CAAC,IAAI,EAAE,WAAW,GAAG,SAAS,GAAG,KAAK,CAAC,KAAK,GAAG,SAAS,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import dayjs from
|
|
2
|
-
import
|
|
1
|
+
import { default as dayjs } from 'dayjs';
|
|
2
|
+
import { ApiDateOnly } from '@leancodepl/api-date';
|
|
3
3
|
/**
|
|
4
4
|
* Converts Day.js object to ApiDateOnly.
|
|
5
5
|
*
|
|
@@ -19,3 +19,4 @@ import type { ApiDateOnly } from "@leancodepl/api-date";
|
|
|
19
19
|
*/
|
|
20
20
|
export declare function toApiDate(date: dayjs.Dayjs): ApiDateOnly;
|
|
21
21
|
export declare function toApiDate(date: dayjs.Dayjs | undefined): ApiDateOnly | undefined;
|
|
22
|
+
//# sourceMappingURL=toApiDate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toApiDate.d.ts","sourceRoot":"","sources":["../../../src/lib/date/toApiDate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAGvD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,GAAG,WAAW,CAAA;AACzD,wBAAgB,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,CAAA"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import dayjs from
|
|
2
|
-
import
|
|
1
|
+
import { default as dayjs } from 'dayjs';
|
|
2
|
+
import { ApiDateTimeOffset } from '@leancodepl/api-date';
|
|
3
3
|
/**
|
|
4
4
|
*This function handles at most milliseconds precision, smaller units are lost in conversion process
|
|
5
5
|
*/
|
|
6
6
|
export declare function fromApiDateTimeOffset(datetime: ApiDateTimeOffset): dayjs.Dayjs;
|
|
7
7
|
export declare function fromApiDateTimeOffset(datetime: ApiDateTimeOffset | undefined): dayjs.Dayjs | undefined;
|
|
8
|
+
//# sourceMappingURL=fromApiDateTimeOffset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fromApiDateTimeOffset.d.ts","sourceRoot":"","sources":["../../../src/lib/dateTimeOffset/fromApiDateTimeOffset.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAI7D;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,KAAK,CAAC,KAAK,CAAA;AAC/E,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,SAAS,GAAG,KAAK,CAAC,KAAK,GAAG,SAAS,CAAA"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import dayjs from
|
|
2
|
-
import
|
|
1
|
+
import { default as dayjs } from 'dayjs';
|
|
2
|
+
import { ApiDateTimeOffset } from '@leancodepl/api-date';
|
|
3
3
|
/**
|
|
4
4
|
*This function handles at most milliseconds precision, smaller units are lost in conversion process
|
|
5
5
|
*/
|
|
6
6
|
export declare function toApiDateTimeOffset(time: dayjs.Dayjs): ApiDateTimeOffset;
|
|
7
7
|
export declare function toApiDateTimeOffset(time: dayjs.Dayjs | undefined): ApiDateTimeOffset | undefined;
|
|
8
|
+
//# sourceMappingURL=toApiDateTimeOffset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toApiDateTimeOffset.d.ts","sourceRoot":"","sources":["../../../src/lib/dateTimeOffset/toApiDateTimeOffset.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAE7D;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,GAAG,iBAAiB,CAAA;AACzE,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,GAAG,SAAS,GAAG,iBAAiB,GAAG,SAAS,CAAA"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import dayjs from
|
|
2
|
-
import
|
|
1
|
+
import { default as dayjs } from 'dayjs';
|
|
2
|
+
import { ApiTimeOnly } from '@leancodepl/api-date';
|
|
3
3
|
/**
|
|
4
4
|
*This function handles at most milliseconds precision, smaller units are lost in conversion process
|
|
5
5
|
*/
|
|
6
6
|
export declare function fromApiTime(time: ApiTimeOnly): dayjs.Dayjs;
|
|
7
7
|
export declare function fromApiTime(time: ApiTimeOnly | undefined): dayjs.Dayjs | undefined;
|
|
8
|
+
//# sourceMappingURL=fromApiTime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fromApiTime.d.ts","sourceRoot":"","sources":["../../../src/lib/time/fromApiTime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAIvD;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,WAAW,GAAG,KAAK,CAAC,KAAK,CAAA;AAC3D,wBAAgB,WAAW,CAAC,IAAI,EAAE,WAAW,GAAG,SAAS,GAAG,KAAK,CAAC,KAAK,GAAG,SAAS,CAAA"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import dayjs from
|
|
2
|
-
import
|
|
1
|
+
import { default as dayjs } from 'dayjs';
|
|
2
|
+
import { ApiTimeOnly } from '@leancodepl/api-date';
|
|
3
3
|
/**
|
|
4
4
|
*This function handles at most milliseconds precision, smaller units are lost in conversion process
|
|
5
5
|
*/
|
|
6
6
|
export declare function toApiTime(time: dayjs.Dayjs): ApiTimeOnly;
|
|
7
7
|
export declare function toApiTime(time: dayjs.Dayjs | undefined): ApiTimeOnly | undefined;
|
|
8
|
+
//# sourceMappingURL=toApiTime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toApiTime.d.ts","sourceRoot":"","sources":["../../../src/lib/time/toApiTime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAEvD;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,GAAG,WAAW,CAAA;AACzD,wBAAgB,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,CAAA"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import duration from
|
|
2
|
-
import
|
|
1
|
+
import { default as duration } from 'dayjs/plugin/duration';
|
|
2
|
+
import { ApiTimeSpan } from '@leancodepl/api-date';
|
|
3
3
|
/**
|
|
4
4
|
*This function handles at most milliseconds precision, smaller units are lost in conversion process
|
|
5
5
|
*/
|
|
6
6
|
export declare function fromApiTimeSpan(timeSpan: ApiTimeSpan): duration.Duration;
|
|
7
7
|
export declare function fromApiTimeSpan(timeSpan: ApiTimeSpan | undefined): duration.Duration | undefined;
|
|
8
|
+
//# sourceMappingURL=fromApiTimeSpan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fromApiTimeSpan.d.ts","sourceRoot":"","sources":["../../../src/lib/timeSpan/fromApiTimeSpan.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,uBAAuB,CAAA;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAKvD;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,WAAW,GAAG,QAAQ,CAAC,QAAQ,CAAA;AACzE,wBAAgB,eAAe,CAAC,QAAQ,EAAE,WAAW,GAAG,SAAS,GAAG,QAAQ,CAAC,QAAQ,GAAG,SAAS,CAAA"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import duration from
|
|
2
|
-
import
|
|
1
|
+
import { default as duration } from 'dayjs/plugin/duration';
|
|
2
|
+
import { ApiTimeSpan } from '@leancodepl/api-date';
|
|
3
3
|
/**
|
|
4
4
|
*This function handles at most milliseconds precision, smaller units are lost in conversion process
|
|
5
5
|
*/
|
|
6
6
|
export declare function toApiTimeSpan(duration: duration.Duration): ApiTimeSpan;
|
|
7
7
|
export declare function toApiTimeSpan(duration: duration.Duration | undefined): ApiTimeSpan | undefined;
|
|
8
|
+
//# sourceMappingURL=toApiTimeSpan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toApiTimeSpan.d.ts","sourceRoot":"","sources":["../../../src/lib/timeSpan/toApiTimeSpan.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,uBAAuB,CAAA;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAIvD;;GAEG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,GAAG,WAAW,CAAA;AACvE,wBAAgB,aAAa,CAAC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import dayjs from
|
|
1
|
+
import { default as dayjs } from 'dayjs';
|
|
2
2
|
/**
|
|
3
3
|
* This function keeps local time (excluding timezone/offset) but sets its offset to UTC
|
|
4
4
|
*/
|
|
5
5
|
export declare function dropLocalOffset(time: dayjs.Dayjs): dayjs.Dayjs;
|
|
6
|
+
//# sourceMappingURL=dropLocalOffset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropLocalOffset.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/dropLocalOffset.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,eAEhD"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leancodepl/api-date-dayjs",
|
|
3
|
-
"version": "9.7.
|
|
3
|
+
"version": "9.7.3",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
"./package.json": "./package.json",
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
5
17
|
"dependencies": {
|
|
6
|
-
"@leancodepl/api-date": "9.7.
|
|
7
|
-
"@leancodepl/api-date-utils": "9.7.
|
|
18
|
+
"@leancodepl/api-date": "9.7.3",
|
|
19
|
+
"@leancodepl/api-date-utils": "9.7.3",
|
|
8
20
|
"dayjs": ">=1.9.0"
|
|
9
21
|
},
|
|
10
22
|
"devDependencies": {
|
|
@@ -15,7 +27,7 @@
|
|
|
15
27
|
"registry": "https://registry.npmjs.org/"
|
|
16
28
|
},
|
|
17
29
|
"engines": {
|
|
18
|
-
"node": ">=
|
|
30
|
+
"node": ">=22.0.0"
|
|
19
31
|
},
|
|
20
32
|
"repository": {
|
|
21
33
|
"type": "git",
|
|
@@ -41,16 +53,9 @@
|
|
|
41
53
|
"url": "https://leancode.co"
|
|
42
54
|
},
|
|
43
55
|
"sideEffects": false,
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"."
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
"import": "./index.cjs.mjs",
|
|
50
|
-
"default": "./index.cjs.js"
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
"module": "./index.esm.js",
|
|
54
|
-
"main": "./index.cjs.js",
|
|
55
|
-
"types": "./index.d.ts"
|
|
56
|
+
"files": [
|
|
57
|
+
"dist",
|
|
58
|
+
"CHANGELOG.md",
|
|
59
|
+
"!**/*.tsbuildinfo"
|
|
60
|
+
]
|
|
56
61
|
}
|
package/index.cjs.default.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
exports._default = require('./index.cjs.js').default;
|
package/index.cjs.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var apiDate = require('@leancodepl/api-date');
|
|
4
|
-
var dayjs = require('dayjs');
|
|
5
|
-
var customParseFormat = require('dayjs/plugin/customParseFormat');
|
|
6
|
-
var utc = require('dayjs/plugin/utc');
|
|
7
|
-
var duration = require('dayjs/plugin/duration');
|
|
8
|
-
var apiDateUtils = require('@leancodepl/api-date-utils');
|
|
9
|
-
|
|
10
|
-
dayjs.extend(customParseFormat);
|
|
11
|
-
function fromApiTime(time) {
|
|
12
|
-
if (!time) {
|
|
13
|
-
return undefined;
|
|
14
|
-
}
|
|
15
|
-
return dayjs(time, "HH:mm:ss.SSS");
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function toApiTime(time) {
|
|
19
|
-
if (!time) {
|
|
20
|
-
return undefined;
|
|
21
|
-
}
|
|
22
|
-
return time.format("HH:mm:ss.SSS");
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function fromApiDate(date) {
|
|
26
|
-
if (!date) {
|
|
27
|
-
return undefined;
|
|
28
|
-
}
|
|
29
|
-
return dayjs(date);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
dayjs.extend(utc);
|
|
33
|
-
/**
|
|
34
|
-
* This function keeps local time (excluding timezone/offset) but sets its offset to UTC
|
|
35
|
-
*/ function dropLocalOffset(time) {
|
|
36
|
-
return time.clone().utc(true);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function toApiDate(date) {
|
|
40
|
-
if (!date) {
|
|
41
|
-
return undefined;
|
|
42
|
-
}
|
|
43
|
-
return dropLocalOffset(date).startOf("day").format("YYYY-MM-DD");
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
dayjs.extend(customParseFormat);
|
|
47
|
-
function fromApiDateTimeOffset(datetime) {
|
|
48
|
-
if (!datetime) {
|
|
49
|
-
return undefined;
|
|
50
|
-
}
|
|
51
|
-
return dayjs(datetime, "YYYY-MM-DDTHH:mm:ss.SSSZ");
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function toApiDateTimeOffset(time) {
|
|
55
|
-
if (!time) {
|
|
56
|
-
return undefined;
|
|
57
|
-
}
|
|
58
|
-
return time.format("YYYY-MM-DDTHH:mm:ss.SSSZ");
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
dayjs.extend(duration);
|
|
62
|
-
function fromApiTimeSpan(timeSpan) {
|
|
63
|
-
if (!timeSpan) {
|
|
64
|
-
return undefined;
|
|
65
|
-
}
|
|
66
|
-
const parsedDuration = apiDateUtils.parseApiTimeSpan(timeSpan);
|
|
67
|
-
const isNegative = parsedDuration.sign === "-";
|
|
68
|
-
const dayjsDuration = dayjs.duration(parsedDuration.values);
|
|
69
|
-
if (isNegative) {
|
|
70
|
-
return dayjs.duration(-dayjsDuration.asMilliseconds());
|
|
71
|
-
}
|
|
72
|
-
return dayjsDuration;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
dayjs.extend(duration);
|
|
76
|
-
function toApiTimeSpan(duration) {
|
|
77
|
-
if (!duration) {
|
|
78
|
-
return undefined;
|
|
79
|
-
}
|
|
80
|
-
const isNegative = duration.asMilliseconds() < 0;
|
|
81
|
-
const absDuration = dayjs.duration(Math.abs(duration.asMilliseconds()));
|
|
82
|
-
const days = Math.floor(absDuration.asDays());
|
|
83
|
-
let stringTimeSpan = "";
|
|
84
|
-
if (isNegative) {
|
|
85
|
-
stringTimeSpan += "-";
|
|
86
|
-
}
|
|
87
|
-
if (days > 0) {
|
|
88
|
-
stringTimeSpan += `${days}.`;
|
|
89
|
-
}
|
|
90
|
-
stringTimeSpan += absDuration.format("HH:mm:ss.SSS");
|
|
91
|
-
return stringTimeSpan;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
exports.dropLocalOffset = dropLocalOffset;
|
|
95
|
-
exports.fromApiDate = fromApiDate;
|
|
96
|
-
exports.fromApiDateTimeOffset = fromApiDateTimeOffset;
|
|
97
|
-
exports.fromApiTime = fromApiTime;
|
|
98
|
-
exports.fromApiTimeSpan = fromApiTimeSpan;
|
|
99
|
-
exports.toApiDate = toApiDate;
|
|
100
|
-
exports.toApiDateTimeOffset = toApiDateTimeOffset;
|
|
101
|
-
exports.toApiTime = toApiTime;
|
|
102
|
-
exports.toApiTimeSpan = toApiTimeSpan;
|
|
103
|
-
Object.keys(apiDate).forEach(function (k) {
|
|
104
|
-
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
105
|
-
enumerable: true,
|
|
106
|
-
get: function () { return apiDate[k]; }
|
|
107
|
-
});
|
|
108
|
-
});
|
package/index.cjs.mjs
DELETED
package/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./src/index";
|
package/index.esm.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
export * from '@leancodepl/api-date';
|
|
2
|
-
import dayjs from 'dayjs';
|
|
3
|
-
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
4
|
-
import utc from 'dayjs/plugin/utc';
|
|
5
|
-
import duration from 'dayjs/plugin/duration';
|
|
6
|
-
import { parseApiTimeSpan } from '@leancodepl/api-date-utils';
|
|
7
|
-
|
|
8
|
-
dayjs.extend(customParseFormat);
|
|
9
|
-
function fromApiTime(time) {
|
|
10
|
-
if (!time) {
|
|
11
|
-
return undefined;
|
|
12
|
-
}
|
|
13
|
-
return dayjs(time, "HH:mm:ss.SSS");
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function toApiTime(time) {
|
|
17
|
-
if (!time) {
|
|
18
|
-
return undefined;
|
|
19
|
-
}
|
|
20
|
-
return time.format("HH:mm:ss.SSS");
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function fromApiDate(date) {
|
|
24
|
-
if (!date) {
|
|
25
|
-
return undefined;
|
|
26
|
-
}
|
|
27
|
-
return dayjs(date);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
dayjs.extend(utc);
|
|
31
|
-
/**
|
|
32
|
-
* This function keeps local time (excluding timezone/offset) but sets its offset to UTC
|
|
33
|
-
*/ function dropLocalOffset(time) {
|
|
34
|
-
return time.clone().utc(true);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function toApiDate(date) {
|
|
38
|
-
if (!date) {
|
|
39
|
-
return undefined;
|
|
40
|
-
}
|
|
41
|
-
return dropLocalOffset(date).startOf("day").format("YYYY-MM-DD");
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
dayjs.extend(customParseFormat);
|
|
45
|
-
function fromApiDateTimeOffset(datetime) {
|
|
46
|
-
if (!datetime) {
|
|
47
|
-
return undefined;
|
|
48
|
-
}
|
|
49
|
-
return dayjs(datetime, "YYYY-MM-DDTHH:mm:ss.SSSZ");
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function toApiDateTimeOffset(time) {
|
|
53
|
-
if (!time) {
|
|
54
|
-
return undefined;
|
|
55
|
-
}
|
|
56
|
-
return time.format("YYYY-MM-DDTHH:mm:ss.SSSZ");
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
dayjs.extend(duration);
|
|
60
|
-
function fromApiTimeSpan(timeSpan) {
|
|
61
|
-
if (!timeSpan) {
|
|
62
|
-
return undefined;
|
|
63
|
-
}
|
|
64
|
-
const parsedDuration = parseApiTimeSpan(timeSpan);
|
|
65
|
-
const isNegative = parsedDuration.sign === "-";
|
|
66
|
-
const dayjsDuration = dayjs.duration(parsedDuration.values);
|
|
67
|
-
if (isNegative) {
|
|
68
|
-
return dayjs.duration(-dayjsDuration.asMilliseconds());
|
|
69
|
-
}
|
|
70
|
-
return dayjsDuration;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
dayjs.extend(duration);
|
|
74
|
-
function toApiTimeSpan(duration) {
|
|
75
|
-
if (!duration) {
|
|
76
|
-
return undefined;
|
|
77
|
-
}
|
|
78
|
-
const isNegative = duration.asMilliseconds() < 0;
|
|
79
|
-
const absDuration = dayjs.duration(Math.abs(duration.asMilliseconds()));
|
|
80
|
-
const days = Math.floor(absDuration.asDays());
|
|
81
|
-
let stringTimeSpan = "";
|
|
82
|
-
if (isNegative) {
|
|
83
|
-
stringTimeSpan += "-";
|
|
84
|
-
}
|
|
85
|
-
if (days > 0) {
|
|
86
|
-
stringTimeSpan += `${days}.`;
|
|
87
|
-
}
|
|
88
|
-
stringTimeSpan += absDuration.format("HH:mm:ss.SSS");
|
|
89
|
-
return stringTimeSpan;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export { dropLocalOffset, fromApiDate, fromApiDateTimeOffset, fromApiTime, fromApiTimeSpan, toApiDate, toApiDateTimeOffset, toApiTime, toApiTimeSpan };
|
package/src/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from "@leancodepl/api-date";
|
|
2
|
-
export * from "./lib/time/fromApiTime";
|
|
3
|
-
export * from "./lib/time/toApiTime";
|
|
4
|
-
export * from "./lib/date/fromApiDate";
|
|
5
|
-
export * from "./lib/date/toApiDate";
|
|
6
|
-
export * from "./lib/dateTimeOffset/fromApiDateTimeOffset";
|
|
7
|
-
export * from "./lib/dateTimeOffset/toApiDateTimeOffset";
|
|
8
|
-
export * from "./lib/timeSpan/fromApiTimeSpan";
|
|
9
|
-
export * from "./lib/timeSpan/toApiTimeSpan";
|
|
10
|
-
export * from "./lib/utils/dropLocalOffset";
|