UNPKG

@anoki/fse-ui

Version:

FSE UI components library

3 lines (2 loc) 947 B
"use strict";const d=require("./index.cjs3.js");function h(s,i){const f=r=>r.toUTC(0,{keepLocalTime:!0}).startOf("day").valueOf(),a=f(i)-f(s);return Math.floor(d.default.fromMillis(a).as("days"))}function y(s,i,f){const a=[["years",(e,t)=>t.year-e.year],["quarters",(e,t)=>t.quarter-e.quarter+(t.year-e.year)*4],["months",(e,t)=>t.month-e.month+(t.year-e.year)*12],["weeks",(e,t)=>{const u=h(e,t);return(u-u%7)/7}],["days",h]],r={},l=s;let o,n;for(const[e,t]of a)f.indexOf(e)>=0&&(o=e,r[e]=t(s,i),n=l.plus(r),n>i?(r[e]--,s=l.plus(r),s>i&&(n=s,r[e]--,s=l.plus(r))):s=n);return[s,r,n,o]}function m(s,i,f,a){let[r,l,o,n]=y(s,i,f);const e=i-r,t=f.filter(c=>["hours","minutes","seconds","milliseconds"].indexOf(c)>=0);t.length===0&&(o<i&&(o=r.plus({[n]:1})),o!==r&&(l[n]=(l[n]||0)+e/(o-r)));const u=d.default.fromObject(l,a);return t.length>0?d.default.fromMillis(e,a).shiftTo(...t).plus(u):u}module.exports=m; //# sourceMappingURL=index.cjs233.js.map