Socket
Socket
Sign inDemoInstall

@drivekyte/date-utils

Package Overview
Dependencies
3
Maintainers
4
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 2.0.0

dist/lib/use-date-formatter.test.js

819

dist/date-utils.es5.js

@@ -1,2 +0,819 @@

"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var t={exports:{}},e=t.exports=function(){var t=1e3,e=6e4,n=36e5,i="millisecond",r="second",s="minute",u="hour",a="day",o="week",f="month",h="quarter",c="year",d="date",l="Invalid Date",$=/^(\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,D={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("_")},g=function(t,e,n){var i=String(t);return!i||i.length>=e?t:""+Array(e+1-i.length).join(n)+t},v={s:g,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),i=Math.floor(n/60),r=n%60;return(e<=0?"+":"-")+g(i,2,"0")+":"+g(r,2,"0")},m:function t(e,n){if(e.date()<n.date())return-t(n,e);var i=12*(n.year()-e.year())+(n.month()-e.month()),r=e.clone().add(i,f),s=n-r<0,u=e.clone().add(i+(s?-1:1),f);return+(-(i+(n-r)/(s?r-u:u-r))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return{M:f,y:c,w:o,d:a,D:d,h:u,m:s,s:r,ms:i,Q:h}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},M="en",y={};y[M]=D;var S=function(t){return t instanceof w},p=function(t,e,n){var i;if(!t)return M;if("string"==typeof t)y[t]&&(i=t),e&&(y[t]=e,i=t);else{var r=t.name;y[r]=t,i=r}return!n&&i&&(M=i),i||!n&&M},O=function(t,e){if(S(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new w(n)},T=v;T.l=p,T.i=S,T.w=function(t,e){return O(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var w=function(){function D(t){this.$L=p(t.locale,null,!0),this.parse(t)}var g=D.prototype;return g.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(T.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var i=e.match($);if(i){var r=i[2]-1||0,s=(i[7]||"0").substring(0,3);return n?new Date(Date.UTC(i[1],r,i[3]||1,i[4]||0,i[5]||0,i[6]||0,s)):new Date(i[1],r,i[3]||1,i[4]||0,i[5]||0,i[6]||0,s)}}return new Date(e)}(t),this.$x=t.x||{},this.init()},g.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()},g.$utils=function(){return T},g.isValid=function(){return!(this.$d.toString()===l)},g.isSame=function(t,e){var n=O(t);return this.startOf(e)<=n&&n<=this.endOf(e)},g.isAfter=function(t,e){return O(t)<this.startOf(e)},g.isBefore=function(t,e){return this.endOf(e)<O(t)},g.$g=function(t,e,n){return T.u(t)?this[e]:this.set(n,t)},g.unix=function(){return Math.floor(this.valueOf()/1e3)},g.valueOf=function(){return this.$d.getTime()},g.startOf=function(t,e){var n=this,i=!!T.u(e)||e,h=T.p(t),l=function(t,e){var r=T.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return i?r:r.endOf(a)},$=function(t,e){return T.w(n.toDate()[t].apply(n.toDate("s"),(i?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},m=this.$W,D=this.$M,g=this.$D,v="set"+(this.$u?"UTC":"");switch(h){case c:return i?l(1,0):l(31,11);case f:return i?l(1,D):l(0,D+1);case o:var M=this.$locale().weekStart||0,y=(m<M?m+7:m)-M;return l(i?g-y:g+(6-y),D);case a:case d:return $(v+"Hours",0);case u:return $(v+"Minutes",1);case s:return $(v+"Seconds",2);case r:return $(v+"Milliseconds",3);default:return this.clone()}},g.endOf=function(t){return this.startOf(t,!1)},g.$set=function(t,e){var n,o=T.p(t),h="set"+(this.$u?"UTC":""),l=(n={},n[a]=h+"Date",n[d]=h+"Date",n[f]=h+"Month",n[c]=h+"FullYear",n[u]=h+"Hours",n[s]=h+"Minutes",n[r]=h+"Seconds",n[i]=h+"Milliseconds",n)[o],$=o===a?this.$D+(e-this.$W):e;if(o===f||o===c){var m=this.clone().set(d,1);m.$d[l]($),m.init(),this.$d=m.set(d,Math.min(this.$D,m.daysInMonth())).$d}else l&&this.$d[l]($);return this.init(),this},g.set=function(t,e){return this.clone().$set(t,e)},g.get=function(t){return this[T.p(t)]()},g.add=function(i,h){var d,l=this;i=Number(i);var $=T.p(h),m=function(t){var e=O(l);return T.w(e.date(e.date()+Math.round(t*i)),l)};if($===f)return this.set(f,this.$M+i);if($===c)return this.set(c,this.$y+i);if($===a)return m(1);if($===o)return m(7);var D=(d={},d[s]=e,d[u]=n,d[r]=t,d)[$]||1,g=this.$d.getTime()+i*D;return T.w(g,this)},g.subtract=function(t,e){return this.add(-1*t,e)},g.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||l;var i=t||"YYYY-MM-DDTHH:mm:ssZ",r=T.z(this),s=this.$H,u=this.$m,a=this.$M,o=n.weekdays,f=n.months,h=function(t,n,r,s){return t&&(t[n]||t(e,i))||r[n].substr(0,s)},c=function(t){return T.s(s%12||12,t,"0")},d=n.meridiem||function(t,e,n){var i=t<12?"AM":"PM";return n?i.toLowerCase():i},$={YY:String(this.$y).slice(-2),YYYY:this.$y,M:a+1,MM:T.s(a+1,2,"0"),MMM:h(n.monthsShort,a,f,3),MMMM:h(f,a),D:this.$D,DD:T.s(this.$D,2,"0"),d:String(this.$W),dd:h(n.weekdaysMin,this.$W,o,2),ddd:h(n.weekdaysShort,this.$W,o,3),dddd:o[this.$W],H:String(s),HH:T.s(s,2,"0"),h:c(1),hh:c(2),a:d(s,u,!0),A:d(s,u,!1),m:String(u),mm:T.s(u,2,"0"),s:String(this.$s),ss:T.s(this.$s,2,"0"),SSS:T.s(this.$ms,3,"0"),Z:r};return i.replace(m,(function(t,e){return e||$[t]||r.replace(":","")}))},g.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},g.diff=function(i,d,l){var $,m=T.p(d),D=O(i),g=(D.utcOffset()-this.utcOffset())*e,v=this-D,M=T.m(this,D);return M=($={},$[c]=M/12,$[f]=M,$[h]=M/3,$[o]=(v-g)/6048e5,$[a]=(v-g)/864e5,$[u]=v/n,$[s]=v/e,$[r]=v/t,$)[m]||v,l?M:T.a(M)},g.daysInMonth=function(){return this.endOf(f).$D},g.$locale=function(){return y[this.$L]},g.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),i=p(t,e,!0);return i&&(n.$L=i),n},g.clone=function(){return T.w(this.$d,this)},g.toDate=function(){return new Date(this.valueOf())},g.toJSON=function(){return this.isValid()?this.toISOString():null},g.toISOString=function(){return this.$d.toISOString()},g.toString=function(){return this.$d.toUTCString()},D}(),Y=w.prototype;return O.prototype=Y,[["$ms",i],["$s",r],["$m",s],["$H",u],["$W",a],["$M",f],["$y",c],["$D",d]].forEach((function(t){Y[t[1]]=function(e){return this.$g(e,t[0],t[1])}})),O.extend=function(t,e){return t.$i||(t(e,w,O),t.$i=!0),O},O.locale=p,O.isDayjs=S,O.unix=function(t){return O(1e3*t)},O.en=y[M],O.Ls=y,O.p={},O}();const n=(t,n={minutesRange:30})=>{const i=e(t),r=e(t);return`${i.format("MMM DD, hh:mm")} - ${r.add(n.minutesRange,"minute").format("hh:mm A")}`},i=(t,n={minutesRange:30})=>`${e(t).format("hh:mm")} - ${e(t).add(n.minutesRange,"minute").format("hh:mm A")}`,r=t=>e(t).format("MMM DD, hh:mm A"),s=t=>e(t).format("MMM DD, YYYY"),u=t=>e(t).format("hh:mm A"),a=t=>e(t).format("MMM DD"),o=t=>e(t).format("ddd MMM DD YYYY"),f=()=>({formatDate:s,formatDateTime:r,formatDateTimeWithRange:n,formatTime:u,formatTimeWithRange:i,formatDateShort:a,formatDateLong:o});var h,c,d,l={exports:{}},$=l.exports=(h="minute",c=/[+-]\d\d(?::?\d\d)?/g,d=/([+-]|\d\d)/g,function(t,e,n){var i=e.prototype;n.utc=function(t){return new e({date:t,utc:!0,args:arguments})},i.utc=function(t){var e=n(this.toDate(),{locale:this.$L,utc:!0});return t?e.add(this.utcOffset(),h):e},i.local=function(){return n(this.toDate(),{locale:this.$L,utc:!1})};var r=i.parse;i.parse=function(t){t.utc&&(this.$u=!0),this.$utils().u(t.$offset)||(this.$offset=t.$offset),r.call(this,t)};var s=i.init;i.init=function(){if(this.$u){var t=this.$d;this.$y=t.getUTCFullYear(),this.$M=t.getUTCMonth(),this.$D=t.getUTCDate(),this.$W=t.getUTCDay(),this.$H=t.getUTCHours(),this.$m=t.getUTCMinutes(),this.$s=t.getUTCSeconds(),this.$ms=t.getUTCMilliseconds()}else s.call(this)};var u=i.utcOffset;i.utcOffset=function(t,e){var n=this.$utils().u;if(n(t))return this.$u?0:n(this.$offset)?u.call(this):this.$offset;if("string"==typeof t&&null===(t=function(t){void 0===t&&(t="");var e=t.match(c);if(!e)return null;var n=(""+e[0]).match(d)||["-",0,0],i=n[0],r=60*+n[1]+ +n[2];return 0===r?0:"+"===i?r:-r}(t)))return this;var i=Math.abs(t)<=16?60*t:t,r=this;if(e)return r.$offset=i,r.$u=0===t,r;if(0!==t){var s=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(r=this.local().add(i+s,h)).$offset=i,r.$x.$localOffset=s}else r=this.utc();return r};var a=i.format;i.format=function(t){var e=t||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return a.call(this,e)},i.valueOf=function(){var t=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||(new Date).getTimezoneOffset());return this.$d.valueOf()-6e4*t},i.isUTC=function(){return!!this.$u},i.toISOString=function(){return this.toDate().toISOString()},i.toString=function(){return this.toDate().toUTCString()};var o=i.toDate;i.toDate=function(t){return"s"===t&&this.$offset?n(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():o.call(this)};var f=i.diff;i.diff=function(t,e,i){if(t&&this.$u===t.$u)return f.call(this,t,e,i);var r=this.local(),s=n(t).local();return f.call(r,s,e,i)}}),m={exports:{}},D=m.exports=function(){var t={year:0,month:1,day:2,hour:3,minute:4,second:5},e={};return function(n,i,r){var s,u=function(t,n,i){void 0===i&&(i={});var r=new Date(t);return function(t,n){void 0===n&&(n={});var i=n.timeZoneName||"short",r=t+"|"+i,s=e[r];return s||(s=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:i}),e[r]=s),s}(n,i).formatToParts(r)},a=function(e,n){for(var i=u(e,n),s=[],a=0;a<i.length;a+=1){var o=i[a],f=o.type,h=o.value,c=t[f];c>=0&&(s[c]=parseInt(h,10))}var d=s[3],l=24===d?0:d,$=s[0]+"-"+s[1]+"-"+s[2]+" "+l+":"+s[4]+":"+s[5]+":000",m=+e;return(r.utc($).valueOf()-(m-=m%1e3))/6e4},o=i.prototype;o.tz=function(t,e){void 0===t&&(t=s);var n=this.utcOffset(),i=this.toDate(),u=i.toLocaleString("en-US",{timeZone:t}),a=Math.round((i-new Date(u))/1e3/60),o=r(u).$set("millisecond",this.$ms).utcOffset(15*-Math.round(i.getTimezoneOffset()/15)-a,!0);if(e){var f=o.utcOffset();o=o.add(n-f,"minute")}return o.$x.$timezone=t,o},o.offsetName=function(t){var e=this.$x.$timezone||r.tz.guess(),n=u(this.valueOf(),e,{timeZoneName:t}).find((function(t){return"timezonename"===t.type.toLowerCase()}));return n&&n.value};var f=o.startOf;o.startOf=function(t,e){if(!this.$x||!this.$x.$timezone)return f.call(this,t,e);var n=r(this.format("YYYY-MM-DD HH:mm:ss:SSS"));return f.call(n,t,e).tz(this.$x.$timezone,!0)},r.tz=function(t,e,n){var i=n&&e,u=n||e||s,o=a(+r(),u);if("string"!=typeof t)return r(t).tz(u);var f=function(t,e,n){var i=t-60*e*1e3,r=a(i,n);if(e===r)return[i,e];var s=a(i-=60*(r-e)*1e3,n);return r===s?[i,r]:[t-60*Math.min(r,s)*1e3,Math.max(r,s)]}(r.utc(t,i).valueOf(),o,u),h=f[0],c=f[1],d=r(h).utcOffset(c);return d.$x.$timezone=u,d},r.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},r.tz.setDefault=function(t){s=t}}}();e.extend($),e.extend(D);const g=(t,n)=>e(t).tz(n,!0).toDate().getTime(),v=(t,e)=>{const n=t.toLocaleString("en-US",{timeZone:e});return new Date(n)},M=t=>e(t).utc(),y=t=>{const e=t.getTime(),n=t.getTimezoneOffset();return new Date(e+6e4*n)},S=(t,e)=>{if(!t)return e;if(!e)return t;const n=e.getHours(),i=e.getMinutes(),r=y(new Date(t));return r.setHours(n),r.setMinutes(i),r},p=()=>({getDateInTz:v,getDateInServiceAreaTz:g,getUTCDate:M,applyDateTimezone:y,combineDateAndTime:S});export{f as useDateFormatter,p as useDateTransformer};
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
var dayjs_min = {exports: {}};
(function (module, exports) {
!function(t,e){module.exports=e();}(commonjsGlobal,(function(){var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",f="month",h="quarter",c="year",d="date",$="Invalid Date",l=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|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,M={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("_")},m=function(t,e,n){var r=String(t);return !r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},g={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return (e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return -t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,f),s=n-i<0,u=e.clone().add(r+(s?-1:1),f);return +(-(r+(n-i)/(s?i-u:u-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return {M:f,y:c,w:o,d:a,D:d,h:u,m:s,s:i,ms:r,Q:h}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},D="en",v={};v[D]=M;var p=function(t){return t instanceof _},S=function(t,e,n){var r;if(!t)return D;if("string"==typeof t)v[t]&&(r=t),e&&(v[t]=e,r=t);else {var i=t.name;v[i]=t,r=i;}return !n&&r&&(D=r),r||!n&&D},w=function(t,e){if(p(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},O=g;O.l=S,O.i=p,O.w=function(t,e){return w(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=S(t.locale,null,!0),this.parse(t);}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(O.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match(l);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.$x=t.x||{},this.init();},m.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();},m.$utils=function(){return O},m.isValid=function(){return !(this.$d.toString()===$)},m.isSame=function(t,e){var n=w(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return w(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<w(t)},m.$g=function(t,e,n){return O.u(t)?this[e]:this.set(n,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,e){var n=this,r=!!O.u(e)||e,h=O.p(t),$=function(t,e){var i=O.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return r?i:i.endOf(a)},l=function(t,e){return O.w(n.toDate()[t].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},y=this.$W,M=this.$M,m=this.$D,g="set"+(this.$u?"UTC":"");switch(h){case c:return r?$(1,0):$(31,11);case f:return r?$(1,M):$(0,M+1);case o:var D=this.$locale().weekStart||0,v=(y<D?y+7:y)-D;return $(r?m-v:m+(6-v),M);case a:case d:return l(g+"Hours",0);case u:return l(g+"Minutes",1);case s:return l(g+"Seconds",2);case i:return l(g+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,!1)},m.$set=function(t,e){var n,o=O.p(t),h="set"+(this.$u?"UTC":""),$=(n={},n[a]=h+"Date",n[d]=h+"Date",n[f]=h+"Month",n[c]=h+"FullYear",n[u]=h+"Hours",n[s]=h+"Minutes",n[i]=h+"Seconds",n[r]=h+"Milliseconds",n)[o],l=o===a?this.$D+(e-this.$W):e;if(o===f||o===c){var y=this.clone().set(d,1);y.$d[$](l),y.init(),this.$d=y.set(d,Math.min(this.$D,y.daysInMonth())).$d;}else $&&this.$d[$](l);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[O.p(t)]()},m.add=function(r,h){var d,$=this;r=Number(r);var l=O.p(h),y=function(t){var e=w($);return O.w(e.date(e.date()+Math.round(t*r)),$)};if(l===f)return this.set(f,this.$M+r);if(l===c)return this.set(c,this.$y+r);if(l===a)return y(1);if(l===o)return y(7);var M=(d={},d[s]=e,d[u]=n,d[i]=t,d)[l]||1,m=this.$d.getTime()+r*M;return O.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||$;var r=t||"YYYY-MM-DDTHH:mm:ssZ",i=O.z(this),s=this.$H,u=this.$m,a=this.$M,o=n.weekdays,f=n.months,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].substr(0,s)},c=function(t){return O.s(s%12||12,t,"0")},d=n.meridiem||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r},l={YY:String(this.$y).slice(-2),YYYY:this.$y,M:a+1,MM:O.s(a+1,2,"0"),MMM:h(n.monthsShort,a,f,3),MMMM:h(f,a),D:this.$D,DD:O.s(this.$D,2,"0"),d:String(this.$W),dd:h(n.weekdaysMin,this.$W,o,2),ddd:h(n.weekdaysShort,this.$W,o,3),dddd:o[this.$W],H:String(s),HH:O.s(s,2,"0"),h:c(1),hh:c(2),a:d(s,u,!0),A:d(s,u,!1),m:String(u),mm:O.s(u,2,"0"),s:String(this.$s),ss:O.s(this.$s,2,"0"),SSS:O.s(this.$ms,3,"0"),Z:i};return r.replace(y,(function(t,e){return e||l[t]||i.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,d,$){var l,y=O.p(d),M=w(r),m=(M.utcOffset()-this.utcOffset())*e,g=this-M,D=O.m(this,M);return D=(l={},l[c]=D/12,l[f]=D,l[h]=D/3,l[o]=(g-m)/6048e5,l[a]=(g-m)/864e5,l[u]=g/n,l[s]=g/e,l[i]=g/t,l)[y]||g,$?D:O.a(D)},m.daysInMonth=function(){return this.endOf(f).$D},m.$locale=function(){return v[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=S(t,e,!0);return r&&(n.$L=r),n},m.clone=function(){return O.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},M}(),b=_.prototype;return w.prototype=b,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",f],["$y",c],["$D",d]].forEach((function(t){b[t[1]]=function(e){return this.$g(e,t[0],t[1])};})),w.extend=function(t,e){return t.$i||(t(e,_,w),t.$i=!0),w},w.locale=S,w.isDayjs=p,w.unix=function(t){return w(1e3*t)},w.en=v[D],w.Ls=v,w.p={},w}));
}(dayjs_min));
var dayjs = dayjs_min.exports;
const formatDateTimeWithRange = (date, options = {
minutesRange: 30,
}) => {
const start = dayjs(date);
const end = dayjs(date);
return `${start.format('MMM DD, hh:mm')} - ${end
.add(options.minutesRange, 'minute')
.format('hh:mm A')}`;
};
const formatTimeWithRange = (date, options = {
minutesRange: 30,
}) => {
const startTime = dayjs(date).format('hh:mm');
const endTime = dayjs(date)
.add(options.minutesRange, 'minute')
.format('hh:mm A');
return `${startTime} - ${endTime}`;
};
const formatDateTime = (date) => dayjs(date).format('MMM DD, hh:mm A');
const formatDate = (date) => dayjs(date).format('MMM DD, YYYY');
const formatTime = (date) => dayjs(date).format('hh:mm A');
const formatDateShort = (date) => dayjs(date).format('MMM DD');
const formatDateLong = (date) => dayjs(date).format('ddd MMM DD YYYY');
const formatISOWithoutTimezone = (date) => dayjs(date).format('YYYY-MM-DDTHH:mm');
const useDateFormatter = () => ({
formatDate,
formatDateTime,
formatDateTimeWithRange,
formatTime,
formatTimeWithRange,
formatDateShort,
formatDateLong,
formatISOWithoutTimezone,
});
function toInteger(dirtyNumber) {
if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
return NaN;
}
var number = Number(dirtyNumber);
if (isNaN(number)) {
return number;
}
return number < 0 ? Math.ceil(number) : Math.floor(number);
}
/**
* Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.
* They usually appear for dates that denote time before the timezones were introduced
* (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891
* and GMT+01:00:00 after that date)
*
* Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,
* which would lead to incorrect calculations.
*
* This function returns the timezone offset in milliseconds that takes seconds in account.
*/
function getTimezoneOffsetInMilliseconds(date) {
var utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
utcDate.setUTCFullYear(date.getFullYear());
return date.getTime() - utcDate.getTime();
}
/**
* Returns the [year, month, day, hour, minute, seconds] tokens of the provided
* `date` as it will be rendered in the `timeZone`.
*/
function tzTokenizeDate(date, timeZone) {
var dtf = getDateTimeFormat(timeZone);
return dtf.formatToParts ? partsOffset(dtf, date) : hackyOffset(dtf, date)
}
var typeToPos = {
year: 0,
month: 1,
day: 2,
hour: 3,
minute: 4,
second: 5,
};
function partsOffset(dtf, date) {
var formatted = dtf.formatToParts(date);
var filled = [];
for (var i = 0; i < formatted.length; i++) {
var pos = typeToPos[formatted[i].type];
if (pos >= 0) {
filled[pos] = parseInt(formatted[i].value, 10);
}
}
return filled
}
function hackyOffset(dtf, date) {
var formatted = dtf.format(date).replace(/\u200E/g, '');
var parsed = /(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(formatted);
// var [, fMonth, fDay, fYear, fHour, fMinute, fSecond] = parsed
// return [fYear, fMonth, fDay, fHour, fMinute, fSecond]
return [parsed[3], parsed[1], parsed[2], parsed[4], parsed[5], parsed[6]]
}
// Get a cached Intl.DateTimeFormat instance for the IANA `timeZone`. This can be used
// to get deterministic local date/time output according to the `en-US` locale which
// can be used to extract local time parts as necessary.
var dtfCache = {};
function getDateTimeFormat(timeZone) {
if (!dtfCache[timeZone]) {
// New browsers use `hourCycle`, IE and Chrome <73 does not support it and uses `hour12`
var testDateFormatted = new Intl.DateTimeFormat('en-US', {
hour12: false,
timeZone: 'America/New_York',
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
}).format(new Date('2014-06-25T04:00:00.123Z'));
var hourCycleSupported =
testDateFormatted === '06/25/2014, 00:00:00' ||
testDateFormatted === '‎06‎/‎25‎/‎2014‎ ‎00‎:‎00‎:‎00';
dtfCache[timeZone] = hourCycleSupported
? new Intl.DateTimeFormat('en-US', {
hour12: false,
timeZone: timeZone,
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
})
: new Intl.DateTimeFormat('en-US', {
hourCycle: 'h23',
timeZone: timeZone,
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
});
}
return dtfCache[timeZone]
}
var MILLISECONDS_IN_HOUR$1 = 3600000;
var MILLISECONDS_IN_MINUTE$1 = 60000;
var patterns$1 = {
timezone: /([Z+-].*)$/,
timezoneZ: /^(Z)$/,
timezoneHH: /^([+-])(\d{2})$/,
timezoneHHMM: /^([+-])(\d{2}):?(\d{2})$/
};
// Parse various time zone offset formats to an offset in milliseconds
function tzParseTimezone(timezoneString, date, isUtcDate) {
var token;
var absoluteOffset;
// Z
token = patterns$1.timezoneZ.exec(timezoneString);
if (token) {
return 0
}
var hours;
// ±hh
token = patterns$1.timezoneHH.exec(timezoneString);
if (token) {
hours = parseInt(token[2], 10);
if (!validateTimezone()) {
return NaN
}
absoluteOffset = hours * MILLISECONDS_IN_HOUR$1;
return token[1] === '+' ? -absoluteOffset : absoluteOffset
}
// ±hh:mm or ±hhmm
token = patterns$1.timezoneHHMM.exec(timezoneString);
if (token) {
hours = parseInt(token[2], 10);
var minutes = parseInt(token[3], 10);
if (!validateTimezone(hours, minutes)) {
return NaN
}
absoluteOffset = hours * MILLISECONDS_IN_HOUR$1 + minutes * MILLISECONDS_IN_MINUTE$1;
return token[1] === '+' ? -absoluteOffset : absoluteOffset
}
// IANA time zone
if (isValidTimezoneIANAString(timezoneString)) {
date = new Date(date || Date.now());
var utcDate = isUtcDate ? date : toUtcDate(date);
var offset = calcOffset(utcDate, timezoneString);
var fixedOffset = isUtcDate ? offset : fixOffset(date, offset, timezoneString);
return -fixedOffset
}
return 0
}
function toUtcDate(date) {
return new Date(
Date.UTC(
date.getFullYear(),
date.getMonth(),
date.getDate(),
date.getHours(),
date.getMinutes(),
date.getSeconds(),
date.getMilliseconds()
)
)
}
function calcOffset(date, timezoneString) {
var tokens = tzTokenizeDate(date, timezoneString);
var asUTC = Date.UTC(tokens[0], tokens[1] - 1, tokens[2], tokens[3] % 24, tokens[4], tokens[5]);
var asTS = date.getTime();
var over = asTS % 1000;
asTS -= over >= 0 ? over : 1000 + over;
return asUTC - asTS
}
function fixOffset(date, offset, timezoneString) {
var localTS = date.getTime();
// Our UTC time is just a guess because our offset is just a guess
var utcGuess = localTS - offset;
// Test whether the zone matches the offset for this ts
var o2 = calcOffset(new Date(utcGuess), timezoneString);
// If so, offset didn't change and we're done
if (offset === o2) {
return offset
}
// If not, change the ts by the difference in the offset
utcGuess -= o2 - offset;
// If that gives us the local time we want, we're done
var o3 = calcOffset(new Date(utcGuess), timezoneString);
if (o2 === o3) {
return o2
}
// If it's different, we're in a hole time. The offset has changed, but the we don't adjust the time
return Math.max(o2, o3)
}
function validateTimezone(hours, minutes) {
if (minutes != null && (minutes < 0 || minutes > 59)) {
return false
}
return true
}
function isValidTimezoneIANAString(timeZoneString) {
try {
Intl.DateTimeFormat(undefined, {timeZone: timeZoneString});
return true;
} catch (error) {
return false;
}
}
var MILLISECONDS_IN_HOUR = 3600000;
var MILLISECONDS_IN_MINUTE = 60000;
var DEFAULT_ADDITIONAL_DIGITS = 2;
var patterns = {
dateTimeDelimeter: /[T ]/,
plainTime: /:/,
timeZoneDelimeter: /[Z ]/i,
// year tokens
YY: /^(\d{2})$/,
YYY: [
/^([+-]\d{2})$/, // 0 additional digits
/^([+-]\d{3})$/, // 1 additional digit
/^([+-]\d{4})$/, // 2 additional digits
],
YYYY: /^(\d{4})/,
YYYYY: [
/^([+-]\d{4})/, // 0 additional digits
/^([+-]\d{5})/, // 1 additional digit
/^([+-]\d{6})/, // 2 additional digits
],
// date tokens
MM: /^-(\d{2})$/,
DDD: /^-?(\d{3})$/,
MMDD: /^-?(\d{2})-?(\d{2})$/,
Www: /^-?W(\d{2})$/,
WwwD: /^-?W(\d{2})-?(\d{1})$/,
HH: /^(\d{2}([.,]\d*)?)$/,
HHMM: /^(\d{2}):?(\d{2}([.,]\d*)?)$/,
HHMMSS: /^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,
// timezone tokens (to identify the presence of a tz)
timezone: /([Z+-].*| UTC|(?:[a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?))$/,
};
/**
* @name toDate
* @category Common Helpers
* @summary Convert the given argument to an instance of Date.
*
* @description
* Convert the given argument to an instance of Date.
*
* If the argument is an instance of Date, the function returns its clone.
*
* If the argument is a number, it is treated as a timestamp.
*
* If an argument is a string, the function tries to parse it.
* Function accepts complete ISO 8601 formats as well as partial implementations.
* ISO 8601: http://en.wikipedia.org/wiki/ISO_8601
* If the function cannot parse the string or the values are invalid, it returns Invalid Date.
*
* If the argument is none of the above, the function returns Invalid Date.
*
* **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
* All *date-fns* functions will throw `RangeError` if `options.additionalDigits` is not 0, 1, 2 or undefined.
*
* @param {Date|String|Number} argument - the value to convert
* @param {OptionsWithTZ} [options] - the object with options. See [Options]{@link https://date-fns.org/docs/Options}
* @param {0|1|2} [options.additionalDigits=2] - the additional number of digits in the extended year format
* @param {String} [options.timeZone=''] - used to specify the IANA time zone offset of a date String.
* @returns {Date} the parsed date in the local time zone
* @throws {TypeError} 1 argument required
* @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2
*
* @example
* // Convert string '2014-02-11T11:30:30' to date:
* var result = toDate('2014-02-11T11:30:30')
* //=> Tue Feb 11 2014 11:30:30
*
* @example
* // Convert string '+02014101' to date,
* // if the additional number of digits in the extended year format is 1:
* var result = toDate('+02014101', {additionalDigits: 1})
* //=> Fri Apr 11 2014 00:00:00
*/
function toDate(argument, dirtyOptions) {
if (arguments.length < 1) {
throw new TypeError('1 argument required, but only ' + arguments.length + ' present')
}
if (argument === null) {
return new Date(NaN)
}
var options = dirtyOptions || {};
var additionalDigits =
options.additionalDigits == null
? DEFAULT_ADDITIONAL_DIGITS
: toInteger(options.additionalDigits);
if (additionalDigits !== 2 && additionalDigits !== 1 && additionalDigits !== 0) {
throw new RangeError('additionalDigits must be 0, 1 or 2')
}
// Clone the date
if (
argument instanceof Date ||
(typeof argument === 'object' && Object.prototype.toString.call(argument) === '[object Date]')
) {
// Prevent the date to lose the milliseconds when passed to new Date() in IE10
return new Date(argument.getTime())
} else if (
typeof argument === 'number' ||
Object.prototype.toString.call(argument) === '[object Number]'
) {
return new Date(argument)
} else if (
!(
typeof argument === 'string' || Object.prototype.toString.call(argument) === '[object String]'
)
) {
return new Date(NaN)
}
var dateStrings = splitDateString(argument);
var parseYearResult = parseYear(dateStrings.date, additionalDigits);
var year = parseYearResult.year;
var restDateString = parseYearResult.restDateString;
var date = parseDate(restDateString, year);
if (isNaN(date)) {
return new Date(NaN)
}
if (date) {
var timestamp = date.getTime();
var time = 0;
var offset;
if (dateStrings.time) {
time = parseTime(dateStrings.time);
if (isNaN(time)) {
return new Date(NaN)
}
}
if (dateStrings.timezone || options.timeZone) {
offset = tzParseTimezone(dateStrings.timezone || options.timeZone, new Date(timestamp + time));
if (isNaN(offset)) {
return new Date(NaN)
}
} else {
// get offset accurate to hour in timezones that change offset
offset = getTimezoneOffsetInMilliseconds(new Date(timestamp + time));
offset = getTimezoneOffsetInMilliseconds(new Date(timestamp + time + offset));
}
return new Date(timestamp + time + offset)
} else {
return new Date(NaN)
}
}
function splitDateString(dateString) {
var dateStrings = {};
var array = dateString.split(patterns.dateTimeDelimeter);
var timeString;
if (patterns.plainTime.test(array[0])) {
dateStrings.date = null;
timeString = array[0];
} else {
dateStrings.date = array[0];
timeString = array[1];
dateStrings.timezone = array[2];
if (patterns.timeZoneDelimeter.test(dateStrings.date)) {
dateStrings.date = dateString.split(patterns.timeZoneDelimeter)[0];
timeString = dateString.substr(dateStrings.date.length, dateString.length);
}
}
if (timeString) {
var token = patterns.timezone.exec(timeString);
if (token) {
dateStrings.time = timeString.replace(token[1], '');
dateStrings.timezone = token[1];
} else {
dateStrings.time = timeString;
}
}
return dateStrings
}
function parseYear(dateString, additionalDigits) {
var patternYYY = patterns.YYY[additionalDigits];
var patternYYYYY = patterns.YYYYY[additionalDigits];
var token;
// YYYY or ±YYYYY
token = patterns.YYYY.exec(dateString) || patternYYYYY.exec(dateString);
if (token) {
var yearString = token[1];
return {
year: parseInt(yearString, 10),
restDateString: dateString.slice(yearString.length),
}
}
// YY or ±YYY
token = patterns.YY.exec(dateString) || patternYYY.exec(dateString);
if (token) {
var centuryString = token[1];
return {
year: parseInt(centuryString, 10) * 100,
restDateString: dateString.slice(centuryString.length),
}
}
// Invalid ISO-formatted year
return {
year: null,
}
}
function parseDate(dateString, year) {
// Invalid ISO-formatted year
if (year === null) {
return null
}
var token;
var date;
var month;
var week;
// YYYY
if (dateString.length === 0) {
date = new Date(0);
date.setUTCFullYear(year);
return date
}
// YYYY-MM
token = patterns.MM.exec(dateString);
if (token) {
date = new Date(0);
month = parseInt(token[1], 10) - 1;
if (!validateDate(year, month)) {
return new Date(NaN)
}
date.setUTCFullYear(year, month);
return date
}
// YYYY-DDD or YYYYDDD
token = patterns.DDD.exec(dateString);
if (token) {
date = new Date(0);
var dayOfYear = parseInt(token[1], 10);
if (!validateDayOfYearDate(year, dayOfYear)) {
return new Date(NaN)
}
date.setUTCFullYear(year, 0, dayOfYear);
return date
}
// yyyy-MM-dd or YYYYMMDD
token = patterns.MMDD.exec(dateString);
if (token) {
date = new Date(0);
month = parseInt(token[1], 10) - 1;
var day = parseInt(token[2], 10);
if (!validateDate(year, month, day)) {
return new Date(NaN)
}
date.setUTCFullYear(year, month, day);
return date
}
// YYYY-Www or YYYYWww
token = patterns.Www.exec(dateString);
if (token) {
week = parseInt(token[1], 10) - 1;
if (!validateWeekDate(year, week)) {
return new Date(NaN)
}
return dayOfISOWeekYear(year, week)
}
// YYYY-Www-D or YYYYWwwD
token = patterns.WwwD.exec(dateString);
if (token) {
week = parseInt(token[1], 10) - 1;
var dayOfWeek = parseInt(token[2], 10) - 1;
if (!validateWeekDate(year, week, dayOfWeek)) {
return new Date(NaN)
}
return dayOfISOWeekYear(year, week, dayOfWeek)
}
// Invalid ISO-formatted date
return null
}
function parseTime(timeString) {
var token;
var hours;
var minutes;
// hh
token = patterns.HH.exec(timeString);
if (token) {
hours = parseFloat(token[1].replace(',', '.'));
if (!validateTime(hours)) {
return NaN
}
return (hours % 24) * MILLISECONDS_IN_HOUR
}
// hh:mm or hhmm
token = patterns.HHMM.exec(timeString);
if (token) {
hours = parseInt(token[1], 10);
minutes = parseFloat(token[2].replace(',', '.'));
if (!validateTime(hours, minutes)) {
return NaN
}
return (hours % 24) * MILLISECONDS_IN_HOUR + minutes * MILLISECONDS_IN_MINUTE
}
// hh:mm:ss or hhmmss
token = patterns.HHMMSS.exec(timeString);
if (token) {
hours = parseInt(token[1], 10);
minutes = parseInt(token[2], 10);
var seconds = parseFloat(token[3].replace(',', '.'));
if (!validateTime(hours, minutes, seconds)) {
return NaN
}
return (hours % 24) * MILLISECONDS_IN_HOUR + minutes * MILLISECONDS_IN_MINUTE + seconds * 1000
}
// Invalid ISO-formatted time
return null
}
function dayOfISOWeekYear(isoWeekYear, week, day) {
week = week || 0;
day = day || 0;
var date = new Date(0);
date.setUTCFullYear(isoWeekYear, 0, 4);
var fourthOfJanuaryDay = date.getUTCDay() || 7;
var diff = week * 7 + day + 1 - fourthOfJanuaryDay;
date.setUTCDate(date.getUTCDate() + diff);
return date
}
// Validation functions
var DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
var DAYS_IN_MONTH_LEAP_YEAR = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
function isLeapYearIndex(year) {
return year % 400 === 0 || (year % 4 === 0 && year % 100 !== 0)
}
function validateDate(year, month, date) {
if (month < 0 || month > 11) {
return false
}
if (date != null) {
if (date < 1) {
return false
}
var isLeapYear = isLeapYearIndex(year);
if (isLeapYear && date > DAYS_IN_MONTH_LEAP_YEAR[month]) {
return false
}
if (!isLeapYear && date > DAYS_IN_MONTH[month]) {
return false
}
}
return true
}
function validateDayOfYearDate(year, dayOfYear) {
if (dayOfYear < 1) {
return false
}
var isLeapYear = isLeapYearIndex(year);
if (isLeapYear && dayOfYear > 366) {
return false
}
if (!isLeapYear && dayOfYear > 365) {
return false
}
return true
}
function validateWeekDate(year, week, day) {
if (week < 0 || week > 52) {
return false
}
if (day != null && (day < 0 || day > 6)) {
return false
}
return true
}
function validateTime(hours, minutes, seconds) {
if (hours != null && (hours < 0 || hours >= 25)) {
return false
}
if (minutes != null && (minutes < 0 || minutes >= 60)) {
return false
}
if (seconds != null && (seconds < 0 || seconds >= 60)) {
return false
}
return true
}
/**
* @name utcToZonedTime
* @category Time Zone Helpers
* @summary Get a date/time representing local time in a given time zone from the UTC date
*
* @description
* Returns a date instance with values representing the local time in the time zone
* specified of the UTC time from the date provided. In other words, when the new date
* is formatted it will show the equivalent hours in the target time zone regardless
* of the current system time zone.
*
* @param {Date|String|Number} date - the date with the relevant UTC time
* @param {String} timeZone - the time zone to get local time for, can be an offset or IANA time zone
* @param {OptionsWithTZ} [options] - the object with options. See [Options]{@link https://date-fns.org/docs/Options}
* @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate}
* @returns {Date} the new date with the equivalent time in the time zone
* @throws {TypeError} 2 arguments required
* @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2
*
* @example
* // In June 10am UTC is 6am in New York (-04:00)
* const result = utcToZonedTime('2014-06-25T10:00:00.000Z', 'America/New_York')
* //=> Jun 25 2014 06:00:00
*/
function utcToZonedTime(dirtyDate, timeZone, options) {
var date = toDate(dirtyDate, options);
var offsetMilliseconds = tzParseTimezone(timeZone, date, true) || 0;
var d = new Date(date.getTime() - offsetMilliseconds);
var zonedTime = new Date(
d.getUTCFullYear(),
d.getUTCMonth(),
d.getUTCDate(),
d.getUTCHours(),
d.getUTCMinutes(),
d.getUTCSeconds(),
d.getUTCMilliseconds()
);
return zonedTime
}
const getDateInServiceAreaTz = (date, timezone) => {
const localDate = new Date(date).getTime();
const localDateInTz = utcToZonedTime(date, timezone).getTime();
return localDate + localDate - localDateInTz;
};
const getZonedTime = (date, timezone) => utcToZonedTime(date, timezone);
const combineDateAndTime = (date, time) => {
if (!date)
return time;
if (!time)
return date;
const hours = time.getHours();
const minutes = time.getMinutes();
const newDate = new Date(date);
newDate.setHours(hours);
newDate.setMinutes(minutes);
return newDate;
};
const sanitizeDate = (date) => {
if (/^\d{4}/.test(date)) {
return new Date(date);
}
return new Date(date.replace(/-/g, '/'));
};
const useDateTransformer = () => ({
getDateInServiceAreaTz,
getZonedTime,
combineDateAndTime,
sanitizeDate,
});
export { useDateFormatter, useDateTransformer };
//# sourceMappingURL=date-utils.es5.js.map

@@ -1,2 +0,824 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var t={exports:{}},e=t.exports=function(){var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",f="month",h="quarter",c="year",d="date",l="Invalid Date",m=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\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,D={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("_")},v=function(t,e,n){var r=String(t);return!r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},g={s:v,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return(e<=0?"+":"-")+v(r,2,"0")+":"+v(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return-t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,f),s=n-i<0,u=e.clone().add(r+(s?-1:1),f);return+(-(r+(n-i)/(s?i-u:u-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return{M:f,y:c,w:o,d:a,D:d,h:u,m:s,s:i,ms:r,Q:h}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},M="en",y={};y[M]=D;var p=function(t){return t instanceof w},S=function(t,e,n){var r;if(!t)return M;if("string"==typeof t)y[t]&&(r=t),e&&(y[t]=e,r=t);else{var i=t.name;y[i]=t,r=i}return!n&&r&&(M=r),r||!n&&M},O=function(t,e){if(p(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new w(n)},T=g;T.l=S,T.i=p,T.w=function(t,e){return O(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var w=function(){function D(t){this.$L=S(t.locale,null,!0),this.parse(t)}var v=D.prototype;return v.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(T.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match(m);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.$x=t.x||{},this.init()},v.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()},v.$utils=function(){return T},v.isValid=function(){return!(this.$d.toString()===l)},v.isSame=function(t,e){var n=O(t);return this.startOf(e)<=n&&n<=this.endOf(e)},v.isAfter=function(t,e){return O(t)<this.startOf(e)},v.isBefore=function(t,e){return this.endOf(e)<O(t)},v.$g=function(t,e,n){return T.u(t)?this[e]:this.set(n,t)},v.unix=function(){return Math.floor(this.valueOf()/1e3)},v.valueOf=function(){return this.$d.getTime()},v.startOf=function(t,e){var n=this,r=!!T.u(e)||e,h=T.p(t),l=function(t,e){var i=T.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return r?i:i.endOf(a)},m=function(t,e){return T.w(n.toDate()[t].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},$=this.$W,D=this.$M,v=this.$D,g="set"+(this.$u?"UTC":"");switch(h){case c:return r?l(1,0):l(31,11);case f:return r?l(1,D):l(0,D+1);case o:var M=this.$locale().weekStart||0,y=($<M?$+7:$)-M;return l(r?v-y:v+(6-y),D);case a:case d:return m(g+"Hours",0);case u:return m(g+"Minutes",1);case s:return m(g+"Seconds",2);case i:return m(g+"Milliseconds",3);default:return this.clone()}},v.endOf=function(t){return this.startOf(t,!1)},v.$set=function(t,e){var n,o=T.p(t),h="set"+(this.$u?"UTC":""),l=(n={},n[a]=h+"Date",n[d]=h+"Date",n[f]=h+"Month",n[c]=h+"FullYear",n[u]=h+"Hours",n[s]=h+"Minutes",n[i]=h+"Seconds",n[r]=h+"Milliseconds",n)[o],m=o===a?this.$D+(e-this.$W):e;if(o===f||o===c){var $=this.clone().set(d,1);$.$d[l](m),$.init(),this.$d=$.set(d,Math.min(this.$D,$.daysInMonth())).$d}else l&&this.$d[l](m);return this.init(),this},v.set=function(t,e){return this.clone().$set(t,e)},v.get=function(t){return this[T.p(t)]()},v.add=function(r,h){var d,l=this;r=Number(r);var m=T.p(h),$=function(t){var e=O(l);return T.w(e.date(e.date()+Math.round(t*r)),l)};if(m===f)return this.set(f,this.$M+r);if(m===c)return this.set(c,this.$y+r);if(m===a)return $(1);if(m===o)return $(7);var D=(d={},d[s]=e,d[u]=n,d[i]=t,d)[m]||1,v=this.$d.getTime()+r*D;return T.w(v,this)},v.subtract=function(t,e){return this.add(-1*t,e)},v.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||l;var r=t||"YYYY-MM-DDTHH:mm:ssZ",i=T.z(this),s=this.$H,u=this.$m,a=this.$M,o=n.weekdays,f=n.months,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].substr(0,s)},c=function(t){return T.s(s%12||12,t,"0")},d=n.meridiem||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r},m={YY:String(this.$y).slice(-2),YYYY:this.$y,M:a+1,MM:T.s(a+1,2,"0"),MMM:h(n.monthsShort,a,f,3),MMMM:h(f,a),D:this.$D,DD:T.s(this.$D,2,"0"),d:String(this.$W),dd:h(n.weekdaysMin,this.$W,o,2),ddd:h(n.weekdaysShort,this.$W,o,3),dddd:o[this.$W],H:String(s),HH:T.s(s,2,"0"),h:c(1),hh:c(2),a:d(s,u,!0),A:d(s,u,!1),m:String(u),mm:T.s(u,2,"0"),s:String(this.$s),ss:T.s(this.$s,2,"0"),SSS:T.s(this.$ms,3,"0"),Z:i};return r.replace($,(function(t,e){return e||m[t]||i.replace(":","")}))},v.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},v.diff=function(r,d,l){var m,$=T.p(d),D=O(r),v=(D.utcOffset()-this.utcOffset())*e,g=this-D,M=T.m(this,D);return M=(m={},m[c]=M/12,m[f]=M,m[h]=M/3,m[o]=(g-v)/6048e5,m[a]=(g-v)/864e5,m[u]=g/n,m[s]=g/e,m[i]=g/t,m)[$]||g,l?M:T.a(M)},v.daysInMonth=function(){return this.endOf(f).$D},v.$locale=function(){return y[this.$L]},v.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=S(t,e,!0);return r&&(n.$L=r),n},v.clone=function(){return T.w(this.$d,this)},v.toDate=function(){return new Date(this.valueOf())},v.toJSON=function(){return this.isValid()?this.toISOString():null},v.toISOString=function(){return this.$d.toISOString()},v.toString=function(){return this.$d.toUTCString()},D}(),Y=w.prototype;return O.prototype=Y,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",f],["$y",c],["$D",d]].forEach((function(t){Y[t[1]]=function(e){return this.$g(e,t[0],t[1])}})),O.extend=function(t,e){return t.$i||(t(e,w,O),t.$i=!0),O},O.locale=S,O.isDayjs=p,O.unix=function(t){return O(1e3*t)},O.en=y[M],O.Ls=y,O.p={},O}();const n=(t,n={minutesRange:30})=>{const r=e(t),i=e(t);return`${r.format("MMM DD, hh:mm")} - ${i.add(n.minutesRange,"minute").format("hh:mm A")}`},r=(t,n={minutesRange:30})=>`${e(t).format("hh:mm")} - ${e(t).add(n.minutesRange,"minute").format("hh:mm A")}`,i=t=>e(t).format("MMM DD, hh:mm A"),s=t=>e(t).format("MMM DD, YYYY"),u=t=>e(t).format("hh:mm A"),a=t=>e(t).format("MMM DD"),o=t=>e(t).format("ddd MMM DD YYYY");var f,h,c,d={exports:{}},l=d.exports=(f="minute",h=/[+-]\d\d(?::?\d\d)?/g,c=/([+-]|\d\d)/g,function(t,e,n){var r=e.prototype;n.utc=function(t){return new e({date:t,utc:!0,args:arguments})},r.utc=function(t){var e=n(this.toDate(),{locale:this.$L,utc:!0});return t?e.add(this.utcOffset(),f):e},r.local=function(){return n(this.toDate(),{locale:this.$L,utc:!1})};var i=r.parse;r.parse=function(t){t.utc&&(this.$u=!0),this.$utils().u(t.$offset)||(this.$offset=t.$offset),i.call(this,t)};var s=r.init;r.init=function(){if(this.$u){var t=this.$d;this.$y=t.getUTCFullYear(),this.$M=t.getUTCMonth(),this.$D=t.getUTCDate(),this.$W=t.getUTCDay(),this.$H=t.getUTCHours(),this.$m=t.getUTCMinutes(),this.$s=t.getUTCSeconds(),this.$ms=t.getUTCMilliseconds()}else s.call(this)};var u=r.utcOffset;r.utcOffset=function(t,e){var n=this.$utils().u;if(n(t))return this.$u?0:n(this.$offset)?u.call(this):this.$offset;if("string"==typeof t&&null===(t=function(t){void 0===t&&(t="");var e=t.match(h);if(!e)return null;var n=(""+e[0]).match(c)||["-",0,0],r=n[0],i=60*+n[1]+ +n[2];return 0===i?0:"+"===r?i:-i}(t)))return this;var r=Math.abs(t)<=16?60*t:t,i=this;if(e)return i.$offset=r,i.$u=0===t,i;if(0!==t){var s=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(i=this.local().add(r+s,f)).$offset=r,i.$x.$localOffset=s}else i=this.utc();return i};var a=r.format;r.format=function(t){var e=t||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return a.call(this,e)},r.valueOf=function(){var t=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||(new Date).getTimezoneOffset());return this.$d.valueOf()-6e4*t},r.isUTC=function(){return!!this.$u},r.toISOString=function(){return this.toDate().toISOString()},r.toString=function(){return this.toDate().toUTCString()};var o=r.toDate;r.toDate=function(t){return"s"===t&&this.$offset?n(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():o.call(this)};var d=r.diff;r.diff=function(t,e,r){if(t&&this.$u===t.$u)return d.call(this,t,e,r);var i=this.local(),s=n(t).local();return d.call(i,s,e,r)}}),m={exports:{}},$=m.exports=function(){var t={year:0,month:1,day:2,hour:3,minute:4,second:5},e={};return function(n,r,i){var s,u=function(t,n,r){void 0===r&&(r={});var i=new Date(t);return function(t,n){void 0===n&&(n={});var r=n.timeZoneName||"short",i=t+"|"+r,s=e[i];return s||(s=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:r}),e[i]=s),s}(n,r).formatToParts(i)},a=function(e,n){for(var r=u(e,n),s=[],a=0;a<r.length;a+=1){var o=r[a],f=o.type,h=o.value,c=t[f];c>=0&&(s[c]=parseInt(h,10))}var d=s[3],l=24===d?0:d,m=s[0]+"-"+s[1]+"-"+s[2]+" "+l+":"+s[4]+":"+s[5]+":000",$=+e;return(i.utc(m).valueOf()-($-=$%1e3))/6e4},o=r.prototype;o.tz=function(t,e){void 0===t&&(t=s);var n=this.utcOffset(),r=this.toDate(),u=r.toLocaleString("en-US",{timeZone:t}),a=Math.round((r-new Date(u))/1e3/60),o=i(u).$set("millisecond",this.$ms).utcOffset(15*-Math.round(r.getTimezoneOffset()/15)-a,!0);if(e){var f=o.utcOffset();o=o.add(n-f,"minute")}return o.$x.$timezone=t,o},o.offsetName=function(t){var e=this.$x.$timezone||i.tz.guess(),n=u(this.valueOf(),e,{timeZoneName:t}).find((function(t){return"timezonename"===t.type.toLowerCase()}));return n&&n.value};var f=o.startOf;o.startOf=function(t,e){if(!this.$x||!this.$x.$timezone)return f.call(this,t,e);var n=i(this.format("YYYY-MM-DD HH:mm:ss:SSS"));return f.call(n,t,e).tz(this.$x.$timezone,!0)},i.tz=function(t,e,n){var r=n&&e,u=n||e||s,o=a(+i(),u);if("string"!=typeof t)return i(t).tz(u);var f=function(t,e,n){var r=t-60*e*1e3,i=a(r,n);if(e===i)return[r,e];var s=a(r-=60*(i-e)*1e3,n);return i===s?[r,i]:[t-60*Math.min(i,s)*1e3,Math.max(i,s)]}(i.utc(t,r).valueOf(),o,u),h=f[0],c=f[1],d=i(h).utcOffset(c);return d.$x.$timezone=u,d},i.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},i.tz.setDefault=function(t){s=t}}}();e.extend(l),e.extend($);const D=(t,n)=>e(t).tz(n,!0).toDate().getTime(),v=(t,e)=>{const n=t.toLocaleString("en-US",{timeZone:e});return new Date(n)},g=t=>e(t).utc(),M=t=>{const e=t.getTime(),n=t.getTimezoneOffset();return new Date(e+6e4*n)},y=(t,e)=>{if(!t)return e;if(!e)return t;const n=e.getHours(),r=e.getMinutes(),i=M(new Date(t));return i.setHours(n),i.setMinutes(r),i};exports.useDateFormatter=()=>({formatDate:s,formatDateTime:i,formatDateTimeWithRange:n,formatTime:u,formatTimeWithRange:r,formatDateShort:a,formatDateLong:o}),exports.useDateTransformer=()=>({getDateInTz:v,getDateInServiceAreaTz:D,getUTCDate:g,applyDateTimezone:M,combineDateAndTime:y});
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
var dayjs_min = {exports: {}};
(function (module, exports) {
!function(t,e){module.exports=e();}(commonjsGlobal,(function(){var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",f="month",h="quarter",c="year",d="date",$="Invalid Date",l=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|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,M={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("_")},m=function(t,e,n){var r=String(t);return !r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},g={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return (e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return -t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,f),s=n-i<0,u=e.clone().add(r+(s?-1:1),f);return +(-(r+(n-i)/(s?i-u:u-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return {M:f,y:c,w:o,d:a,D:d,h:u,m:s,s:i,ms:r,Q:h}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},D="en",v={};v[D]=M;var p=function(t){return t instanceof _},S=function(t,e,n){var r;if(!t)return D;if("string"==typeof t)v[t]&&(r=t),e&&(v[t]=e,r=t);else {var i=t.name;v[i]=t,r=i;}return !n&&r&&(D=r),r||!n&&D},w=function(t,e){if(p(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},O=g;O.l=S,O.i=p,O.w=function(t,e){return w(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=S(t.locale,null,!0),this.parse(t);}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(O.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match(l);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.$x=t.x||{},this.init();},m.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();},m.$utils=function(){return O},m.isValid=function(){return !(this.$d.toString()===$)},m.isSame=function(t,e){var n=w(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return w(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<w(t)},m.$g=function(t,e,n){return O.u(t)?this[e]:this.set(n,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,e){var n=this,r=!!O.u(e)||e,h=O.p(t),$=function(t,e){var i=O.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return r?i:i.endOf(a)},l=function(t,e){return O.w(n.toDate()[t].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},y=this.$W,M=this.$M,m=this.$D,g="set"+(this.$u?"UTC":"");switch(h){case c:return r?$(1,0):$(31,11);case f:return r?$(1,M):$(0,M+1);case o:var D=this.$locale().weekStart||0,v=(y<D?y+7:y)-D;return $(r?m-v:m+(6-v),M);case a:case d:return l(g+"Hours",0);case u:return l(g+"Minutes",1);case s:return l(g+"Seconds",2);case i:return l(g+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,!1)},m.$set=function(t,e){var n,o=O.p(t),h="set"+(this.$u?"UTC":""),$=(n={},n[a]=h+"Date",n[d]=h+"Date",n[f]=h+"Month",n[c]=h+"FullYear",n[u]=h+"Hours",n[s]=h+"Minutes",n[i]=h+"Seconds",n[r]=h+"Milliseconds",n)[o],l=o===a?this.$D+(e-this.$W):e;if(o===f||o===c){var y=this.clone().set(d,1);y.$d[$](l),y.init(),this.$d=y.set(d,Math.min(this.$D,y.daysInMonth())).$d;}else $&&this.$d[$](l);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[O.p(t)]()},m.add=function(r,h){var d,$=this;r=Number(r);var l=O.p(h),y=function(t){var e=w($);return O.w(e.date(e.date()+Math.round(t*r)),$)};if(l===f)return this.set(f,this.$M+r);if(l===c)return this.set(c,this.$y+r);if(l===a)return y(1);if(l===o)return y(7);var M=(d={},d[s]=e,d[u]=n,d[i]=t,d)[l]||1,m=this.$d.getTime()+r*M;return O.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||$;var r=t||"YYYY-MM-DDTHH:mm:ssZ",i=O.z(this),s=this.$H,u=this.$m,a=this.$M,o=n.weekdays,f=n.months,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].substr(0,s)},c=function(t){return O.s(s%12||12,t,"0")},d=n.meridiem||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r},l={YY:String(this.$y).slice(-2),YYYY:this.$y,M:a+1,MM:O.s(a+1,2,"0"),MMM:h(n.monthsShort,a,f,3),MMMM:h(f,a),D:this.$D,DD:O.s(this.$D,2,"0"),d:String(this.$W),dd:h(n.weekdaysMin,this.$W,o,2),ddd:h(n.weekdaysShort,this.$W,o,3),dddd:o[this.$W],H:String(s),HH:O.s(s,2,"0"),h:c(1),hh:c(2),a:d(s,u,!0),A:d(s,u,!1),m:String(u),mm:O.s(u,2,"0"),s:String(this.$s),ss:O.s(this.$s,2,"0"),SSS:O.s(this.$ms,3,"0"),Z:i};return r.replace(y,(function(t,e){return e||l[t]||i.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,d,$){var l,y=O.p(d),M=w(r),m=(M.utcOffset()-this.utcOffset())*e,g=this-M,D=O.m(this,M);return D=(l={},l[c]=D/12,l[f]=D,l[h]=D/3,l[o]=(g-m)/6048e5,l[a]=(g-m)/864e5,l[u]=g/n,l[s]=g/e,l[i]=g/t,l)[y]||g,$?D:O.a(D)},m.daysInMonth=function(){return this.endOf(f).$D},m.$locale=function(){return v[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=S(t,e,!0);return r&&(n.$L=r),n},m.clone=function(){return O.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},M}(),b=_.prototype;return w.prototype=b,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",f],["$y",c],["$D",d]].forEach((function(t){b[t[1]]=function(e){return this.$g(e,t[0],t[1])};})),w.extend=function(t,e){return t.$i||(t(e,_,w),t.$i=!0),w},w.locale=S,w.isDayjs=p,w.unix=function(t){return w(1e3*t)},w.en=v[D],w.Ls=v,w.p={},w}));
}(dayjs_min));
var dayjs = dayjs_min.exports;
const formatDateTimeWithRange = (date, options = {
minutesRange: 30,
}) => {
const start = dayjs(date);
const end = dayjs(date);
return `${start.format('MMM DD, hh:mm')} - ${end
.add(options.minutesRange, 'minute')
.format('hh:mm A')}`;
};
const formatTimeWithRange = (date, options = {
minutesRange: 30,
}) => {
const startTime = dayjs(date).format('hh:mm');
const endTime = dayjs(date)
.add(options.minutesRange, 'minute')
.format('hh:mm A');
return `${startTime} - ${endTime}`;
};
const formatDateTime = (date) => dayjs(date).format('MMM DD, hh:mm A');
const formatDate = (date) => dayjs(date).format('MMM DD, YYYY');
const formatTime = (date) => dayjs(date).format('hh:mm A');
const formatDateShort = (date) => dayjs(date).format('MMM DD');
const formatDateLong = (date) => dayjs(date).format('ddd MMM DD YYYY');
const formatISOWithoutTimezone = (date) => dayjs(date).format('YYYY-MM-DDTHH:mm');
const useDateFormatter = () => ({
formatDate,
formatDateTime,
formatDateTimeWithRange,
formatTime,
formatTimeWithRange,
formatDateShort,
formatDateLong,
formatISOWithoutTimezone,
});
function toInteger(dirtyNumber) {
if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
return NaN;
}
var number = Number(dirtyNumber);
if (isNaN(number)) {
return number;
}
return number < 0 ? Math.ceil(number) : Math.floor(number);
}
/**
* Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.
* They usually appear for dates that denote time before the timezones were introduced
* (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891
* and GMT+01:00:00 after that date)
*
* Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,
* which would lead to incorrect calculations.
*
* This function returns the timezone offset in milliseconds that takes seconds in account.
*/
function getTimezoneOffsetInMilliseconds(date) {
var utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
utcDate.setUTCFullYear(date.getFullYear());
return date.getTime() - utcDate.getTime();
}
/**
* Returns the [year, month, day, hour, minute, seconds] tokens of the provided
* `date` as it will be rendered in the `timeZone`.
*/
function tzTokenizeDate(date, timeZone) {
var dtf = getDateTimeFormat(timeZone);
return dtf.formatToParts ? partsOffset(dtf, date) : hackyOffset(dtf, date)
}
var typeToPos = {
year: 0,
month: 1,
day: 2,
hour: 3,
minute: 4,
second: 5,
};
function partsOffset(dtf, date) {
var formatted = dtf.formatToParts(date);
var filled = [];
for (var i = 0; i < formatted.length; i++) {
var pos = typeToPos[formatted[i].type];
if (pos >= 0) {
filled[pos] = parseInt(formatted[i].value, 10);
}
}
return filled
}
function hackyOffset(dtf, date) {
var formatted = dtf.format(date).replace(/\u200E/g, '');
var parsed = /(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(formatted);
// var [, fMonth, fDay, fYear, fHour, fMinute, fSecond] = parsed
// return [fYear, fMonth, fDay, fHour, fMinute, fSecond]
return [parsed[3], parsed[1], parsed[2], parsed[4], parsed[5], parsed[6]]
}
// Get a cached Intl.DateTimeFormat instance for the IANA `timeZone`. This can be used
// to get deterministic local date/time output according to the `en-US` locale which
// can be used to extract local time parts as necessary.
var dtfCache = {};
function getDateTimeFormat(timeZone) {
if (!dtfCache[timeZone]) {
// New browsers use `hourCycle`, IE and Chrome <73 does not support it and uses `hour12`
var testDateFormatted = new Intl.DateTimeFormat('en-US', {
hour12: false,
timeZone: 'America/New_York',
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
}).format(new Date('2014-06-25T04:00:00.123Z'));
var hourCycleSupported =
testDateFormatted === '06/25/2014, 00:00:00' ||
testDateFormatted === '‎06‎/‎25‎/‎2014‎ ‎00‎:‎00‎:‎00';
dtfCache[timeZone] = hourCycleSupported
? new Intl.DateTimeFormat('en-US', {
hour12: false,
timeZone: timeZone,
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
})
: new Intl.DateTimeFormat('en-US', {
hourCycle: 'h23',
timeZone: timeZone,
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
});
}
return dtfCache[timeZone]
}
var MILLISECONDS_IN_HOUR$1 = 3600000;
var MILLISECONDS_IN_MINUTE$1 = 60000;
var patterns$1 = {
timezone: /([Z+-].*)$/,
timezoneZ: /^(Z)$/,
timezoneHH: /^([+-])(\d{2})$/,
timezoneHHMM: /^([+-])(\d{2}):?(\d{2})$/
};
// Parse various time zone offset formats to an offset in milliseconds
function tzParseTimezone(timezoneString, date, isUtcDate) {
var token;
var absoluteOffset;
// Z
token = patterns$1.timezoneZ.exec(timezoneString);
if (token) {
return 0
}
var hours;
// ±hh
token = patterns$1.timezoneHH.exec(timezoneString);
if (token) {
hours = parseInt(token[2], 10);
if (!validateTimezone()) {
return NaN
}
absoluteOffset = hours * MILLISECONDS_IN_HOUR$1;
return token[1] === '+' ? -absoluteOffset : absoluteOffset
}
// ±hh:mm or ±hhmm
token = patterns$1.timezoneHHMM.exec(timezoneString);
if (token) {
hours = parseInt(token[2], 10);
var minutes = parseInt(token[3], 10);
if (!validateTimezone(hours, minutes)) {
return NaN
}
absoluteOffset = hours * MILLISECONDS_IN_HOUR$1 + minutes * MILLISECONDS_IN_MINUTE$1;
return token[1] === '+' ? -absoluteOffset : absoluteOffset
}
// IANA time zone
if (isValidTimezoneIANAString(timezoneString)) {
date = new Date(date || Date.now());
var utcDate = isUtcDate ? date : toUtcDate(date);
var offset = calcOffset(utcDate, timezoneString);
var fixedOffset = isUtcDate ? offset : fixOffset(date, offset, timezoneString);
return -fixedOffset
}
return 0
}
function toUtcDate(date) {
return new Date(
Date.UTC(
date.getFullYear(),
date.getMonth(),
date.getDate(),
date.getHours(),
date.getMinutes(),
date.getSeconds(),
date.getMilliseconds()
)
)
}
function calcOffset(date, timezoneString) {
var tokens = tzTokenizeDate(date, timezoneString);
var asUTC = Date.UTC(tokens[0], tokens[1] - 1, tokens[2], tokens[3] % 24, tokens[4], tokens[5]);
var asTS = date.getTime();
var over = asTS % 1000;
asTS -= over >= 0 ? over : 1000 + over;
return asUTC - asTS
}
function fixOffset(date, offset, timezoneString) {
var localTS = date.getTime();
// Our UTC time is just a guess because our offset is just a guess
var utcGuess = localTS - offset;
// Test whether the zone matches the offset for this ts
var o2 = calcOffset(new Date(utcGuess), timezoneString);
// If so, offset didn't change and we're done
if (offset === o2) {
return offset
}
// If not, change the ts by the difference in the offset
utcGuess -= o2 - offset;
// If that gives us the local time we want, we're done
var o3 = calcOffset(new Date(utcGuess), timezoneString);
if (o2 === o3) {
return o2
}
// If it's different, we're in a hole time. The offset has changed, but the we don't adjust the time
return Math.max(o2, o3)
}
function validateTimezone(hours, minutes) {
if (minutes != null && (minutes < 0 || minutes > 59)) {
return false
}
return true
}
function isValidTimezoneIANAString(timeZoneString) {
try {
Intl.DateTimeFormat(undefined, {timeZone: timeZoneString});
return true;
} catch (error) {
return false;
}
}
var MILLISECONDS_IN_HOUR = 3600000;
var MILLISECONDS_IN_MINUTE = 60000;
var DEFAULT_ADDITIONAL_DIGITS = 2;
var patterns = {
dateTimeDelimeter: /[T ]/,
plainTime: /:/,
timeZoneDelimeter: /[Z ]/i,
// year tokens
YY: /^(\d{2})$/,
YYY: [
/^([+-]\d{2})$/, // 0 additional digits
/^([+-]\d{3})$/, // 1 additional digit
/^([+-]\d{4})$/, // 2 additional digits
],
YYYY: /^(\d{4})/,
YYYYY: [
/^([+-]\d{4})/, // 0 additional digits
/^([+-]\d{5})/, // 1 additional digit
/^([+-]\d{6})/, // 2 additional digits
],
// date tokens
MM: /^-(\d{2})$/,
DDD: /^-?(\d{3})$/,
MMDD: /^-?(\d{2})-?(\d{2})$/,
Www: /^-?W(\d{2})$/,
WwwD: /^-?W(\d{2})-?(\d{1})$/,
HH: /^(\d{2}([.,]\d*)?)$/,
HHMM: /^(\d{2}):?(\d{2}([.,]\d*)?)$/,
HHMMSS: /^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,
// timezone tokens (to identify the presence of a tz)
timezone: /([Z+-].*| UTC|(?:[a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?))$/,
};
/**
* @name toDate
* @category Common Helpers
* @summary Convert the given argument to an instance of Date.
*
* @description
* Convert the given argument to an instance of Date.
*
* If the argument is an instance of Date, the function returns its clone.
*
* If the argument is a number, it is treated as a timestamp.
*
* If an argument is a string, the function tries to parse it.
* Function accepts complete ISO 8601 formats as well as partial implementations.
* ISO 8601: http://en.wikipedia.org/wiki/ISO_8601
* If the function cannot parse the string or the values are invalid, it returns Invalid Date.
*
* If the argument is none of the above, the function returns Invalid Date.
*
* **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
* All *date-fns* functions will throw `RangeError` if `options.additionalDigits` is not 0, 1, 2 or undefined.
*
* @param {Date|String|Number} argument - the value to convert
* @param {OptionsWithTZ} [options] - the object with options. See [Options]{@link https://date-fns.org/docs/Options}
* @param {0|1|2} [options.additionalDigits=2] - the additional number of digits in the extended year format
* @param {String} [options.timeZone=''] - used to specify the IANA time zone offset of a date String.
* @returns {Date} the parsed date in the local time zone
* @throws {TypeError} 1 argument required
* @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2
*
* @example
* // Convert string '2014-02-11T11:30:30' to date:
* var result = toDate('2014-02-11T11:30:30')
* //=> Tue Feb 11 2014 11:30:30
*
* @example
* // Convert string '+02014101' to date,
* // if the additional number of digits in the extended year format is 1:
* var result = toDate('+02014101', {additionalDigits: 1})
* //=> Fri Apr 11 2014 00:00:00
*/
function toDate(argument, dirtyOptions) {
if (arguments.length < 1) {
throw new TypeError('1 argument required, but only ' + arguments.length + ' present')
}
if (argument === null) {
return new Date(NaN)
}
var options = dirtyOptions || {};
var additionalDigits =
options.additionalDigits == null
? DEFAULT_ADDITIONAL_DIGITS
: toInteger(options.additionalDigits);
if (additionalDigits !== 2 && additionalDigits !== 1 && additionalDigits !== 0) {
throw new RangeError('additionalDigits must be 0, 1 or 2')
}
// Clone the date
if (
argument instanceof Date ||
(typeof argument === 'object' && Object.prototype.toString.call(argument) === '[object Date]')
) {
// Prevent the date to lose the milliseconds when passed to new Date() in IE10
return new Date(argument.getTime())
} else if (
typeof argument === 'number' ||
Object.prototype.toString.call(argument) === '[object Number]'
) {
return new Date(argument)
} else if (
!(
typeof argument === 'string' || Object.prototype.toString.call(argument) === '[object String]'
)
) {
return new Date(NaN)
}
var dateStrings = splitDateString(argument);
var parseYearResult = parseYear(dateStrings.date, additionalDigits);
var year = parseYearResult.year;
var restDateString = parseYearResult.restDateString;
var date = parseDate(restDateString, year);
if (isNaN(date)) {
return new Date(NaN)
}
if (date) {
var timestamp = date.getTime();
var time = 0;
var offset;
if (dateStrings.time) {
time = parseTime(dateStrings.time);
if (isNaN(time)) {
return new Date(NaN)
}
}
if (dateStrings.timezone || options.timeZone) {
offset = tzParseTimezone(dateStrings.timezone || options.timeZone, new Date(timestamp + time));
if (isNaN(offset)) {
return new Date(NaN)
}
} else {
// get offset accurate to hour in timezones that change offset
offset = getTimezoneOffsetInMilliseconds(new Date(timestamp + time));
offset = getTimezoneOffsetInMilliseconds(new Date(timestamp + time + offset));
}
return new Date(timestamp + time + offset)
} else {
return new Date(NaN)
}
}
function splitDateString(dateString) {
var dateStrings = {};
var array = dateString.split(patterns.dateTimeDelimeter);
var timeString;
if (patterns.plainTime.test(array[0])) {
dateStrings.date = null;
timeString = array[0];
} else {
dateStrings.date = array[0];
timeString = array[1];
dateStrings.timezone = array[2];
if (patterns.timeZoneDelimeter.test(dateStrings.date)) {
dateStrings.date = dateString.split(patterns.timeZoneDelimeter)[0];
timeString = dateString.substr(dateStrings.date.length, dateString.length);
}
}
if (timeString) {
var token = patterns.timezone.exec(timeString);
if (token) {
dateStrings.time = timeString.replace(token[1], '');
dateStrings.timezone = token[1];
} else {
dateStrings.time = timeString;
}
}
return dateStrings
}
function parseYear(dateString, additionalDigits) {
var patternYYY = patterns.YYY[additionalDigits];
var patternYYYYY = patterns.YYYYY[additionalDigits];
var token;
// YYYY or ±YYYYY
token = patterns.YYYY.exec(dateString) || patternYYYYY.exec(dateString);
if (token) {
var yearString = token[1];
return {
year: parseInt(yearString, 10),
restDateString: dateString.slice(yearString.length),
}
}
// YY or ±YYY
token = patterns.YY.exec(dateString) || patternYYY.exec(dateString);
if (token) {
var centuryString = token[1];
return {
year: parseInt(centuryString, 10) * 100,
restDateString: dateString.slice(centuryString.length),
}
}
// Invalid ISO-formatted year
return {
year: null,
}
}
function parseDate(dateString, year) {
// Invalid ISO-formatted year
if (year === null) {
return null
}
var token;
var date;
var month;
var week;
// YYYY
if (dateString.length === 0) {
date = new Date(0);
date.setUTCFullYear(year);
return date
}
// YYYY-MM
token = patterns.MM.exec(dateString);
if (token) {
date = new Date(0);
month = parseInt(token[1], 10) - 1;
if (!validateDate(year, month)) {
return new Date(NaN)
}
date.setUTCFullYear(year, month);
return date
}
// YYYY-DDD or YYYYDDD
token = patterns.DDD.exec(dateString);
if (token) {
date = new Date(0);
var dayOfYear = parseInt(token[1], 10);
if (!validateDayOfYearDate(year, dayOfYear)) {
return new Date(NaN)
}
date.setUTCFullYear(year, 0, dayOfYear);
return date
}
// yyyy-MM-dd or YYYYMMDD
token = patterns.MMDD.exec(dateString);
if (token) {
date = new Date(0);
month = parseInt(token[1], 10) - 1;
var day = parseInt(token[2], 10);
if (!validateDate(year, month, day)) {
return new Date(NaN)
}
date.setUTCFullYear(year, month, day);
return date
}
// YYYY-Www or YYYYWww
token = patterns.Www.exec(dateString);
if (token) {
week = parseInt(token[1], 10) - 1;
if (!validateWeekDate(year, week)) {
return new Date(NaN)
}
return dayOfISOWeekYear(year, week)
}
// YYYY-Www-D or YYYYWwwD
token = patterns.WwwD.exec(dateString);
if (token) {
week = parseInt(token[1], 10) - 1;
var dayOfWeek = parseInt(token[2], 10) - 1;
if (!validateWeekDate(year, week, dayOfWeek)) {
return new Date(NaN)
}
return dayOfISOWeekYear(year, week, dayOfWeek)
}
// Invalid ISO-formatted date
return null
}
function parseTime(timeString) {
var token;
var hours;
var minutes;
// hh
token = patterns.HH.exec(timeString);
if (token) {
hours = parseFloat(token[1].replace(',', '.'));
if (!validateTime(hours)) {
return NaN
}
return (hours % 24) * MILLISECONDS_IN_HOUR
}
// hh:mm or hhmm
token = patterns.HHMM.exec(timeString);
if (token) {
hours = parseInt(token[1], 10);
minutes = parseFloat(token[2].replace(',', '.'));
if (!validateTime(hours, minutes)) {
return NaN
}
return (hours % 24) * MILLISECONDS_IN_HOUR + minutes * MILLISECONDS_IN_MINUTE
}
// hh:mm:ss or hhmmss
token = patterns.HHMMSS.exec(timeString);
if (token) {
hours = parseInt(token[1], 10);
minutes = parseInt(token[2], 10);
var seconds = parseFloat(token[3].replace(',', '.'));
if (!validateTime(hours, minutes, seconds)) {
return NaN
}
return (hours % 24) * MILLISECONDS_IN_HOUR + minutes * MILLISECONDS_IN_MINUTE + seconds * 1000
}
// Invalid ISO-formatted time
return null
}
function dayOfISOWeekYear(isoWeekYear, week, day) {
week = week || 0;
day = day || 0;
var date = new Date(0);
date.setUTCFullYear(isoWeekYear, 0, 4);
var fourthOfJanuaryDay = date.getUTCDay() || 7;
var diff = week * 7 + day + 1 - fourthOfJanuaryDay;
date.setUTCDate(date.getUTCDate() + diff);
return date
}
// Validation functions
var DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
var DAYS_IN_MONTH_LEAP_YEAR = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
function isLeapYearIndex(year) {
return year % 400 === 0 || (year % 4 === 0 && year % 100 !== 0)
}
function validateDate(year, month, date) {
if (month < 0 || month > 11) {
return false
}
if (date != null) {
if (date < 1) {
return false
}
var isLeapYear = isLeapYearIndex(year);
if (isLeapYear && date > DAYS_IN_MONTH_LEAP_YEAR[month]) {
return false
}
if (!isLeapYear && date > DAYS_IN_MONTH[month]) {
return false
}
}
return true
}
function validateDayOfYearDate(year, dayOfYear) {
if (dayOfYear < 1) {
return false
}
var isLeapYear = isLeapYearIndex(year);
if (isLeapYear && dayOfYear > 366) {
return false
}
if (!isLeapYear && dayOfYear > 365) {
return false
}
return true
}
function validateWeekDate(year, week, day) {
if (week < 0 || week > 52) {
return false
}
if (day != null && (day < 0 || day > 6)) {
return false
}
return true
}
function validateTime(hours, minutes, seconds) {
if (hours != null && (hours < 0 || hours >= 25)) {
return false
}
if (minutes != null && (minutes < 0 || minutes >= 60)) {
return false
}
if (seconds != null && (seconds < 0 || seconds >= 60)) {
return false
}
return true
}
/**
* @name utcToZonedTime
* @category Time Zone Helpers
* @summary Get a date/time representing local time in a given time zone from the UTC date
*
* @description
* Returns a date instance with values representing the local time in the time zone
* specified of the UTC time from the date provided. In other words, when the new date
* is formatted it will show the equivalent hours in the target time zone regardless
* of the current system time zone.
*
* @param {Date|String|Number} date - the date with the relevant UTC time
* @param {String} timeZone - the time zone to get local time for, can be an offset or IANA time zone
* @param {OptionsWithTZ} [options] - the object with options. See [Options]{@link https://date-fns.org/docs/Options}
* @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate}
* @returns {Date} the new date with the equivalent time in the time zone
* @throws {TypeError} 2 arguments required
* @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2
*
* @example
* // In June 10am UTC is 6am in New York (-04:00)
* const result = utcToZonedTime('2014-06-25T10:00:00.000Z', 'America/New_York')
* //=> Jun 25 2014 06:00:00
*/
function utcToZonedTime(dirtyDate, timeZone, options) {
var date = toDate(dirtyDate, options);
var offsetMilliseconds = tzParseTimezone(timeZone, date, true) || 0;
var d = new Date(date.getTime() - offsetMilliseconds);
var zonedTime = new Date(
d.getUTCFullYear(),
d.getUTCMonth(),
d.getUTCDate(),
d.getUTCHours(),
d.getUTCMinutes(),
d.getUTCSeconds(),
d.getUTCMilliseconds()
);
return zonedTime
}
const getDateInServiceAreaTz = (date, timezone) => {
const localDate = new Date(date).getTime();
const localDateInTz = utcToZonedTime(date, timezone).getTime();
return localDate + localDate - localDateInTz;
};
const getZonedTime = (date, timezone) => utcToZonedTime(date, timezone);
const combineDateAndTime = (date, time) => {
if (!date)
return time;
if (!time)
return date;
const hours = time.getHours();
const minutes = time.getMinutes();
const newDate = new Date(date);
newDate.setHours(hours);
newDate.setMinutes(minutes);
return newDate;
};
const sanitizeDate = (date) => {
if (/^\d{4}/.test(date)) {
return new Date(date);
}
return new Date(date.replace(/-/g, '/'));
};
const useDateTransformer = () => ({
getDateInServiceAreaTz,
getZonedTime,
combineDateAndTime,
sanitizeDate,
});
exports.useDateFormatter = useDateFormatter;
exports.useDateTransformer = useDateTransformer;
//# sourceMappingURL=date-utils.umd.js.map

20

dist/lib/use-date-formatter.js

@@ -10,4 +10,4 @@ "use strict";

}) => {
const start = dayjs_1.default(date);
const end = dayjs_1.default(date);
const start = (0, dayjs_1.default)(date);
const end = (0, dayjs_1.default)(date);
return `${start.format('MMM DD, hh:mm')} - ${end

@@ -20,4 +20,4 @@ .add(options.minutesRange, 'minute')

}) => {
const startTime = dayjs_1.default(date).format('hh:mm');
const endTime = dayjs_1.default(date)
const startTime = (0, dayjs_1.default)(date).format('hh:mm');
const endTime = (0, dayjs_1.default)(date)
.add(options.minutesRange, 'minute')

@@ -27,7 +27,8 @@ .format('hh:mm A');

};
const formatDateTime = (date) => dayjs_1.default(date).format('MMM DD, hh:mm A');
const formatDate = (date) => dayjs_1.default(date).format('MMM DD, YYYY');
const formatTime = (date) => dayjs_1.default(date).format('hh:mm A');
const formatDateShort = (date) => dayjs_1.default(date).format('MMM DD');
const formatDateLong = (date) => dayjs_1.default(date).format('ddd MMM DD YYYY');
const formatDateTime = (date) => (0, dayjs_1.default)(date).format('MMM DD, hh:mm A');
const formatDate = (date) => (0, dayjs_1.default)(date).format('MMM DD, YYYY');
const formatTime = (date) => (0, dayjs_1.default)(date).format('hh:mm A');
const formatDateShort = (date) => (0, dayjs_1.default)(date).format('MMM DD');
const formatDateLong = (date) => (0, dayjs_1.default)(date).format('ddd MMM DD YYYY');
const formatISOWithoutTimezone = (date) => (0, dayjs_1.default)(date).format('YYYY-MM-DDTHH:mm');
const useDateFormatter = () => ({

@@ -41,4 +42,5 @@ formatDate,

formatDateLong,
formatISOWithoutTimezone,
});
exports.default = useDateFormatter;
//# sourceMappingURL=use-date-formatter.js.map
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const dayjs_1 = __importDefault(require("dayjs"));
const utc_1 = __importDefault(require("dayjs/plugin/utc"));
const timezone_1 = __importDefault(require("dayjs/plugin/timezone"));
dayjs_1.default.extend(utc_1.default);
dayjs_1.default.extend(timezone_1.default);
const getDateInServiceAreaTz = (date, timezone) => dayjs_1.default(date).tz(timezone, true).toDate().getTime();
const getDateInTz = (date, timezone) => {
const formattedDate = date.toLocaleString('en-US', {
timeZone: timezone,
});
return new Date(formattedDate);
exports.sanitizeDate = void 0;
const date_fns_tz_1 = require("date-fns-tz");
const getDateInServiceAreaTz = (date, timezone) => {
const localDate = new Date(date).getTime();
const localDateInTz = (0, date_fns_tz_1.utcToZonedTime)(date, timezone).getTime();
return localDate + localDate - localDateInTz;
};
const getUTCDate = (date) => dayjs_1.default(date).utc();
const applyDateTimezone = (date) => {
const dateTimeValue = date.getTime();
const timezoneOffset = date.getTimezoneOffset();
const hoursTimeValue = timezoneOffset * 60000;
return new Date(dateTimeValue + hoursTimeValue);
};
const getZonedTime = (date, timezone) => (0, date_fns_tz_1.utcToZonedTime)(date, timezone);
const combineDateAndTime = (date, time) => {

@@ -32,3 +18,3 @@ if (!date)

const minutes = time.getMinutes();
const newDate = applyDateTimezone(new Date(date));
const newDate = new Date(date);
newDate.setHours(hours);

@@ -38,10 +24,16 @@ newDate.setMinutes(minutes);

};
const sanitizeDate = (date) => {
if (/^\d{4}/.test(date)) {
return new Date(date);
}
return new Date(date.replace(/-/g, '/'));
};
exports.sanitizeDate = sanitizeDate;
const useDateTransformer = () => ({
getDateInTz,
getDateInServiceAreaTz,
getUTCDate,
applyDateTimezone,
getZonedTime,
combineDateAndTime,
sanitizeDate: exports.sanitizeDate,
});
exports.default = useDateTransformer;
//# sourceMappingURL=use-date-transformer.js.map

@@ -15,3 +15,4 @@ import { Dayjs } from 'dayjs';

formatDateLong: (date: Dayjs | Date) => string;
formatISOWithoutTimezone: (date: Date) => string;
};
export default useDateFormatter;

@@ -1,9 +0,8 @@

import dayjs from 'dayjs';
export declare const sanitizeDate: (date: string) => Date;
declare const useDateTransformer: () => {
getDateInTz: (date: Date, timezone: string) => Date;
getDateInServiceAreaTz: (date: number, timezone: string) => number;
getUTCDate: (date: Date) => dayjs.Dayjs;
applyDateTimezone: (date: Date) => Date;
getZonedTime: (date: Date | number | string, timezone: string) => Date;
combineDateAndTime: (date?: Date | undefined, time?: Date | undefined) => Date | undefined;
sanitizeDate: (date: string) => Date;
};
export default useDateTransformer;
{
"name": "@drivekyte/date-utils",
"version": "1.0.1",
"version": "2.0.0",
"description": "",

@@ -38,30 +38,6 @@ "keywords": [],

},
"jest": {
"transform": {
".(ts|tsx)": "ts-jest"
},
"testEnvironment": "node",
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js"
],
"coveragePathIgnorePatterns": [
"/node_modules/",
"/test/"
],
"coverageThreshold": {
"global": {
"branches": 90,
"functions": 95,
"lines": 95,
"statements": 95
}
},
"collectCoverageFrom": [
"src/*.{js,ts}"
]
},
"devDependencies": {
"@babel/preset-env": "^7.15.0",
"@babel/preset-react": "^7.14.5",
"@babel/preset-typescript": "^7.15.0",
"@drivekyte/eslint-config": "^5.1.1",

@@ -71,4 +47,5 @@ "@drivekyte/prettier-config": "^4.0.0",

"@rollup/plugin-node-resolve": "^13.0.4",
"@types/jest": "^26.0.24",
"@types/node": "^16.4.2",
"@testing-library/react-hooks": "^7.0.1",
"@types/jest": "^27.0.2",
"@types/node": "^16.6.2",
"audit-ci": "^3.1.1",

@@ -80,3 +57,3 @@ "colors": "^1.4.0",

"husky": "^4.3.8",
"jest": "^26.0.24",
"jest": "^27.3.1",
"jest-config": "^27.0.6",

@@ -86,14 +63,21 @@ "lint-staged": "^10.5.3",

"prompt": "^1.1.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-test-renderer": "^17.0.2",
"regenerator-runtime": "^0.13.9",
"replace-in-file": "^6.2.0",
"rimraf": "^3.0.2",
"rollup": "^2.53.3",
"rollup": "^2.56.2",
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.30.0",
"semantic-release": "^17.4.4",
"semantic-release": "^17.4.5",
"shelljs": "^0.8.4",
"ts-jest": "^27.0.4",
"ts-node": "^10.0.1",
"ts-jest": "^27.0.5",
"ts-node": "^10.2.1",
"typescript": "^4.1.3"
},
"resolutions": {
"ansi-regex": "5.0.1",
"json-schema": "0.4.0"
},
"husky": {

@@ -115,5 +99,11 @@ "hooks": {

},
"jest": {
"testEnvironment": "jsdom",
"globalSetup": "<rootDir>/jest/global-setup.js"
},
"dependencies": {
"dayjs": "^1.10.6"
"dayjs": "^1.10.6",
"date-fns": "^2.26.0",
"date-fns-tz": "^1.1.6"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc