@esri/calcite-components
Version:
Web Components for Esri's Calcite Design System.
5 lines (4 loc) • 2.74 kB
JavaScript
/*! All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://github.com/Esri/calcite-design-system/blob/dev/LICENSE.md for details.
v3.2.1 */
import{k as f}from"./XDKVBD6O.js";function m(t,n,e){if(!t)return;let r=t.getTime(),a=!(n instanceof Date)||r>=n.getTime(),o=!(e instanceof Date)||r<=e.getTime();return a&&o}function p(t,n,e){if(!(t instanceof Date))return null;let r=t.getTime(),a=n instanceof Date&&r<n.getTime(),o=e instanceof Date&&r>e.getTime();return a?n:o?e:t}function O(t,n=!1){if(t instanceof Date)return t;if(!t||typeof t!="string")return null;let e=t.split(/[: T-]/).map(parseFloat),r=new Date(e[0],(e[1]||1)-1,e[2]||1);if(r.setFullYear(e[0]),isNaN(r.getTime()))throw new Error(`Invalid ISO 8601 date: "${t}"`);return n?T(r):r}function w(t,n){if(!n)return null;let{separator:e}=n,r=y(t,n),{day:a,month:o}=r,s=M(r.year,n),i=new Date(s,o,a);i.setFullYear(s);let c=a>0,u=o>-1,l=!isNaN(i.getTime()),D=t.split(e).filter(d=>d).length>2,h=s.toString().length>0;return c&&u&&l&&D&&h?i:null}function M(t,n){return g(t,n,"read")}function I(t,n){return g(t,n,"write")}function g(t,n,e){if(n["default-calendar"]!=="buddhist")return t;let a=543*(e==="read"?-1:1);return t+a}function F(t,n){let{separator:e,unitOrder:r}=n,a=S(r),o=t.split(e).map(u=>f.delocalize(u)),s=o[a.indexOf("d")],i=o[a.indexOf("m")],c=o[a.indexOf("y")];return{day:s,month:i,year:c}}function x(t){if(t instanceof Date){let n=String(t.getMonth()+1).padStart(2,"0"),e=String(t.getDate()).padStart(2,"0");return`${String(t.getFullYear()).padStart(4,"0")}-${n}-${e}`}return""}function E(t){let n=t.split("-");return{day:n[2],month:n[1],year:n[0]}}function v(t,n){return t instanceof Date&&n instanceof Date&&t.getDate()===n.getDate()&&t.getMonth()===n.getMonth()&&t.getFullYear()===n.getFullYear()}function A(t){let n=t.getMonth(),e=new Date(t);return e.setMonth(n-1),n===e.getMonth()?new Date(t.getFullYear(),n,0):e}function C(t,n){let e=new Date(t);return e.setMonth(n),e}function L(t,n,e){let r=new Date(t);return r.setDate(1),m(r,n,e)?r:p(r,n,e)}function N(t){let n=t.getMonth(),e=new Date(t);return e.setMonth(n+1),(n+2)%7===e.getMonth()%7?new Date(t.getFullYear(),n+2,0):e}function y(t,n){let{day:e,month:r,year:a}=F(t,n);return{day:parseInt(e),month:parseInt(r)-1,year:parseInt(a)}}function S(t){let n=["d","m","y"],e=t.toLowerCase();return n.sort((r,a)=>e.indexOf(r)-e.indexOf(a))}function R(t,n){let e=t.getTime(),r=n.getTime();return(e-r)/(1e3*3600*24)}function T(t){return t.setHours(23,59,59,999),t}function _(t,n){return t&&n&&t.getMonth()===n.getMonth()&&t.getFullYear()===n.getFullYear()}export{m as a,p as b,O as c,w as d,M as e,I as f,F as g,x as h,E as i,v as j,A as k,C as l,L as m,N as n,S as o,R as p,_ as q};