import{clampNumber as t}from"../utils.js";const e=1e3,n=6e4,r=36e5,i=864e5;function o(t){return new Date(t.getTime())}function u(t){return t instanceof Date&&!isNaN(t.getTime())}function f(e,n,r){return new Date(t(e.getTime(),n?.getTime(),r?.getTime()))}function c(t,e){return new Date(t,e+1,0).getDate()}const a={Y:function(t,e){const n=o(t),r=t.getUTCFullYear()+e;let i=t.getUTCDate();return i>28&&(i=Math.min(i,c(r,t.getUTCMonth())),n.setUTCDate(i)),n.setUTCFullYear(r),n},M:function(t,e){const n=o(t),r=Math.floor(e/12),i=e-12*r,u=t.getUTCFullYear()+r,f=t.getUTCMonth()+i;let a=t.getUTCDate();return a>28&&(a=Math.min(a,c(u,f)),n.setUTCDate(a)),n.setUTCFullYear(u),n.setUTCMonth(f),n},D:function(t,e){return a._shift(t,e*i)},H:function(t,e){return a._shift(t,e*r)},m:function(t,e){return a._shift(t,6e4*e)},s:function(t,e){return a._shift(t,1e3*e)},S:function(t,e){return a._shift(t,e)},_shift:function(t,e){return new Date(t.getTime()+e)}};function s(t,e,n){const r=a[e];if(null==r)throw new Error(`Cannot shift field "${e}".`);return r(t,n)}const T=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}(Z|[+-]\d{2}:\d{2})$/;function d(t){return g(t,T,(()=>new Date(t)))}const h=/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/;function l(t,e){return g(t,h,(()=>new Date(`${t}${"UTC"===e?"Z":""}`)))}function g(t,e,n){if(t.match(e)){const t=n();if(u(t))return t}throw new Error(`Invalid date "${t}"`)}export{i as DAY,r as HOUR,n as MINUTE,e as SECOND,f as clampDate,o as cloneDate,c as getNumberOfDaysInMonth,u as isDateValid,d as parseIsoDateString,l as parseSimpleDateString,s as shiftDateField};
//# sourceMappingURL=date-utils.js.map
