@fluixi/utils 1.0.0-alpha.53
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/LICENSE +21 -0
- package/README.md +73 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/dist/lib/array/advanced.cjs +1 -0
- package/dist/lib/array/advanced.d.ts +1116 -0
- package/dist/lib/array/advanced.d.ts.map +1 -0
- package/dist/lib/array/advanced.js +2429 -0
- package/dist/lib/array/advanced.mjs +1 -0
- package/dist/lib/array/array.cjs +1 -0
- package/dist/lib/array/array.d.ts +6 -0
- package/dist/lib/array/array.d.ts.map +1 -0
- package/dist/lib/array/array.js +31 -0
- package/dist/lib/array/array.mjs +1 -0
- package/dist/lib/array/index.cjs +1 -0
- package/dist/lib/array/index.d.ts +4 -0
- package/dist/lib/array/index.d.ts.map +1 -0
- package/dist/lib/array/index.js +3 -0
- package/dist/lib/array/index.mjs +1 -0
- package/dist/lib/array/utils.cjs +1 -0
- package/dist/lib/array/utils.d.ts +100 -0
- package/dist/lib/array/utils.d.ts.map +1 -0
- package/dist/lib/array/utils.js +165 -0
- package/dist/lib/array/utils.mjs +1 -0
- package/dist/lib/color/color.cjs +1 -0
- package/dist/lib/color/color.d.ts +366 -0
- package/dist/lib/color/color.d.ts.map +1 -0
- package/dist/lib/color/color.js +722 -0
- package/dist/lib/color/color.mjs +1 -0
- package/dist/lib/color/constants.cjs +1 -0
- package/dist/lib/color/constants.d.ts +361 -0
- package/dist/lib/color/constants.d.ts.map +1 -0
- package/dist/lib/color/constants.js +358 -0
- package/dist/lib/color/constants.mjs +1 -0
- package/dist/lib/color/conversions.cjs +1 -0
- package/dist/lib/color/conversions.d.ts +166 -0
- package/dist/lib/color/conversions.d.ts.map +1 -0
- package/dist/lib/color/conversions.js +766 -0
- package/dist/lib/color/conversions.mjs +1 -0
- package/dist/lib/color/helpers.cjs +1 -0
- package/dist/lib/color/helpers.d.ts +75 -0
- package/dist/lib/color/helpers.d.ts.map +1 -0
- package/dist/lib/color/helpers.js +419 -0
- package/dist/lib/color/helpers.mjs +1 -0
- package/dist/lib/color/index.cjs +1 -0
- package/dist/lib/color/index.d.ts +12 -0
- package/dist/lib/color/index.d.ts.map +1 -0
- package/dist/lib/color/index.js +15 -0
- package/dist/lib/color/index.mjs +1 -0
- package/dist/lib/color/types.cjs +1 -0
- package/dist/lib/color/types.d.ts +179 -0
- package/dist/lib/color/types.d.ts.map +1 -0
- package/dist/lib/color/types.js +1 -0
- package/dist/lib/color/types.mjs +0 -0
- package/dist/lib/color/utils.cjs +1 -0
- package/dist/lib/color/utils.d.ts +199 -0
- package/dist/lib/color/utils.d.ts.map +1 -0
- package/dist/lib/color/utils.js +858 -0
- package/dist/lib/color/utils.mjs +1 -0
- package/dist/lib/compare/comparators.cjs +1 -0
- package/dist/lib/compare/comparators.d.ts +65 -0
- package/dist/lib/compare/comparators.d.ts.map +1 -0
- package/dist/lib/compare/comparators.js +210 -0
- package/dist/lib/compare/comparators.mjs +1 -0
- package/dist/lib/compare/index.cjs +1 -0
- package/dist/lib/compare/index.d.ts +2 -0
- package/dist/lib/compare/index.d.ts.map +1 -0
- package/dist/lib/compare/index.js +1 -0
- package/dist/lib/compare/index.mjs +1 -0
- package/dist/lib/crypto/hash.cjs +1 -0
- package/dist/lib/crypto/hash.d.ts +6 -0
- package/dist/lib/crypto/hash.d.ts.map +1 -0
- package/dist/lib/crypto/hash.js +53 -0
- package/dist/lib/crypto/hash.mjs +1 -0
- package/dist/lib/crypto/index.cjs +1 -0
- package/dist/lib/crypto/index.d.ts +2 -0
- package/dist/lib/crypto/index.d.ts.map +1 -0
- package/dist/lib/crypto/index.js +1 -0
- package/dist/lib/crypto/index.mjs +1 -0
- package/dist/lib/dom/events.cjs +1 -0
- package/dist/lib/dom/events.d.ts +159 -0
- package/dist/lib/dom/events.d.ts.map +1 -0
- package/dist/lib/dom/events.js +50 -0
- package/dist/lib/dom/events.mjs +1 -0
- package/dist/lib/dom/index.cjs +1 -0
- package/dist/lib/dom/index.d.ts +3 -0
- package/dist/lib/dom/index.d.ts.map +1 -0
- package/dist/lib/dom/index.js +2 -0
- package/dist/lib/dom/index.mjs +1 -0
- package/dist/lib/dom/utils.cjs +1 -0
- package/dist/lib/dom/utils.d.ts +6 -0
- package/dist/lib/dom/utils.d.ts.map +1 -0
- package/dist/lib/dom/utils.js +37 -0
- package/dist/lib/dom/utils.mjs +1 -0
- package/dist/lib/functions/functions.cjs +1 -0
- package/dist/lib/functions/functions.d.ts +329 -0
- package/dist/lib/functions/functions.d.ts.map +1 -0
- package/dist/lib/functions/functions.js +585 -0
- package/dist/lib/functions/functions.mjs +1 -0
- package/dist/lib/functions/index.cjs +1 -0
- package/dist/lib/functions/index.d.ts +3 -0
- package/dist/lib/functions/index.d.ts.map +1 -0
- package/dist/lib/functions/index.js +1 -0
- package/dist/lib/functions/index.mjs +1 -0
- package/dist/lib/functions/types.cjs +1 -0
- package/dist/lib/functions/types.d.ts +2 -0
- package/dist/lib/functions/types.d.ts.map +1 -0
- package/dist/lib/functions/types.js +1 -0
- package/dist/lib/functions/types.mjs +0 -0
- package/dist/lib/helpers.cjs +1 -0
- package/dist/lib/helpers.d.ts +13 -0
- package/dist/lib/helpers.d.ts.map +1 -0
- package/dist/lib/helpers.js +66 -0
- package/dist/lib/helpers.mjs +1 -0
- package/dist/lib/index.cjs +1 -0
- package/dist/lib/index.d.ts +6 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +8 -0
- package/dist/lib/index.mjs +1 -0
- package/dist/lib/maths/constants.cjs +1 -0
- package/dist/lib/maths/constants.d.ts +84 -0
- package/dist/lib/maths/constants.d.ts.map +1 -0
- package/dist/lib/maths/constants.js +79 -0
- package/dist/lib/maths/constants.mjs +1 -0
- package/dist/lib/maths/fn/advanced.cjs +1 -0
- package/dist/lib/maths/fn/advanced.d.ts +149 -0
- package/dist/lib/maths/fn/advanced.d.ts.map +1 -0
- package/dist/lib/maths/fn/advanced.js +264 -0
- package/dist/lib/maths/fn/advanced.mjs +1 -0
- package/dist/lib/maths/fn/basic.cjs +1 -0
- package/dist/lib/maths/fn/basic.d.ts +182 -0
- package/dist/lib/maths/fn/basic.d.ts.map +1 -0
- package/dist/lib/maths/fn/basic.js +343 -0
- package/dist/lib/maths/fn/basic.mjs +1 -0
- package/dist/lib/maths/fn/complex.cjs +1 -0
- package/dist/lib/maths/fn/complex.d.ts +153 -0
- package/dist/lib/maths/fn/complex.d.ts.map +1 -0
- package/dist/lib/maths/fn/complex.js +383 -0
- package/dist/lib/maths/fn/complex.mjs +1 -0
- package/dist/lib/maths/fn/index.cjs +1 -0
- package/dist/lib/maths/fn/index.d.ts +10 -0
- package/dist/lib/maths/fn/index.d.ts.map +1 -0
- package/dist/lib/maths/fn/index.js +9 -0
- package/dist/lib/maths/fn/index.mjs +1 -0
- package/dist/lib/maths/fn/trigo.cjs +1 -0
- package/dist/lib/maths/fn/trigo.d.ts +147 -0
- package/dist/lib/maths/fn/trigo.d.ts.map +1 -0
- package/dist/lib/maths/fn/trigo.js +227 -0
- package/dist/lib/maths/fn/trigo.mjs +1 -0
- package/dist/lib/maths/fn/vector.cjs +1 -0
- package/dist/lib/maths/fn/vector.d.ts +512 -0
- package/dist/lib/maths/fn/vector.d.ts.map +1 -0
- package/dist/lib/maths/fn/vector.js +1136 -0
- package/dist/lib/maths/fn/vector.mjs +1 -0
- package/dist/lib/maths/formatter.cjs +1 -0
- package/dist/lib/maths/formatter.d.ts +35 -0
- package/dist/lib/maths/formatter.d.ts.map +1 -0
- package/dist/lib/maths/formatter.js +56 -0
- package/dist/lib/maths/formatter.mjs +1 -0
- package/dist/lib/maths/guards.cjs +1 -0
- package/dist/lib/maths/guards.d.ts +166 -0
- package/dist/lib/maths/guards.d.ts.map +1 -0
- package/dist/lib/maths/guards.js +315 -0
- package/dist/lib/maths/guards.mjs +1 -0
- package/dist/lib/maths/index.cjs +1 -0
- package/dist/lib/maths/index.d.ts +24 -0
- package/dist/lib/maths/index.d.ts.map +1 -0
- package/dist/lib/maths/index.js +29 -0
- package/dist/lib/maths/index.mjs +1 -0
- package/dist/lib/maths/parser.cjs +1 -0
- package/dist/lib/maths/parser.d.ts +20 -0
- package/dist/lib/maths/parser.d.ts.map +1 -0
- package/dist/lib/maths/parser.js +78 -0
- package/dist/lib/maths/parser.mjs +1 -0
- package/dist/lib/maths/random.cjs +1 -0
- package/dist/lib/maths/random.d.ts +27 -0
- package/dist/lib/maths/random.d.ts.map +1 -0
- package/dist/lib/maths/random.js +49 -0
- package/dist/lib/maths/random.mjs +1 -0
- package/dist/lib/maths/types/advanced.cjs +1 -0
- package/dist/lib/maths/types/advanced.d.ts +357 -0
- package/dist/lib/maths/types/advanced.d.ts.map +1 -0
- package/dist/lib/maths/types/advanced.js +5 -0
- package/dist/lib/maths/types/advanced.mjs +0 -0
- package/dist/lib/maths/types/basic.cjs +1 -0
- package/dist/lib/maths/types/basic.d.ts +95 -0
- package/dist/lib/maths/types/basic.d.ts.map +1 -0
- package/dist/lib/maths/types/basic.js +5 -0
- package/dist/lib/maths/types/basic.mjs +0 -0
- package/dist/lib/maths/types/index.cjs +1 -0
- package/dist/lib/maths/types/index.d.ts +4 -0
- package/dist/lib/maths/types/index.d.ts.map +1 -0
- package/dist/lib/maths/types/index.js +3 -0
- package/dist/lib/maths/types/index.mjs +0 -0
- package/dist/lib/maths/types/negative.cjs +1 -0
- package/dist/lib/maths/types/negative.d.ts +51 -0
- package/dist/lib/maths/types/negative.d.ts.map +1 -0
- package/dist/lib/maths/types/negative.js +5 -0
- package/dist/lib/maths/types/negative.mjs +0 -0
- package/dist/lib/maths/types/operations.cjs +1 -0
- package/dist/lib/maths/types/operations.d.ts +188 -0
- package/dist/lib/maths/types/operations.d.ts.map +1 -0
- package/dist/lib/maths/types/operations.js +6 -0
- package/dist/lib/maths/types/operations.mjs +0 -0
- package/dist/lib/object/clone.cjs +1 -0
- package/dist/lib/object/clone.d.ts +46 -0
- package/dist/lib/object/clone.d.ts.map +1 -0
- package/dist/lib/object/clone.js +104 -0
- package/dist/lib/object/clone.mjs +1 -0
- package/dist/lib/object/diff.cjs +1 -0
- package/dist/lib/object/diff.d.ts +203 -0
- package/dist/lib/object/diff.d.ts.map +1 -0
- package/dist/lib/object/diff.js +805 -0
- package/dist/lib/object/diff.mjs +1 -0
- package/dist/lib/object/getter-setter.cjs +1 -0
- package/dist/lib/object/getter-setter.d.ts +361 -0
- package/dist/lib/object/getter-setter.d.ts.map +1 -0
- package/dist/lib/object/getter-setter.js +1771 -0
- package/dist/lib/object/getter-setter.mjs +1 -0
- package/dist/lib/object/index.cjs +6 -0
- package/dist/lib/object/index.d.ts +13 -0
- package/dist/lib/object/index.d.ts.map +1 -0
- package/dist/lib/object/index.js +12 -0
- package/dist/lib/object/index.mjs +6 -0
- package/dist/lib/object/merge.cjs +1 -0
- package/dist/lib/object/merge.d.ts +93 -0
- package/dist/lib/object/merge.d.ts.map +1 -0
- package/dist/lib/object/merge.js +474 -0
- package/dist/lib/object/merge.mjs +1 -0
- package/dist/lib/object/object.cjs +1 -0
- package/dist/lib/object/object.d.ts +128 -0
- package/dist/lib/object/object.d.ts.map +1 -0
- package/dist/lib/object/object.js +432 -0
- package/dist/lib/object/object.mjs +1 -0
- package/dist/lib/object/omit.cjs +1 -0
- package/dist/lib/object/omit.d.ts +351 -0
- package/dist/lib/object/omit.d.ts.map +1 -0
- package/dist/lib/object/omit.js +656 -0
- package/dist/lib/object/omit.mjs +1 -0
- package/dist/lib/object/reconcile.cjs +1 -0
- package/dist/lib/object/reconcile.d.ts +7 -0
- package/dist/lib/object/reconcile.d.ts.map +1 -0
- package/dist/lib/object/reconcile.js +122 -0
- package/dist/lib/object/reconcile.mjs +1 -0
- package/dist/lib/object/selector.cjs +1 -0
- package/dist/lib/object/selector.d.ts +50 -0
- package/dist/lib/object/selector.d.ts.map +1 -0
- package/dist/lib/object/selector.js +371 -0
- package/dist/lib/object/selector.mjs +1 -0
- package/dist/lib/object/sort.cjs +1 -0
- package/dist/lib/object/sort.d.ts +149 -0
- package/dist/lib/object/sort.d.ts.map +1 -0
- package/dist/lib/object/sort.js +298 -0
- package/dist/lib/object/sort.mjs +1 -0
- package/dist/lib/object/transform.cjs +1 -0
- package/dist/lib/object/transform.d.ts +620 -0
- package/dist/lib/object/transform.d.ts.map +1 -0
- package/dist/lib/object/transform.js +1058 -0
- package/dist/lib/object/transform.mjs +1 -0
- package/dist/lib/object/types.cjs +1 -0
- package/dist/lib/object/types.d.ts +250 -0
- package/dist/lib/object/types.d.ts.map +1 -0
- package/dist/lib/object/types.js +1 -0
- package/dist/lib/object/types.mjs +0 -0
- package/dist/lib/object/utils.cjs +6 -0
- package/dist/lib/object/utils.d.ts +165 -0
- package/dist/lib/object/utils.d.ts.map +1 -0
- package/dist/lib/object/utils.js +444 -0
- package/dist/lib/object/utils.mjs +6 -0
- package/dist/lib/primitive/boolean/boolean.cjs +1 -0
- package/dist/lib/primitive/boolean/boolean.d.ts +276 -0
- package/dist/lib/primitive/boolean/boolean.d.ts.map +1 -0
- package/dist/lib/primitive/boolean/boolean.js +615 -0
- package/dist/lib/primitive/boolean/boolean.mjs +1 -0
- package/dist/lib/primitive/boolean/index.cjs +1 -0
- package/dist/lib/primitive/boolean/index.d.ts +3 -0
- package/dist/lib/primitive/boolean/index.d.ts.map +1 -0
- package/dist/lib/primitive/boolean/index.js +2 -0
- package/dist/lib/primitive/boolean/index.mjs +1 -0
- package/dist/lib/primitive/boolean/types.cjs +1 -0
- package/dist/lib/primitive/boolean/types.d.ts +14 -0
- package/dist/lib/primitive/boolean/types.d.ts.map +1 -0
- package/dist/lib/primitive/boolean/types.js +1 -0
- package/dist/lib/primitive/boolean/types.mjs +0 -0
- package/dist/lib/primitive/date/date.cjs +1 -0
- package/dist/lib/primitive/date/date.d.ts +641 -0
- package/dist/lib/primitive/date/date.d.ts.map +1 -0
- package/dist/lib/primitive/date/date.js +1998 -0
- package/dist/lib/primitive/date/date.mjs +1 -0
- package/dist/lib/primitive/date/index.cjs +1 -0
- package/dist/lib/primitive/date/index.d.ts +3 -0
- package/dist/lib/primitive/date/index.d.ts.map +1 -0
- package/dist/lib/primitive/date/index.js +2 -0
- package/dist/lib/primitive/date/index.mjs +1 -0
- package/dist/lib/primitive/date/types.cjs +1 -0
- package/dist/lib/primitive/date/types.d.ts +205 -0
- package/dist/lib/primitive/date/types.d.ts.map +1 -0
- package/dist/lib/primitive/date/types.js +7 -0
- package/dist/lib/primitive/date/types.mjs +0 -0
- package/dist/lib/primitive/index.cjs +5 -0
- package/dist/lib/primitive/index.d.ts +5 -0
- package/dist/lib/primitive/index.d.ts.map +1 -0
- package/dist/lib/primitive/index.js +4 -0
- package/dist/lib/primitive/index.mjs +5 -0
- package/dist/lib/primitive/string/index.cjs +5 -0
- package/dist/lib/primitive/string/index.d.ts +3 -0
- package/dist/lib/primitive/string/index.d.ts.map +1 -0
- package/dist/lib/primitive/string/index.js +2 -0
- package/dist/lib/primitive/string/index.mjs +5 -0
- package/dist/lib/primitive/string/parser-2.cjs +8 -0
- package/dist/lib/primitive/string/parser-2.d.ts +17 -0
- package/dist/lib/primitive/string/parser-2.d.ts.map +1 -0
- package/dist/lib/primitive/string/parser-2.js +656 -0
- package/dist/lib/primitive/string/parser-2.mjs +8 -0
- package/dist/lib/primitive/string/parser.cjs +3 -0
- package/dist/lib/primitive/string/parser.d.ts +9 -0
- package/dist/lib/primitive/string/parser.d.ts.map +1 -0
- package/dist/lib/primitive/string/parser.js +775 -0
- package/dist/lib/primitive/string/parser.mjs +3 -0
- package/dist/lib/primitive/string/string.cjs +5 -0
- package/dist/lib/primitive/string/string.d.ts +535 -0
- package/dist/lib/primitive/string/string.d.ts.map +1 -0
- package/dist/lib/primitive/string/string.js +1301 -0
- package/dist/lib/primitive/string/string.mjs +5 -0
- package/dist/lib/primitive/string/types.cjs +1 -0
- package/dist/lib/primitive/string/types.d.ts +318 -0
- package/dist/lib/primitive/string/types.d.ts.map +1 -0
- package/dist/lib/primitive/string/types.js +5 -0
- package/dist/lib/primitive/string/types.mjs +0 -0
- package/dist/lib/primitive/types.cjs +1 -0
- package/dist/lib/primitive/types.d.ts +27 -0
- package/dist/lib/primitive/types.d.ts.map +1 -0
- package/dist/lib/primitive/types.js +1 -0
- package/dist/lib/primitive/types.mjs +0 -0
- package/dist/lib/url/index.cjs +1 -0
- package/dist/lib/url/index.d.ts +3 -0
- package/dist/lib/url/index.d.ts.map +1 -0
- package/dist/lib/url/index.js +2 -0
- package/dist/lib/url/index.mjs +1 -0
- package/dist/lib/url/parser.cjs +1 -0
- package/dist/lib/url/parser.d.ts +216 -0
- package/dist/lib/url/parser.d.ts.map +1 -0
- package/dist/lib/url/parser.js +488 -0
- package/dist/lib/url/parser.mjs +1 -0
- package/dist/lib/url/types.cjs +1 -0
- package/dist/lib/url/types.d.ts +18 -0
- package/dist/lib/url/types.d.ts.map +1 -0
- package/dist/lib/url/types.js +1 -0
- package/dist/lib/url/types.mjs +0 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -0
- package/package.json +150 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var E=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var tt=Object.getOwnPropertyNames;var et=Object.prototype.hasOwnProperty;var rt=(t,e)=>{for(var n in e)E(t,n,{get:e[n],enumerable:!0})},nt=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of tt(e))!et.call(t,a)&&a!==n&&E(t,a,{get:()=>e[a],enumerable:!(r=X(e,a))||r.enumerable});return t};var at=t=>nt(E({},"__esModule",{value:!0}),t);var ae={};rt(ae,{add:()=>M,addBusinessDays:()=>Ht,addDays:()=>F,addMonths:()=>ht,addYears:()=>wt,configureDateUtils:()=>ot,convertTimezone:()=>U,createDate:()=>B,daysBetween:()=>Ut,difference:()=>j,endOf:()=>S,endOfDay:()=>Mt,endOfMonth:()=>yt,endOfWeek:()=>Tt,endOfYear:()=>$t,formatDate:()=>T,getAge:()=>_t,getDayName:()=>Pt,getDaysInMonth:()=>Wt,getMonthName:()=>zt,getQuarter:()=>Rt,getTimezoneInfo:()=>Bt,getWeekNumber:()=>At,humanizeDifference:()=>Ft,isAfter:()=>xt,isBefore:()=>kt,isBetween:()=>Yt,isBusinessDay:()=>K,isDate:()=>f,isFuture:()=>Z,isLeapYear:()=>Lt,isPast:()=>V,isSame:()=>N,isToday:()=>Ot,isWeekday:()=>Nt,isWeekend:()=>H,monthsBetween:()=>vt,now:()=>p,parseDate:()=>u,resetDateConfig:()=>st,startOf:()=>h,startOfDay:()=>y,startOfMonth:()=>St,startOfWeek:()=>Et,startOfYear:()=>It,subtract:()=>$,subtractDays:()=>J,subtractMonths:()=>bt,subtractYears:()=>pt,today:()=>I,tomorrow:()=>lt,validateDate:()=>qt,yearsBetween:()=>Ct,yesterday:()=>dt});module.exports=at(ae);var Y=1e3,k=60,x=60,O=24,b=7;var P=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],z=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],W=["January","February","March","April","May","June","July","August","September","October","November","December"],L=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],q={defaultTimezone:"UTC",defaultLocale:"en-US",weekStartsOn:0,businessDays:{businessDays:[1,2,3,4,5],holidays:[],holidayCheck:()=>!1,workStartHour:9,workEndHour:17}},D={...q};function ot(t){D={...D,...t,businessDays:{...D.businessDays,...t.businessDays||{}}}}function st(){D={...q}}function u(t,e={}){let{format:n="ISO",customFormat:r="",timezone:a=D.defaultTimezone,strict:o=!0,locale:s=D.defaultLocale}=e;if(t instanceof Date&&f(t))return t;let i=null;if(typeof t=="number"){if(i=new Date(t),!f(i))throw new Error(`Invalid timestamp: ${t}`);return _(i,a)}if(typeof t!="string")throw new Error(`Invalid input type: ${typeof t}`);let c=t.trim();if(!c)throw new Error("Empty date string");try{switch(n){case"ISO":case"ISO_DATE":case"ISO_TIME":i=it(c,n);break;case"US":i=ut(c);break;case"EU":i=ct(c);break;case"CUSTOM":i=mt(c,r);break;case"RFC_2822":i=ft(c);break;case"TIMESTAMP":i=Dt(c);break;default:i=gt(c,s,o)}if(!i||!f(i)){if(o)throw new Error(`Parsing resulted in invalid date from input: "${c}"`);if(i=new Date(c),!f(i))throw new Error(`Invalid date format: ${c}`)}if(a&&a!=="UTC"&&(i=U(i,a)),!i)throw new Error(`Invalid date format: ${c}`);return i}catch(l){if(o)throw new Error(`Failed to parse date "${c}" with format ${n}: ${l instanceof Error?l.message:String(l)}`);let m=new Date(c);if(f(m)){let d=_(m,a);if(!d)throw new Error(`Invalid date format: ${c}`);return d}throw new Error(`Invalid date format: ${c}`)}}function it(t,e){try{if(e==="ISO_DATE"){let r=t.split("-").map(i=>parseInt(i,10));if(r.length<3||r.some(isNaN))throw new Error("Invalid ISO date format");let[a,o,s]=r;return new Date(Date.UTC(a,o-1,s))}if(e==="ISO_TIME"){let a=new Date().toISOString().split("T")[0];return new Date(`${a}T${t}Z`)}let n=new Date(t);if(!f(n))throw new Error("Invalid ISO date");return n}catch{throw new Error(`Invalid ISO ${e} format: ${t}`)}}function ut(t){try{let e=t.split("/");if(e.length!==3)throw new Error("Invalid US date format - expected MM/DD/YYYY");let n=parseInt(e[0],10)-1,r=parseInt(e[1],10),a=parseInt(e[2],10);if(isNaN(n)||isNaN(r)||isNaN(a))throw new Error("Invalid US date format - non-numeric parts");if(a<100){let s=new Date().getFullYear(),i=Math.floor(s/100)*100;a+=a<50?i:i-100}if(n<0||n>11)throw new Error(`Month must be between 1 and 12, got ${n+1}`);let o=new Date(a,n,r);if(!f(o))throw new Error("Invalid date");if(o.getFullYear()!==a||o.getMonth()!==n||o.getDate()!==r)throw new Error("Invalid date");return o}catch(e){throw new Error(`Invalid US date format: ${t} - ${e instanceof Error?e.message:String(e)}`)}}function ct(t){try{let e=t.split("/");if(e.length!==3)throw new Error("Invalid EU date format - expected DD/MM/YYYY");let n=parseInt(e[0],10),r=parseInt(e[1],10)-1,a=parseInt(e[2],10);if(isNaN(n)||isNaN(r)||isNaN(a))throw new Error("Invalid EU date format - non-numeric parts");if(a<100){let s=new Date().getFullYear(),i=Math.floor(s/100)*100;a+=a<50?i:i-100}if(r<0||r>11)throw new Error(`Month must be between 1 and 12, got ${r+1}`);let o=new Date(a,r,n);if(!f(o))throw new Error("Invalid date");if(o.getFullYear()!==a||o.getMonth()!==r||o.getDate()!==n)throw new Error("Invalid date");return o}catch(e){throw new Error(`Invalid EU date format: ${t} - ${e instanceof Error?e.message:String(e)}`)}}function mt(t,e){try{if(!e)throw new Error("Custom format string is required");let n=e.replace(/YYYY/g,"(\\d{4})").replace(/YY/g,"(\\d{2})").replace(/MM/g,"(\\d{2})").replace(/M/g,"(\\d{1,2})").replace(/DD/g,"(\\d{2})").replace(/D/g,"(\\d{1,2})").replace(/HH/g,"(\\d{2})").replace(/H/g,"(\\d{1,2})").replace(/hh/g,"(\\d{2})").replace(/h/g,"(\\d{1,2})").replace(/mm/g,"(\\d{2})").replace(/m/g,"(\\d{1,2})").replace(/ss/g,"(\\d{2})").replace(/s/g,"(\\d{1,2})"),r=new RegExp(`^${n}$`),a=t.match(r);if(!a)throw new Error(`Input does not match custom format: ${e}`);let o=0,s=0,i=1,c=0,l=0,m=0,d=1,G=e.match(/YYYY|YY|MM|M|DD|D|HH|H|hh|h|mm|m|ss|s/g)||[];for(let v of G){let g=parseInt(a[d],10);if(isNaN(g))throw new Error(`Invalid numeric value for token ${v}`);switch(v){case"YYYY":o=g;break;case"YY":if(o=g,o<100){let Q=new Date().getFullYear(),C=Math.floor(Q/100)*100;o+=o<50?C:C-100}break;case"MM":case"M":s=g-1;break;case"DD":case"D":i=g;break;case"HH":case"H":c=g;break;case"hh":case"h":c=g;break;case"mm":case"m":l=g;break;case"ss":case"s":m=g;break}d++}if(o<1e3||o>9999)throw new Error(`Year must be between 1000 and 9999: ${o}`);if(s<0||s>11)throw new Error(`Month must be between 1 and 12: ${s+1}`);let w=new Date(o,s,i,c,l,m);if(!f(w))throw new Error("Invalid date");if(w.getFullYear()!==o||w.getMonth()!==s||w.getDate()!==i)throw new Error("Invalid date");return w}catch(n){throw new Error(`Failed to parse with custom format "${e}": ${n instanceof Error?n.message:String(n)}`)}}function ft(t){try{let e=new Date(t);if(!f(e))throw new Error("Invalid RFC 2822 date");return e}catch{throw new Error(`Invalid RFC 2822 date format: ${t}`)}}function Dt(t){try{if(!/^\d{8}(\d{6})?$/.test(t))throw new Error("Invalid timestamp format - expected YYYYMMDD or YYYYMMDDHHMMSS");let e=parseInt(t.substring(0,4),10),n=parseInt(t.substring(4,6),10)-1,r=parseInt(t.substring(6,8),10),a=0,o=0,s=0;if(t.length===14&&(a=parseInt(t.substring(8,10),10),o=parseInt(t.substring(10,12),10),s=parseInt(t.substring(12,14),10)),n<0||n>11)throw new Error(`Month must be between 1 and 12: ${n+1}`);let i=new Date(e,n,r,a,o,s);if(!f(i))throw new Error("Invalid timestamp");return i}catch(e){throw new Error(`Invalid timestamp format: ${t} - ${e instanceof Error?e.message:String(e)}`)}}function gt(t,e,n){try{let r=new Date(t);if(f(r))return r;let a=new Intl.DateTimeFormat(e,{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}),o=new Date(t);if(f(o))return o;if(n)throw new Error(`Could not parse date with locale ${e}`);return new Date(NaN)}catch(r){if(n)throw new Error(`Failed to parse locale date: ${r instanceof Error?r.message:String(r)}`);return new Date(NaN)}}function _(t,e){return t}function f(t){if(!t||typeof t!="object")return!1;let e=t;if(typeof e.getTime!="function"||typeof e.getFullYear!="function")return!1;let n=e.getTime();return!isNaN(n)&&typeof n=="number"&&isFinite(n)}function T(t,e={}){let n=u(t),{format:r="ISO",customFormat:a="",timezone:o=D.defaultTimezone,locale:s=D.defaultLocale,includeTime:i=!0,includeSeconds:c=!1,includeMilliseconds:l=!1}=e,m=n;switch(o&&o!=="UTC"&&(m=U(n,o)),r){case"ISO":return m.toISOString();case"ISO_DATE":return m.toISOString().split("T")[0];case"ISO_TIME":{let d=m.toISOString().split("T")[1];return l?d:d.split(".")[0]}case"US":return Jt(m);case"EU":return Vt(m);case"FULL":return Zt(m,s);case"LONG":return jt(m,s);case"MEDIUM":return A(m,s);case"SHORT":return Kt(m,s);case"TIME":return R(m,s,c);case"TIME_24":return Gt(m,c);case"DATETIME":return`${A(m,s)}, ${R(m,s,c)}`;case"TIMESTAMP":return Qt(m);case"RFC_2822":return Xt(m);case"CUSTOM":return te(m,a);default:return m.toISOString()}}function p(){return new Date}function I(){return y(new Date)}function lt(){return F(I(),1)}function dt(){return J(I(),1)}function B(t,e,n,r=0,a=0,o=0,s=0){return ee(t,e,n,r,a,o,s),new Date(t,e,n,r,a,o,s)}function M(t,e,n="day"){let r=u(t),a=new Date(r);switch(n){case"millisecond":a.setMilliseconds(a.getMilliseconds()+e);break;case"second":a.setSeconds(a.getSeconds()+e);break;case"minute":a.setMinutes(a.getMinutes()+e);break;case"hour":a.setHours(a.getHours()+e);break;case"day":a.setDate(a.getDate()+e);break;case"week":a.setDate(a.getDate()+e*b);break;case"month":a.setMonth(a.getMonth()+e);break;case"quarter":a.setMonth(a.getMonth()+e*3);break;case"year":a.setFullYear(a.getFullYear()+e);break;default:throw new Error(`Unsupported date unit: ${n}`)}return a}function $(t,e,n="day"){return M(t,-e,n)}function F(t,e){return M(t,e,"day")}function J(t,e){return $(t,e,"day")}function ht(t,e){return M(t,e,"month")}function bt(t,e){return $(t,e,"month")}function wt(t,e){return M(t,e,"year")}function pt(t,e){return $(t,e,"year")}function h(t,e){let n=u(t),r=new Date(n);switch(e){case"year":r.setMonth(0,1),r.setHours(0,0,0,0);break;case"month":r.setDate(1),r.setHours(0,0,0,0);break;case"day":r.setHours(0,0,0,0);break;case"hour":r.setMinutes(0,0,0);break;case"minute":r.setSeconds(0,0);break;case"second":r.setMilliseconds(0);break;case"week":{let o=(r.getDay()-D.weekStartsOn+b)%b;r.setDate(r.getDate()-o),r.setHours(0,0,0,0);break}case"quarter":{let a=Math.floor(r.getMonth()/3);r.setMonth(a*3,1),r.setHours(0,0,0,0);break}default:throw new Error(`Unsupported unit for startOf: ${e}`)}return r}function S(t,e){let n=h(t,e),r=new Date(n);switch(e){case"year":r.setFullYear(r.getFullYear()+1);break;case"quarter":r.setMonth(r.getMonth()+3);break;case"month":r.setMonth(r.getMonth()+1);break;case"week":r.setDate(r.getDate()+b);break;case"day":r.setDate(r.getDate()+1);break;case"hour":r.setHours(r.getHours()+1);break;case"minute":r.setMinutes(r.getMinutes()+1);break;case"second":r.setSeconds(r.getSeconds()+1);break;default:throw new Error(`Unsupported unit for endOf: ${e}`)}return r.setMilliseconds(r.getMilliseconds()-1),r}function y(t){return h(t,"day")}function Mt(t){return S(t,"day")}function St(t){return h(t,"month")}function yt(t){return S(t,"month")}function It(t){return h(t,"year")}function $t(t){return S(t,"year")}function Et(t){return h(t,"week")}function Tt(t){return S(t,"week")}function Yt(t,e,n,r=!0){let a=u(t),o=u(e),s=u(n);return r?a>=o&&a<=s:a>o&&a<s}function kt(t,e){return u(t)<u(e)}function xt(t,e){return u(t)>u(e)}function N(t,e,n){let r=u(t),a=u(e);if(!n)return r.getTime()===a.getTime();let o=h(r,n),s=h(a,n);return o.getTime()===s.getTime()}function Ot(t){return N(t,I(),"day")}function V(t){return u(t)<p()}function Z(t){return u(t)>p()}function j(t,e){let n=u(t),r=u(e),a=Math.abs(r.getTime()-n.getTime()),o=Math.floor(a/Y),s=Math.floor(o/k),i=Math.floor(s/x),c=Math.floor(i/O);return{years:Math.floor(c/365),months:Math.floor(c/30),weeks:Math.floor(c/b),days:c,hours:i,minutes:s,seconds:o,milliseconds:a,totalDays:c,totalHours:i,totalMinutes:s,totalSeconds:o,totalMilliseconds:a}}function Ft(t,e=p(),n=!1){let r=j(t,e),o=u(t)<u(e)?"ago":"in";return r.years>0?n?`${r.years} year${r.years===1?"":"s"} ${o}`:`${r.years}y ${o}`:r.months>0?n?`${r.months} month${r.months===1?"":"s"} ${o}`:`${r.months}mo ${o}`:r.weeks>0?n?`${r.weeks} week${r.weeks===1?"":"s"} ${o}`:`${r.weeks}w ${o}`:r.days>0?n?`${r.days} day${r.days===1?"":"s"} ${o}`:`${r.days}d ${o}`:r.hours>0?n?`${r.hours} hour${r.hours===1?"":"s"} ${o}`:`${r.hours}h ${o}`:r.minutes>0?n?`${r.minutes} minute${r.minutes===1?"":"s"} ${o}`:`${r.minutes}m ${o}`:n?`${r.seconds} second${r.seconds===1?"":"s"} ${o}`:`${r.seconds}s ${o}`}function H(t){let n=u(t).getDay();return n===0||n===6}function Nt(t){return!H(t)}function K(t){let e=u(t);return H(e)||!D.businessDays.businessDays.includes(e.getDay())?!1:!(D.businessDays.holidays?.some(r=>N(r,e,"day"))||D.businessDays.holidayCheck?.(e))}function Ht(t,e){let n=u(t),r=0,a=e>0?1:-1;for(;r<Math.abs(e);)n=F(n,a),K(n)&&r++;return n}function Ut(t,e,n=!1){let r=y(u(t)),a=y(u(e)),o=Math.abs(a.getTime()-r.getTime()),s=Math.floor(o/(Y*k*x*O));return n?s+1:s}function vt(t,e){let n=u(t),r=u(e),a=r.getFullYear()-n.getFullYear(),o=r.getMonth()-n.getMonth();return a*12+o}function Ct(t,e){let n=u(t);return u(e).getFullYear()-n.getFullYear()}function _t(t,e=p()){let n=u(t),r=u(e),a=r.getFullYear()-n.getFullYear(),o=r.getMonth()-n.getMonth();return(o<0||o===0&&r.getDate()<n.getDate())&&a--,Math.max(0,a)}function At(t){let e=u(t),n=new Date(e.getFullYear(),0,1),r=(e.getTime()-n.getTime())/(Y*k*x*O);return Math.ceil((r+n.getDay()+1)/b)}function Rt(t){let e=u(t).getMonth();return Math.floor(e/3)+1}function Pt(t,e="full"){let r=u(t).getDay();return e==="full"?P[r]:z[r]}function zt(t,e="full"){let r=u(t).getMonth();return e==="full"?W[r]:L[r]}function Wt(t){let e=u(t);return new Date(e.getFullYear(),e.getMonth()+1,0).getDate()}function Lt(t){return t%4===0&&t%100!==0||t%400===0}function qt(t,e={}){let n=[];try{let r=u(t);if(e.required&&!r&&n.push("Date is required"),e.min||e.minDate){let a=u(e.min||e.minDate);r<a&&n.push(`Date must be on or after ${T(a,{format:"MEDIUM"})}`)}if(e.max||e.maxDate){let a=u(e.max||e.maxDate);r>a&&n.push(`Date must be on or before ${T(a,{format:"MEDIUM"})}`)}e.allowPast===!1&&V(r)&&n.push("Date must be in the future"),e.allowFuture===!1&&Z(r)&&n.push("Date must be in the past")}catch(r){n.push(r instanceof Error?r.message:"Invalid date")}return{isValid:n.length===0,errors:n}}function Bt(t){let e=u(t),n=Intl.DateTimeFormat().resolvedOptions().timeZone,r=-e.getTimezoneOffset(),a=Math.floor(Math.abs(r)/60),o=Math.abs(r)%60,s=r>=0?"+":"-";return{abbreviation:re(e),name:n,offset:r,offsetString:`UTC${s}${String(a).padStart(2,"0")}:${String(o).padStart(2,"0")}`,isDST:ne(e)}}function U(t,e){let n=u(t);if(e==="UTC")return new Date(n.getTime()+n.getTimezoneOffset()*6e4);let a=new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}).formatToParts(n),o=s=>a.find(i=>i.type===s)?.value;return B(parseInt(o("year")),parseInt(o("month"))-1,parseInt(o("day")),parseInt(o("hour")),parseInt(o("minute")),parseInt(o("second")))}function Jt(t){let e=(t.getMonth()+1).toString().padStart(2,"0"),n=t.getDate().toString().padStart(2,"0"),r=t.getFullYear();return`${e}/${n}/${r}`}function Vt(t){let e=t.getDate().toString().padStart(2,"0"),n=(t.getMonth()+1).toString().padStart(2,"0"),r=t.getFullYear();return`${e}/${n}/${r}`}function Zt(t,e){return new Intl.DateTimeFormat(e,{weekday:"long",year:"numeric",month:"long",day:"numeric"}).format(t)}function jt(t,e){return new Intl.DateTimeFormat(e,{year:"numeric",month:"long",day:"numeric"}).format(t)}function A(t,e){return new Intl.DateTimeFormat(e,{year:"numeric",month:"short",day:"numeric"}).format(t)}function Kt(t,e){return new Intl.DateTimeFormat(e,{year:"2-digit",month:"numeric",day:"numeric"}).format(t)}function R(t,e,n){return new Intl.DateTimeFormat(e,{hour:"numeric",minute:"2-digit",second:n?"2-digit":void 0,hour12:!0}).format(t)}function Gt(t,e){let n=t.getHours().toString().padStart(2,"0"),r=t.getMinutes().toString().padStart(2,"0"),a=e?`:${t.getSeconds().toString().padStart(2,"0")}`:"";return`${n}:${r}${a}`}function Qt(t){let e=t.getFullYear(),n=(t.getMonth()+1).toString().padStart(2,"0"),r=t.getDate().toString().padStart(2,"0"),a=t.getHours().toString().padStart(2,"0"),o=t.getMinutes().toString().padStart(2,"0"),s=t.getSeconds().toString().padStart(2,"0");return`${e}${n}${r}${a}${o}${s}`}function Xt(t){return t.toUTCString()}function te(t,e){let n={YYYY:t.getFullYear().toString(),YY:t.getFullYear().toString().slice(-2),MMMM:W[t.getMonth()],MMM:L[t.getMonth()],MM:(t.getMonth()+1).toString().padStart(2,"0"),M:(t.getMonth()+1).toString(),DDDD:P[t.getDay()],DDD:z[t.getDay()],DD:t.getDate().toString().padStart(2,"0"),D:t.getDate().toString(),HH:t.getHours().toString().padStart(2,"0"),H:t.getHours().toString(),hh:(t.getHours()%12||12).toString().padStart(2,"0"),h:(t.getHours()%12||12).toString(),mm:t.getMinutes().toString().padStart(2,"0"),m:t.getMinutes().toString(),ss:t.getSeconds().toString().padStart(2,"0"),s:t.getSeconds().toString(),SSS:t.getMilliseconds().toString().padStart(3,"0"),A:t.getHours()<12?"AM":"PM",a:t.getHours()<12?"am":"pm"};return e.replace(/YYYY|YY|MMMM|MMM|MM|M|DDDD|DDD|DD|D|HH|H|hh|h|mm|m|ss|s|SSS|A|a/g,r=>n[r]||r)}function ee(t,e,n,r=0,a=0,o=0,s=0){if(t<1e3||t>9999)throw new Error(`Year must be between 1000 and 9999: ${t}`);if(e<0||e>11)throw new Error(`Month must be between 0 and 11: ${e}`);let i=new Date(t,e+1,0).getDate();if(n<1||n>i)throw new Error(`Day must be between 1 and ${i} for month ${e}: ${n}`);if(r<0||r>23)throw new Error(`Hour must be between 0 and 23: ${r}`);if(a<0||a>59)throw new Error(`Minute must be between 0 and 59: ${a}`);if(o<0||o>59)throw new Error(`Second must be between 0 and 59: ${o}`);if(s<0||s>999)throw new Error(`Millisecond must be between 0 and 999: ${s}`)}function re(t){let r=new Intl.DateTimeFormat("en-US",{timeZoneName:"short"}).formatToParts(t).find(a=>a.type==="timeZoneName");return r?r.value:"UTC"}function ne(t){let e=new Date(t.getFullYear(),0,1),n=new Date(t.getFullYear(),6,1),r=Math.max(e.getTimezoneOffset(),n.getTimezoneOffset());return t.getTimezoneOffset()<r}
|
|
@@ -0,0 +1,641 @@
|
|
|
1
|
+
import { DateConfig, FormatOptions, Month, DateUnit, DateDifference, ValidationOptions, ValidationResult, TimezoneInfo, DateParseOptions } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Configure date utility settings globally
|
|
4
|
+
* @function configureDateUtils
|
|
5
|
+
* @param {Partial<DateConfig>} newConfig - New configuration options
|
|
6
|
+
* @returns {void}
|
|
7
|
+
* @example
|
|
8
|
+
* // Configure with French locale and week starting on Monday
|
|
9
|
+
* configureDateUtils({
|
|
10
|
+
* defaultLocale: 'fr-FR',
|
|
11
|
+
* weekStartsOn: 1,
|
|
12
|
+
* });
|
|
13
|
+
*/
|
|
14
|
+
export declare function configureDateUtils(newConfig: Partial<DateConfig>): void;
|
|
15
|
+
/**
|
|
16
|
+
* Reset configuration to defaults
|
|
17
|
+
* @function resetDateConfig
|
|
18
|
+
* @returns {void}
|
|
19
|
+
* @example
|
|
20
|
+
* resetDateConfig(); // Reset all settings to defaults
|
|
21
|
+
*/
|
|
22
|
+
export declare function resetDateConfig(): void;
|
|
23
|
+
/**
|
|
24
|
+
* Parse a date from various input types with flexible formatting options
|
|
25
|
+
* @function parseDate
|
|
26
|
+
* @param {Date | string | number} input - Date to parse (Date object, string, or timestamp)
|
|
27
|
+
* @param {ParseOptions} [options={}] - Parsing options
|
|
28
|
+
* @returns {Date} Parsed Date object
|
|
29
|
+
* @throws {Error} If date cannot be parsed and strict mode is enabled
|
|
30
|
+
* @example
|
|
31
|
+
* // Parse ISO date
|
|
32
|
+
* parseDate('2024-01-15T10:30:00Z');
|
|
33
|
+
*
|
|
34
|
+
* // Parse US date
|
|
35
|
+
* parseDate('01/15/2024', { format: 'US' });
|
|
36
|
+
*
|
|
37
|
+
* // Parse with custom format
|
|
38
|
+
* parseDate('2024-15-01', { format: 'CUSTOM', customFormat: 'YYYY-DD-MM' });
|
|
39
|
+
*/
|
|
40
|
+
export declare function parseDate(input: Date | string | number, options?: DateParseOptions): Date;
|
|
41
|
+
/**
|
|
42
|
+
* Validate if a value is a valid Date object
|
|
43
|
+
* @function isDate
|
|
44
|
+
* @param {unknown} date - Value to validate
|
|
45
|
+
* @returns {date is Date} True if value is a valid Date object
|
|
46
|
+
* @example
|
|
47
|
+
* isDate(new Date()); // true
|
|
48
|
+
* isDate('invalid'); // false
|
|
49
|
+
* isDate(new Date('invalid')); // false
|
|
50
|
+
*/
|
|
51
|
+
export declare function isDate(date: unknown): date is Date;
|
|
52
|
+
/**
|
|
53
|
+
* Format a date to string with various formatting options
|
|
54
|
+
* @function formatDate
|
|
55
|
+
* @param {Date | string | number} date - Date to format
|
|
56
|
+
* @param {FormatOptions} [options={}] - Formatting options
|
|
57
|
+
* @returns {string} Formatted date string
|
|
58
|
+
* @example
|
|
59
|
+
* // Format as ISO
|
|
60
|
+
* formatDate(new Date(), { format: 'ISO' });
|
|
61
|
+
*
|
|
62
|
+
* // Format as US date
|
|
63
|
+
* formatDate('2024-01-15', { format: 'US' });
|
|
64
|
+
*
|
|
65
|
+
* // Format with custom format
|
|
66
|
+
* formatDate(new Date(), { format: 'CUSTOM', customFormat: 'YYYY-MM-DD HH:mm:ss' });
|
|
67
|
+
*/
|
|
68
|
+
export declare function formatDate(date: Date | string | number, options?: FormatOptions): string;
|
|
69
|
+
/**
|
|
70
|
+
* Get current date and time
|
|
71
|
+
* @function now
|
|
72
|
+
* @returns {Date} Current date and time
|
|
73
|
+
* @example
|
|
74
|
+
* const current = now(); // Returns current Date object
|
|
75
|
+
*/
|
|
76
|
+
export declare function now(): Date;
|
|
77
|
+
/**
|
|
78
|
+
* Get today's date at midnight (00:00:00.000)
|
|
79
|
+
* @function today
|
|
80
|
+
* @returns {Date} Today's date at midnight
|
|
81
|
+
* @example
|
|
82
|
+
* const todayDate = today(); // Returns today at midnight
|
|
83
|
+
*/
|
|
84
|
+
export declare function today(): Date;
|
|
85
|
+
/**
|
|
86
|
+
* Get tomorrow's date at midnight
|
|
87
|
+
* @function tomorrow
|
|
88
|
+
* @returns {Date} Tomorrow's date at midnight
|
|
89
|
+
* @example
|
|
90
|
+
* const tomorrowDate = tomorrow(); // Returns tomorrow at midnight
|
|
91
|
+
*/
|
|
92
|
+
export declare function tomorrow(): Date;
|
|
93
|
+
/**
|
|
94
|
+
* Get yesterday's date at midnight
|
|
95
|
+
* @function yesterday
|
|
96
|
+
* @returns {Date} Yesterday's date at midnight
|
|
97
|
+
* @example
|
|
98
|
+
* const yesterdayDate = yesterday(); // Returns yesterday at midnight
|
|
99
|
+
*/
|
|
100
|
+
export declare function yesterday(): Date;
|
|
101
|
+
/**
|
|
102
|
+
* Create a date from individual components
|
|
103
|
+
* @function createDate
|
|
104
|
+
* @param {number} year - Year (e.g., 2024)
|
|
105
|
+
* @param {Month} month - Month (0-11, where 0 = January)
|
|
106
|
+
* @param {number} day - Day of month (1-31)
|
|
107
|
+
* @param {number} [hour=0] - Hour (0-23)
|
|
108
|
+
* @param {number} [minute=0] - Minute (0-59)
|
|
109
|
+
* @param {number} [second=0] - Second (0-59)
|
|
110
|
+
* @param {number} [millisecond=0] - Millisecond (0-999)
|
|
111
|
+
* @returns {Date} Created Date object
|
|
112
|
+
* @throws {Error} If any component is out of valid range
|
|
113
|
+
* @example
|
|
114
|
+
* // Create date for January 15, 2024, 10:30:45
|
|
115
|
+
* createDate(2024, 0, 15, 10, 30, 45);
|
|
116
|
+
*/
|
|
117
|
+
export declare function createDate(year: number, month: Month, day: number, hour?: number, minute?: number, second?: number, millisecond?: number): Date;
|
|
118
|
+
/**
|
|
119
|
+
* Add time to a date
|
|
120
|
+
* @function add
|
|
121
|
+
* @param {Date | string | number} date - Base date
|
|
122
|
+
* @param {number} amount - Amount to add (can be negative to subtract)
|
|
123
|
+
* @param {DateUnit} [unit='day'] - Unit of time to add
|
|
124
|
+
* @returns {Date} New date after addition
|
|
125
|
+
* @example
|
|
126
|
+
* // Add 5 days
|
|
127
|
+
* add(new Date(), 5, 'day');
|
|
128
|
+
*
|
|
129
|
+
* // Add 2 months
|
|
130
|
+
* add('2024-01-15', 2, 'month');
|
|
131
|
+
*
|
|
132
|
+
* // Subtract 3 hours
|
|
133
|
+
* add(new Date(), -3, 'hour');
|
|
134
|
+
*/
|
|
135
|
+
export declare function add(date: Date | string | number, amount: number, unit?: DateUnit): Date;
|
|
136
|
+
/**
|
|
137
|
+
* Subtract time from a date
|
|
138
|
+
* @function subtract
|
|
139
|
+
* @param {Date | string | number} date - Base date
|
|
140
|
+
* @param {number} amount - Amount to subtract (can be negative to add)
|
|
141
|
+
* @param {DateUnit} [unit='day'] - Unit of time to subtract
|
|
142
|
+
* @returns {Date} New date after subtraction
|
|
143
|
+
* @example
|
|
144
|
+
* // Subtract 5 days
|
|
145
|
+
* subtract(new Date(), 5, 'day');
|
|
146
|
+
*
|
|
147
|
+
* // Subtract 2 months
|
|
148
|
+
* subtract('2024-01-15', 2, 'month');
|
|
149
|
+
*/
|
|
150
|
+
export declare function subtract(date: Date | string | number, amount: number, unit?: DateUnit): Date;
|
|
151
|
+
/**
|
|
152
|
+
* Add days to a date
|
|
153
|
+
* @function addDays
|
|
154
|
+
* @param {Date | string | number} date - Base date
|
|
155
|
+
* @param {number} days - Number of days to add (can be negative)
|
|
156
|
+
* @returns {Date} New date after adding days
|
|
157
|
+
* @example
|
|
158
|
+
* // Add 5 days
|
|
159
|
+
* addDays(new Date(), 5);
|
|
160
|
+
*
|
|
161
|
+
* // Subtract 3 days
|
|
162
|
+
* addDays('2024-01-15', -3);
|
|
163
|
+
*/
|
|
164
|
+
export declare function addDays(date: Date | string | number, days: number): Date;
|
|
165
|
+
/**
|
|
166
|
+
* Subtract days from a date
|
|
167
|
+
* @function subtractDays
|
|
168
|
+
* @param {Date | string | number} date - Base date
|
|
169
|
+
* @param {number} days - Number of days to subtract
|
|
170
|
+
* @returns {Date} New date after subtracting days
|
|
171
|
+
* @example
|
|
172
|
+
* // Subtract 5 days
|
|
173
|
+
* subtractDays(new Date(), 5);
|
|
174
|
+
*/
|
|
175
|
+
export declare function subtractDays(date: Date | string | number, days: number): Date;
|
|
176
|
+
/**
|
|
177
|
+
* Add months to a date
|
|
178
|
+
* @function addMonths
|
|
179
|
+
* @param {Date | string | number} date - Base date
|
|
180
|
+
* @param {number} months - Number of months to add (can be negative)
|
|
181
|
+
* @returns {Date} New date after adding months
|
|
182
|
+
* @example
|
|
183
|
+
* // Add 2 months
|
|
184
|
+
* addMonths(new Date(), 2);
|
|
185
|
+
*
|
|
186
|
+
* // Subtract 3 months
|
|
187
|
+
* addMonths('2024-01-15', -3);
|
|
188
|
+
*/
|
|
189
|
+
export declare function addMonths(date: Date | string | number, months: number): Date;
|
|
190
|
+
/**
|
|
191
|
+
* Subtract months from a date
|
|
192
|
+
* @function subtractMonths
|
|
193
|
+
* @param {Date | string | number} date - Base date
|
|
194
|
+
* @param {number} months - Number of months to subtract
|
|
195
|
+
* @returns {Date} New date after subtracting months
|
|
196
|
+
* @example
|
|
197
|
+
* // Subtract 2 months
|
|
198
|
+
* subtractMonths(new Date(), 2);
|
|
199
|
+
*/
|
|
200
|
+
export declare function subtractMonths(date: Date | string | number, months: number): Date;
|
|
201
|
+
/**
|
|
202
|
+
* Add years to a date
|
|
203
|
+
* @function addYears
|
|
204
|
+
* @param {Date | string | number} date - Base date
|
|
205
|
+
* @param {number} years - Number of years to add (can be negative)
|
|
206
|
+
* @returns {Date} New date after adding years
|
|
207
|
+
* @example
|
|
208
|
+
* // Add 1 year
|
|
209
|
+
* addYears(new Date(), 1);
|
|
210
|
+
*
|
|
211
|
+
* // Subtract 5 years
|
|
212
|
+
* addYears('2024-01-15', -5);
|
|
213
|
+
*/
|
|
214
|
+
export declare function addYears(date: Date | string | number, years: number): Date;
|
|
215
|
+
/**
|
|
216
|
+
* Subtract years from a date
|
|
217
|
+
* @function subtractYears
|
|
218
|
+
* @param {Date | string | number} date - Base date
|
|
219
|
+
* @param {number} years - Number of years to subtract
|
|
220
|
+
* @returns {Date} New date after subtracting years
|
|
221
|
+
* @example
|
|
222
|
+
* // Subtract 10 years
|
|
223
|
+
* subtractYears(new Date(), 10);
|
|
224
|
+
*/
|
|
225
|
+
export declare function subtractYears(date: Date | string | number, years: number): Date;
|
|
226
|
+
/**
|
|
227
|
+
* Get the start of a time unit
|
|
228
|
+
* @function startOf
|
|
229
|
+
* @param {Date | string | number} date - Base date
|
|
230
|
+
* @param {DateUnit} unit - Time unit to get start of
|
|
231
|
+
* @returns {Date} Date representing the start of the specified unit
|
|
232
|
+
* @example
|
|
233
|
+
* // Start of month
|
|
234
|
+
* startOf(new Date(), 'month');
|
|
235
|
+
*
|
|
236
|
+
* // Start of year
|
|
237
|
+
* startOf('2024-06-15', 'year');
|
|
238
|
+
*
|
|
239
|
+
* // Start of week (configurable via weekStartsOn)
|
|
240
|
+
* startOf(new Date(), 'week');
|
|
241
|
+
*/
|
|
242
|
+
export declare function startOf(date: Date | string | number, unit: DateUnit): Date;
|
|
243
|
+
/**
|
|
244
|
+
* Get the end of a time unit
|
|
245
|
+
* @function endOf
|
|
246
|
+
* @param {Date | string | number} date - Base date
|
|
247
|
+
* @param {DateUnit} unit - Time unit to get end of
|
|
248
|
+
* @returns {Date} Date representing the end of the specified unit
|
|
249
|
+
* @example
|
|
250
|
+
* // End of month
|
|
251
|
+
* endOf(new Date(), 'month');
|
|
252
|
+
*
|
|
253
|
+
* // End of day (23:59:59.999)
|
|
254
|
+
* endOf('2024-01-15', 'day');
|
|
255
|
+
*/
|
|
256
|
+
export declare function endOf(date: Date | string | number, unit: DateUnit): Date;
|
|
257
|
+
/**
|
|
258
|
+
* Get start of day (midnight)
|
|
259
|
+
* @function startOfDay
|
|
260
|
+
* @param {Date | string | number} date - Base date
|
|
261
|
+
* @returns {Date} Date at 00:00:00.000
|
|
262
|
+
* @example
|
|
263
|
+
* startOfDay(new Date()); // Returns today at midnight
|
|
264
|
+
*/
|
|
265
|
+
export declare function startOfDay(date: Date | string | number): Date;
|
|
266
|
+
/**
|
|
267
|
+
* Get end of day (last millisecond)
|
|
268
|
+
* @function endOfDay
|
|
269
|
+
* @param {Date | string | number} date - Base date
|
|
270
|
+
* @returns {Date} Date at 23:59:59.999
|
|
271
|
+
* @example
|
|
272
|
+
* endOfDay(new Date()); // Returns today at 23:59:59.999
|
|
273
|
+
*/
|
|
274
|
+
export declare function endOfDay(date: Date | string | number): Date;
|
|
275
|
+
/**
|
|
276
|
+
* Get start of month
|
|
277
|
+
* @function startOfMonth
|
|
278
|
+
* @param {Date | string | number} date - Base date
|
|
279
|
+
* @returns {Date} First day of month at 00:00:00.000
|
|
280
|
+
* @example
|
|
281
|
+
* startOfMonth(new Date()); // Returns first day of current month
|
|
282
|
+
*/
|
|
283
|
+
export declare function startOfMonth(date: Date | string | number): Date;
|
|
284
|
+
/**
|
|
285
|
+
* Get end of month
|
|
286
|
+
* @function endOfMonth
|
|
287
|
+
* @param {Date | string | number} date - Base date
|
|
288
|
+
* @returns {Date} Last day of month at 23:59:59.999
|
|
289
|
+
* @example
|
|
290
|
+
* endOfMonth(new Date()); // Returns last day of current month at 23:59:59.999
|
|
291
|
+
*/
|
|
292
|
+
export declare function endOfMonth(date: Date | string | number): Date;
|
|
293
|
+
/**
|
|
294
|
+
* Get start of year
|
|
295
|
+
* @function startOfYear
|
|
296
|
+
* @param {Date | string | number} date - Base date
|
|
297
|
+
* @returns {Date} January 1st at 00:00:00.000
|
|
298
|
+
* @example
|
|
299
|
+
* startOfYear(new Date()); // Returns January 1st of current year
|
|
300
|
+
*/
|
|
301
|
+
export declare function startOfYear(date: Date | string | number): Date;
|
|
302
|
+
/**
|
|
303
|
+
* Get end of year
|
|
304
|
+
* @function endOfYear
|
|
305
|
+
* @param {Date | string | number} date - Base date
|
|
306
|
+
* @returns {Date} December 31st at 23:59:59.999
|
|
307
|
+
* @example
|
|
308
|
+
* endOfYear(new Date()); // Returns December 31st of current year at 23:59:59.999
|
|
309
|
+
*/
|
|
310
|
+
export declare function endOfYear(date: Date | string | number): Date;
|
|
311
|
+
/**
|
|
312
|
+
* Get start of week
|
|
313
|
+
* @function startOfWeek
|
|
314
|
+
* @param {Date | string | number} date - Base date
|
|
315
|
+
* @returns {Date} Start of week (configurable via weekStartsOn) at 00:00:00.000
|
|
316
|
+
* @example
|
|
317
|
+
* // With weekStartsOn = 0 (Sunday)
|
|
318
|
+
* startOfWeek(new Date('2024-01-15')); // Returns Sunday, January 14, 2024
|
|
319
|
+
*/
|
|
320
|
+
export declare function startOfWeek(date: Date | string | number): Date;
|
|
321
|
+
/**
|
|
322
|
+
* Get end of week
|
|
323
|
+
* @function endOfWeek
|
|
324
|
+
* @param {Date | string | number} date - Base date
|
|
325
|
+
* @returns {Date} End of week (configurable via weekStartsOn) at 23:59:59.999
|
|
326
|
+
* @example
|
|
327
|
+
* // With weekStartsOn = 0 (Sunday)
|
|
328
|
+
* endOfWeek(new Date('2024-01-15')); // Returns Saturday, January 20, 2024
|
|
329
|
+
*/
|
|
330
|
+
export declare function endOfWeek(date: Date | string | number): Date;
|
|
331
|
+
/**
|
|
332
|
+
* Check if a date is between two other dates
|
|
333
|
+
* @function isBetween
|
|
334
|
+
* @param {Date | string | number} date - Date to check
|
|
335
|
+
* @param {Date | string | number} start - Start of range
|
|
336
|
+
* @param {Date | string | number} end - End of range
|
|
337
|
+
* @param {boolean} [inclusive=true] - Whether to include boundaries
|
|
338
|
+
* @returns {boolean} True if date is between start and end
|
|
339
|
+
* @example
|
|
340
|
+
* // Check if date is in January 2024
|
|
341
|
+
* isBetween('2024-01-15', '2024-01-01', '2024-01-31');
|
|
342
|
+
*
|
|
343
|
+
* // Exclusive check
|
|
344
|
+
* isBetween('2024-01-01', '2024-01-01', '2024-01-31', false); // false
|
|
345
|
+
*/
|
|
346
|
+
export declare function isBetween(date: Date | string | number, start: Date | string | number, end: Date | string | number, inclusive?: boolean): boolean;
|
|
347
|
+
/**
|
|
348
|
+
* Check if a date is before another date
|
|
349
|
+
* @function isBefore
|
|
350
|
+
* @param {Date | string | number} date - Date to check
|
|
351
|
+
* @param {Date | string | number} compareTo - Date to compare against
|
|
352
|
+
* @returns {boolean} True if date is before compareTo
|
|
353
|
+
* @example
|
|
354
|
+
* isBefore('2024-01-15', '2024-01-20'); // true
|
|
355
|
+
* isBefore('2024-01-20', '2024-01-15'); // false
|
|
356
|
+
*/
|
|
357
|
+
export declare function isBefore(date: Date | string | number, compareTo: Date | string | number): boolean;
|
|
358
|
+
/**
|
|
359
|
+
* Check if a date is after another date
|
|
360
|
+
* @function isAfter
|
|
361
|
+
* @param {Date | string | number} date - Date to check
|
|
362
|
+
* @param {Date | string | number} compareTo - Date to compare against
|
|
363
|
+
* @returns {boolean} True if date is after compareTo
|
|
364
|
+
* @example
|
|
365
|
+
* isAfter('2024-01-20', '2024-01-15'); // true
|
|
366
|
+
* isAfter('2024-01-15', '2024-01-20'); // false
|
|
367
|
+
*/
|
|
368
|
+
export declare function isAfter(date: Date | string | number, compareTo: Date | string | number): boolean;
|
|
369
|
+
/**
|
|
370
|
+
* Check if two dates are the same (optionally by specific unit)
|
|
371
|
+
* @function isSame
|
|
372
|
+
* @param {Date | string | number} date1 - First date
|
|
373
|
+
* @param {Date | string | number} date2 - Second date
|
|
374
|
+
* @param {DateUnit} [unit] - Unit to compare (if not provided, compares exact timestamps)
|
|
375
|
+
* @returns {boolean} True if dates are the same
|
|
376
|
+
* @example
|
|
377
|
+
* // Exact timestamp comparison
|
|
378
|
+
* isSame(new Date('2024-01-15T10:30:00'), new Date('2024-01-15T10:30:00')); // true
|
|
379
|
+
*
|
|
380
|
+
* // Same day comparison
|
|
381
|
+
* isSame('2024-01-15T10:30:00', '2024-01-15T15:45:00', 'day'); // true
|
|
382
|
+
*
|
|
383
|
+
* // Same month comparison
|
|
384
|
+
* isSame('2024-01-15', '2024-01-31', 'month'); // true
|
|
385
|
+
*/
|
|
386
|
+
export declare function isSame(date1: Date | string | number, date2: Date | string | number, unit?: DateUnit): boolean;
|
|
387
|
+
/**
|
|
388
|
+
* Check if a date is today
|
|
389
|
+
* @function isToday
|
|
390
|
+
* @param {Date | string | number} date - Date to check
|
|
391
|
+
* @returns {boolean} True if date is today
|
|
392
|
+
* @example
|
|
393
|
+
* isToday(new Date()); // true
|
|
394
|
+
* isToday('2024-01-15'); // depends on current date
|
|
395
|
+
*/
|
|
396
|
+
export declare function isToday(date: Date | string | number): boolean;
|
|
397
|
+
/**
|
|
398
|
+
* Check if a date is in the past
|
|
399
|
+
* @function isPast
|
|
400
|
+
* @param {Date | string | number} date - Date to check
|
|
401
|
+
* @returns {boolean} True if date is before now
|
|
402
|
+
* @example
|
|
403
|
+
* isPast('2020-01-01'); // true
|
|
404
|
+
* isPast('2030-01-01'); // false
|
|
405
|
+
*/
|
|
406
|
+
export declare function isPast(date: Date | string | number): boolean;
|
|
407
|
+
/**
|
|
408
|
+
* Check if a date is in the future
|
|
409
|
+
* @function isFuture
|
|
410
|
+
* @param {Date | string | number} date - Date to check
|
|
411
|
+
* @returns {boolean} True if date is after now
|
|
412
|
+
* @example
|
|
413
|
+
* isFuture('2030-01-01'); // true
|
|
414
|
+
* isFuture('2020-01-01'); // false
|
|
415
|
+
*/
|
|
416
|
+
export declare function isFuture(date: Date | string | number): boolean;
|
|
417
|
+
/**
|
|
418
|
+
* Calculate the difference between two dates in multiple units
|
|
419
|
+
* @function difference
|
|
420
|
+
* @param {Date | string | number} date1 - First date
|
|
421
|
+
* @param {Date | string | number} date2 - Second date
|
|
422
|
+
* @returns {DateDifference} Object containing differences in various units
|
|
423
|
+
* @example
|
|
424
|
+
* const diff = difference('2024-01-10', '2024-01-15');
|
|
425
|
+
* console.log(diff.days); // 5
|
|
426
|
+
* console.log(diff.totalHours); // 120
|
|
427
|
+
*/
|
|
428
|
+
export declare function difference(date1: Date | string | number, date2: Date | string | number): DateDifference;
|
|
429
|
+
/**
|
|
430
|
+
* Get human-readable description of date difference
|
|
431
|
+
* @function humanizeDifference
|
|
432
|
+
* @param {Date | string | number} date1 - First date
|
|
433
|
+
* @param {Date | string | number} [date2=now()] - Second date (defaults to now)
|
|
434
|
+
* @param {boolean} [detailed=false] - Whether to use detailed descriptions
|
|
435
|
+
* @returns {string} Human-readable difference
|
|
436
|
+
* @example
|
|
437
|
+
* // Returns something like "2 days ago" or "in 3 hours"
|
|
438
|
+
* humanizeDifference('2024-01-13');
|
|
439
|
+
*
|
|
440
|
+
* // Detailed format
|
|
441
|
+
* humanizeDifference('2024-01-13', new Date(), true); // "2 days ago"
|
|
442
|
+
*/
|
|
443
|
+
export declare function humanizeDifference(date1: Date | string | number, date2?: Date | string | number, detailed?: boolean): string;
|
|
444
|
+
/**
|
|
445
|
+
* Check if a date falls on a weekend
|
|
446
|
+
* @function isWeekend
|
|
447
|
+
* @param {Date | string | number} date - Date to check
|
|
448
|
+
* @returns {boolean} True if date is Saturday or Sunday
|
|
449
|
+
* @example
|
|
450
|
+
* isWeekend('2024-01-15'); // false (Monday)
|
|
451
|
+
* isWeekend('2024-01-20'); // true (Saturday)
|
|
452
|
+
*/
|
|
453
|
+
export declare function isWeekend(date: Date | string | number): boolean;
|
|
454
|
+
/**
|
|
455
|
+
* Check if a date falls on a weekday
|
|
456
|
+
* @function isWeekday
|
|
457
|
+
* @param {Date | string | number} date - Date to check
|
|
458
|
+
* @returns {boolean} True if date is Monday through Friday
|
|
459
|
+
* @example
|
|
460
|
+
* isWeekday('2024-01-15'); // true (Monday)
|
|
461
|
+
* isWeekday('2024-01-20'); // false (Saturday)
|
|
462
|
+
*/
|
|
463
|
+
export declare function isWeekday(date: Date | string | number): boolean;
|
|
464
|
+
/**
|
|
465
|
+
* Check if a date is a business day (considering weekends and holidays)
|
|
466
|
+
* @function isBusinessDay
|
|
467
|
+
* @param {Date | string | number} date - Date to check
|
|
468
|
+
* @returns {boolean} True if date is a business day
|
|
469
|
+
* @example
|
|
470
|
+
* // Assuming Monday-Friday are business days
|
|
471
|
+
* isBusinessDay('2024-01-15'); // true (Monday)
|
|
472
|
+
* isBusinessDay('2024-01-20'); // false (Saturday)
|
|
473
|
+
*/
|
|
474
|
+
export declare function isBusinessDay(date: Date | string | number): boolean;
|
|
475
|
+
/**
|
|
476
|
+
* Add business days to a date (skips weekends and holidays)
|
|
477
|
+
* @function addBusinessDays
|
|
478
|
+
* @param {Date | string | number} date - Base date
|
|
479
|
+
* @param {number} days - Number of business days to add (can be negative)
|
|
480
|
+
* @returns {Date} New date after adding business days
|
|
481
|
+
* @example
|
|
482
|
+
* // Add 3 business days to Friday
|
|
483
|
+
* addBusinessDays('2024-01-12', 3); // Returns Wednesday, January 17
|
|
484
|
+
*/
|
|
485
|
+
export declare function addBusinessDays(date: Date | string | number, days: number): Date;
|
|
486
|
+
/**
|
|
487
|
+
* Calculate number of days between two dates
|
|
488
|
+
* @function daysBetween
|
|
489
|
+
* @param {Date | string | number} start - Start date
|
|
490
|
+
* @param {Date | string | number} end - End date
|
|
491
|
+
* @param {boolean} [inclusive=false] - Whether to include both start and end dates
|
|
492
|
+
* @returns {number} Number of days between dates
|
|
493
|
+
* @example
|
|
494
|
+
* daysBetween('2024-01-10', '2024-01-15'); // 5
|
|
495
|
+
* daysBetween('2024-01-10', '2024-01-15', true); // 6
|
|
496
|
+
*/
|
|
497
|
+
export declare function daysBetween(start: Date | string | number, end: Date | string | number, inclusive?: boolean): number;
|
|
498
|
+
/**
|
|
499
|
+
* Calculate number of months between two dates
|
|
500
|
+
* @function monthsBetween
|
|
501
|
+
* @param {Date | string | number} start - Start date
|
|
502
|
+
* @param {Date | string | number} end - End date
|
|
503
|
+
* @returns {number} Number of months between dates
|
|
504
|
+
* @example
|
|
505
|
+
* monthsBetween('2024-01-15', '2024-03-15'); // 2
|
|
506
|
+
* monthsBetween('2024-01-31', '2024-02-28'); // 1
|
|
507
|
+
*/
|
|
508
|
+
export declare function monthsBetween(start: Date | string | number, end: Date | string | number): number;
|
|
509
|
+
/**
|
|
510
|
+
* Calculate number of years between two dates
|
|
511
|
+
* @function yearsBetween
|
|
512
|
+
* @param {Date | string | number} start - Start date
|
|
513
|
+
* @param {Date | string | number} end - End date
|
|
514
|
+
* @returns {number} Number of years between dates
|
|
515
|
+
* @example
|
|
516
|
+
* yearsBetween('2020-06-15', '2024-01-15'); // 4
|
|
517
|
+
*/
|
|
518
|
+
export declare function yearsBetween(start: Date | string | number, end: Date | string | number): number;
|
|
519
|
+
/**
|
|
520
|
+
* Calculate age from birth date
|
|
521
|
+
* @function getAge
|
|
522
|
+
* @param {Date | string | number} birthDate - Birth date
|
|
523
|
+
* @param {Date | string | number} [asOfDate=now()] - Date to calculate age as of
|
|
524
|
+
* @returns {number} Age in years
|
|
525
|
+
* @example
|
|
526
|
+
* getAge('1990-06-15', '2024-01-15'); // 33
|
|
527
|
+
* getAge('2000-02-29', '2024-02-28'); // 23
|
|
528
|
+
* getAge('2000-02-29', '2024-02-29'); // 24
|
|
529
|
+
*/
|
|
530
|
+
export declare function getAge(birthDate: Date | string | number, asOfDate?: Date | string | number): number;
|
|
531
|
+
/**
|
|
532
|
+
* Get ISO week number of year
|
|
533
|
+
* @function getWeekNumber
|
|
534
|
+
* @param {Date | string | number} date - Date to check
|
|
535
|
+
* @returns {number} Week number (1-53)
|
|
536
|
+
* @example
|
|
537
|
+
* getWeekNumber('2024-01-01'); // 1
|
|
538
|
+
* getWeekNumber('2024-01-15'); // 3
|
|
539
|
+
*/
|
|
540
|
+
export declare function getWeekNumber(date: Date | string | number): number;
|
|
541
|
+
/**
|
|
542
|
+
* Get quarter of year
|
|
543
|
+
* @function getQuarter
|
|
544
|
+
* @param {Date | string | number} date - Date to check
|
|
545
|
+
* @returns {number} Quarter number (1-4)
|
|
546
|
+
* @example
|
|
547
|
+
* getQuarter('2024-01-15'); // 1
|
|
548
|
+
* getQuarter('2024-04-15'); // 2
|
|
549
|
+
* getQuarter('2024-07-15'); // 3
|
|
550
|
+
* getQuarter('2024-10-15'); // 4
|
|
551
|
+
*/
|
|
552
|
+
export declare function getQuarter(date: Date | string | number): number;
|
|
553
|
+
/**
|
|
554
|
+
* Get day name
|
|
555
|
+
* @function getDayName
|
|
556
|
+
* @param {Date | string | number} date - Date to check
|
|
557
|
+
* @param {'full' | 'short'} [format='full'] - Format of day name
|
|
558
|
+
* @returns {string} Day name
|
|
559
|
+
* @example
|
|
560
|
+
* getDayName('2024-01-15'); // "Monday"
|
|
561
|
+
* getDayName('2024-01-15', 'short'); // "Mon"
|
|
562
|
+
*/
|
|
563
|
+
export declare function getDayName(date: Date | string | number, format?: 'full' | 'short'): string;
|
|
564
|
+
/**
|
|
565
|
+
* Get month name
|
|
566
|
+
* @function getMonthName
|
|
567
|
+
* @param {Date | string | number} date - Date to check
|
|
568
|
+
* @param {'full' | 'short'} [format='full'] - Format of month name
|
|
569
|
+
* @returns {string} Month name
|
|
570
|
+
* @example
|
|
571
|
+
* getMonthName('2024-01-15'); // "January"
|
|
572
|
+
* getMonthName('2024-01-15', 'short'); // "Jan"
|
|
573
|
+
*/
|
|
574
|
+
export declare function getMonthName(date: Date | string | number, format?: 'full' | 'short'): string;
|
|
575
|
+
/**
|
|
576
|
+
* Get number of days in month
|
|
577
|
+
* @function getDaysInMonth
|
|
578
|
+
* @param {Date | string | number} date - Date to check
|
|
579
|
+
* @returns {number} Number of days in month
|
|
580
|
+
* @example
|
|
581
|
+
* getDaysInMonth('2024-01-15'); // 31
|
|
582
|
+
* getDaysInMonth('2024-02-15'); // 29 (leap year)
|
|
583
|
+
* getDaysInMonth('2023-02-15'); // 28
|
|
584
|
+
*/
|
|
585
|
+
export declare function getDaysInMonth(date: Date | string | number): number;
|
|
586
|
+
/**
|
|
587
|
+
* Check if year is a leap year
|
|
588
|
+
* @function isLeapYear
|
|
589
|
+
* @param {number} year - Year to check
|
|
590
|
+
* @returns {boolean} True if year is a leap year
|
|
591
|
+
* @example
|
|
592
|
+
* isLeapYear(2024); // true
|
|
593
|
+
* isLeapYear(2023); // false
|
|
594
|
+
* isLeapYear(2000); // true (century divisible by 400)
|
|
595
|
+
* isLeapYear(1900); // false (century not divisible by 400)
|
|
596
|
+
*/
|
|
597
|
+
export declare function isLeapYear(year: number): boolean;
|
|
598
|
+
/**
|
|
599
|
+
* Validate a date with constraints
|
|
600
|
+
* @function validateDate
|
|
601
|
+
* @param {Date | string | number} date - Date to validate
|
|
602
|
+
* @param {ValidationOptions} [options={}] - Validation options
|
|
603
|
+
* @returns {ValidationResult} Validation result with errors if any
|
|
604
|
+
* @example
|
|
605
|
+
* // Simple validation
|
|
606
|
+
* validateDate('2024-01-15');
|
|
607
|
+
*
|
|
608
|
+
* // With constraints
|
|
609
|
+
* validateDate('2024-01-15', {
|
|
610
|
+
* min: '2024-01-01',
|
|
611
|
+
* max: '2024-12-31',
|
|
612
|
+
* allowPast: false,
|
|
613
|
+
* });
|
|
614
|
+
*/
|
|
615
|
+
export declare function validateDate(date: Date | string | number, options?: ValidationOptions): ValidationResult;
|
|
616
|
+
/**
|
|
617
|
+
* Get timezone information for a date
|
|
618
|
+
* @function getTimezoneInfo
|
|
619
|
+
* @param {Date | string | number} date - Date to get timezone info for
|
|
620
|
+
* @returns {TimezoneInfo} Timezone information
|
|
621
|
+
* @example
|
|
622
|
+
* const info = getTimezoneInfo(new Date());
|
|
623
|
+
* console.log(info.name); // "America/New_York"
|
|
624
|
+
* console.log(info.offsetString); // "UTC-05:00"
|
|
625
|
+
*/
|
|
626
|
+
export declare function getTimezoneInfo(date: Date | string | number): TimezoneInfo;
|
|
627
|
+
/**
|
|
628
|
+
* Convert date to another timezone
|
|
629
|
+
* @function convertTimezone
|
|
630
|
+
* @param {Date | string | number} date - Date to convert
|
|
631
|
+
* @param {string} targetTimezone - Target timezone (e.g., 'America/New_York', 'UTC')
|
|
632
|
+
* @returns {Date} Date converted to target timezone
|
|
633
|
+
* @example
|
|
634
|
+
* // Convert to UTC
|
|
635
|
+
* convertTimezone(new Date(), 'UTC');
|
|
636
|
+
*
|
|
637
|
+
* // Convert to New York time
|
|
638
|
+
* convertTimezone('2024-01-15T10:30:00Z', 'America/New_York');
|
|
639
|
+
*/
|
|
640
|
+
export declare function convertTimezone(date: Date | string | number, targetTimezone: string): Date;
|
|
641
|
+
//# sourceMappingURL=date.d.ts.map
|