datetick 1.0.0

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.
@@ -0,0 +1 @@
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).datetick={})}(this,function(e){"use strict";const t=(e,t)=>new Date(Date.UTC(e,t+1,0)).getUTCDate(),r=(e,t)=>{if(Number.isNaN(e.getTime()))return{year:Number.NaN,month:Number.NaN,day:Number.NaN,hour:Number.NaN,minute:Number.NaN,second:Number.NaN,millisecond:Number.NaN,weekday:Number.NaN};const r=new Intl.DateTimeFormat("en-US",{timeZone:t,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),s={};for(const t of r.formatToParts(e))"literal"!==t.type&&(s[t.type]=Number(t.value));const a=new Date(Date.UTC(s.year,s.month-1,s.day)).getUTCDay();return{year:s.year,month:s.month-1,day:s.day,hour:s.hour,minute:s.minute,second:s.second,millisecond:e.getMilliseconds(),weekday:a}},s=(e,t)=>{const s=r(e,t);return Date.UTC(s.year,s.month,s.day,s.hour,s.minute,s.second,s.millisecond)-e.getTime()},a=(e,t)=>{const r=Date.UTC(e.year,e.month,e.day,e.hour,e.minute,e.second,e.millisecond),a=s(new Date(r),t);let n=r-a;const i=s(new Date(n),t);return i!==a&&(n=r-i),new Date(n)},n=new Map,i=new Map,o=(e,t)=>{const r=`${e} ${t}`;let s=n.get(r);if(!s){const a=new Intl.DateTimeFormat(e,{month:t,timeZone:"UTC"});s=Array.from({length:12},(e,t)=>a.format(new Date(Date.UTC(2021,t,15)))),n.set(r,s)}return s},h=(e,t)=>{const r=`${e} ${t}`;let s=i.get(r);if(!s){const a=new Intl.DateTimeFormat(e,{weekday:t,timeZone:"UTC"});s=Array.from({length:7},(e,t)=>a.format(new Date(Date.UTC(2020,5,7+t)))),i.set(r,s)}return s},u=new Map,d=e=>{const t=u.get(e);if(t)return t;const r=new Intl.DateTimeFormat(e,{hour:"numeric",hour12:!0,timeZone:"UTC"}),s=e=>r.formatToParts(new Date(Date.UTC(2020,0,1,e))).find(e=>"dayPeriod"===e.type)?.value??"",a={am:s(6)||"AM",pm:s(18)||"PM"};return u.set(e,a),a},m=e=>{const{am:t,pm:r}=d(e),s=t=>[t.toLocaleUpperCase(e),t.toLocaleLowerCase(e)];return Array.from(new Set([...s(r),...s(t)])).filter(Boolean).sort((e,t)=>t.length-e.length).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|")},l={hour:"numeric",minute:"2-digit"},c={LT:{time:l},LTS:{time:{hour:"numeric",minute:"2-digit",second:"2-digit"}},L:{date:{year:"numeric",month:"2-digit",day:"2-digit"}},l:{date:{year:"numeric",month:"numeric",day:"numeric"}},LL:{date:{year:"numeric",month:"long",day:"numeric"}},ll:{date:{year:"numeric",month:"short",day:"numeric"}},LLL:{date:{year:"numeric",month:"long",day:"numeric"},time:l},lll:{date:{year:"numeric",month:"short",day:"numeric"},time:l},LLLL:{date:{weekday:"long",year:"numeric",month:"long",day:"numeric"},time:l},llll:{date:{weekday:"short",year:"numeric",month:"short",day:"numeric"},time:l}},y=new Map,w={numeric:"M","2-digit":"MM",short:"MMM",long:"MMMM"},f={narrow:"dd",short:"ddd",long:"dddd"},M={year:e=>"2-digit"===e.year?"YY":"YYYY",month:e=>w[e.month??"numeric"]??"MMMM",day:e=>"2-digit"===e.day?"DD":"D",weekday:e=>f[e.weekday??"long"]??"dddd",hour:(e,t)=>t?"h":"HH",minute:()=>"mm",second:()=>"ss",dayPeriod:()=>"A"},g=(e,t)=>{const r=new Intl.DateTimeFormat(e,{timeZone:"UTC",...t}),s=r.resolvedOptions().hour12??!1,a=new Date(Date.UTC(2020,0,2,3,4,5));return r.formatToParts(a).map(e=>{const r=M[e.type];return r?r(t,s):`[${e.value.replace(/[\u00a0\u202f]/g," ")}]`})},D={LTS:"h:mm:ss A",LT:"h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A",LLL:"MMMM D, YYYY h:mm A",LL:"MMMM D, YYYY",L:"MM/DD/YYYY",llll:"ddd, MMM D, YYYY h:mm A",lll:"MMM D, YYYY h:mm A",ll:"MMM D, YYYY",l:"M/D/YYYY"},p=["YYYY","MMMM","dddd","LLLL","llll","MMM","ddd","SSS","LLL","LTS","lll","YY","MM","DD","dd","HH","hh","mm","ss","ZZ","Do","kk","ww","wo","WW","Wo","LL","LT","ll","M","D","d","H","h","m","s","A","a","Z","Q","k","X","x","w","W","L","l"],k=(e,t)=>e in D?t?((e,t)=>{const r=`${t} ${e}`,s=y.get(r);if(s)return s;const a=c[e],n=[];return a.date&&n.push(...g(t,a.date)),a.date&&a.time&&n.push("[ ]"),a.time&&n.push(...g(t,a.time)),y.set(r,n),n})(e,t):T(D[e]):[e],b=(e,t)=>{const r=[];let s=0;for(;s<e.length;){const a="["===e[s]?e.indexOf("]",s):-1;if(-1!==a){r.push(e.slice(s,a+1)),s=a+1;continue}const n=t.find(t=>e.startsWith(t,s));n?(r.push(n),s+=n.length):(r.push(e[s]),s+=1)}return r},T=(e,t)=>b(e,p).flatMap(e=>k(e,t)),_={millisecond:1,second:1e3,minute:6e4,hour:36e5,date:864e5,day:864e5,week:6048e5,month:2592e6,quarter:7776e6,year:31536e6},S=e=>{const t=_[e];if(null==t)throw new Error(`Invalid duration unit: ${e}`);return t},Y=["YYYY","SSS","YY","MM","DD","HH","mm","ss","Y","M","D","H","m","s"],C=/^([+-])?P(?:(\d+(?:[.,]\d+)?)Y)?(?:(\d+(?:[.,]\d+)?)M)?(?:(\d+(?:[.,]\d+)?)W)?(?:(\d+(?:[.,]\d+)?)D)?(?:T(?:(\d+(?:[.,]\d+)?)H)?(?:(\d+(?:[.,]\d+)?)M)?(?:(\d+(?:[.,]\d+)?)S)?)?$/;class L{_locale;_ms;constructor(e,t,r="en"){this._locale=r,this._ms="string"==typeof e?(e=>{const t=C.exec(e.trim());if(!t||!t.slice(2).some(Boolean))throw new Error(`Invalid ISO 8601 duration: "${e}"`);const r=e=>e?Number.parseFloat(e.replace(",",".")):0,s=r(t[2])*_.year+r(t[3])*_.month+r(t[4])*_.week+r(t[5])*_.day+r(t[6])*_.hour+r(t[7])*_.minute+r(t[8])*_.second;return"-"===t[1]?-s:s})(e):"number"==typeof e?e*(t?S(t):1):e instanceof L?e.valueOf():e&&"object"==typeof e?(e.years??0)*_.year+(e.months??0)*_.month+(e.weeks??0)*_.week+(e.days??0)*_.day+(e.hours??0)*_.hour+(e.minutes??0)*_.minute+(e.seconds??0)*_.second+(e.milliseconds??0):0}static isDuration(e){return e instanceof L}add(e,t="millisecond"){return new L(this._ms+e*S(t),void 0,this._locale)}as(e){return this._ms/S(e)}asDays(){return this._ms/_.day}asHours(){return this._ms/_.hour}asMilliseconds(){return this._ms}asMinutes(){return this._ms/_.minute}asMonths(){return this._ms/_.month}asSeconds(){return this._ms/_.second}asWeeks(){return this._ms/_.week}asYears(){return this._ms/_.year}days(){return this.components().days}format(e="HH:mm:ss"){const t=this._ms<0?"-":"",r=this.absComponents(),s=e=>String(e).padStart(2,"0"),a={YYYY:String(r.years).padStart(4,"0"),YY:s(r.years%100),Y:String(r.years),MM:s(r.months),M:String(r.months),DD:s(r.days),D:String(r.days),HH:s(r.hours),H:String(r.hours),mm:s(r.minutes),m:String(r.minutes),ss:s(r.seconds),s:String(r.seconds),SSS:String(r.milliseconds).padStart(3,"0")};return t+b(e,Y).map(e=>e.startsWith("[")&&e.endsWith("]")?e.slice(1,-1):e in a?a[e]:e).join("")}get(e){const t=this.components();switch(e){case"year":return t.years;case"quarter":return Math.trunc(t.months/3);case"month":return t.months;case"week":return Math.trunc(t.days/7);case"date":case"day":return t.days;case"hour":return t.hours;case"minute":return t.minutes;case"second":return t.seconds;case"millisecond":return t.milliseconds;default:throw new Error(`Invalid duration unit: ${e}`)}}hours(){return this.components().hours}humanize(e=!1){const t=Math.abs(this._ms)/1e3,r=t/60,s=r/60,a=s/24;let n,i;if(t<45?(n="second",i=Math.round(t)):r<45?(n="minute",i=Math.round(r)):s<22?(n="hour",i=Math.round(s)):a<26?(n="day",i=Math.round(a)):a/30<11?(n="month",i=Math.round(a/30)):(n="year",i=Math.round(a/365)),e){const e=this._ms<0?-i:i;return new Intl.RelativeTimeFormat(this._locale,{numeric:"auto"}).format(e,n)}return new Intl.NumberFormat(this._locale,{style:"unit",unit:n,unitDisplay:"long"}).format(i)}milliseconds(){return this.components().milliseconds}minutes(){return this.components().minutes}months(){return this.components().months}seconds(){return this.components().seconds}subtract(e,t="millisecond"){return this.add(-e,t)}toISOString(){const e=this.components(),t=this._ms<0?"-":"",r=(e,t)=>e?`${Math.abs(e)}${t}`:"",s=`${r(e.years,"Y")}${r(e.months,"M")}${r(e.days,"D")}`,a=Math.abs(e.seconds)+Math.abs(e.milliseconds)/1e3,n=`${r(e.hours,"H")}${r(e.minutes,"M")}${a?`${a}S`:""}`;return s||n?`${t}P${s}${n?`T${n}`:""}`:"P0D"}toJSON(){return this.toISOString()}valueOf(){return this._ms}years(){return this.components().years}absComponents(){const e=this.components();return{years:Math.abs(e.years),months:Math.abs(e.months),weeks:Math.abs(e.weeks),days:Math.abs(e.days),hours:Math.abs(e.hours),minutes:Math.abs(e.minutes),seconds:Math.abs(e.seconds),milliseconds:Math.abs(e.milliseconds)}}components(){const e=this._ms<0?-1:1;let t=Math.abs(this._ms);const r=Math.floor(t/_.year);t-=r*_.year;const s=Math.floor(t/_.month);t-=s*_.month;const a=Math.floor(t/_.day);t-=a*_.day;const n=Math.floor(t/_.hour);t-=n*_.hour;const i=Math.floor(t/_.minute);t-=i*_.minute;const o=Math.floor(t/_.second);return t-=o*_.second,{years:r*e,months:s*e,weeks:0,days:a*e,hours:n*e,minutes:i*e,seconds:o*e,milliseconds:t*e}}}class N{_date;_locale;_ordinal;_timezone;_weekStartsOn;constructor(e="en",t=N.guessTimezone(),r,s=0,a){this._locale=e,this._timezone=t,this._weekStartsOn=(s%7+7)%7,this._ordinal=a,this._date=null==r?new Date:N.resolveInput(r,t)}static duration(e,t,r="en"){return new L(e,t,r)}static guessTimezone(){return Intl.DateTimeFormat().resolvedOptions().timeZone}static isDateTick(e){return e instanceof N}static isValid(e){const t=N.resolveInput(e);return!Number.isNaN(t.getTime())}static max(...e){const t=Math.max(...e.map(e=>N.resolveInput(e).getTime()));return new Date(t)}static min(...e){const t=Math.min(...e.map(e=>N.resolveInput(e).getTime()));return new Date(t)}static parse(e,r,s="en",n=N.guessTimezone()){const i={year:1970,month:0,day:1,hour:0,minute:0,second:0,millisecond:0};let h=!1,u=!1,l=null,c="^";const y=[],w=(e,t,r)=>e===t?"(\\d{2})":r,f=()=>new Error(`Unable to parse "${e}" with pattern "${r}"`),M=(e,t,r)=>{if(!Number.isInteger(e)||e<t||e>r)throw f()};for(const e of T(r,s))switch(e){case"YYYY":c+="(\\d{4})",y.push(e=>i.year=Number(e));break;case"YY":c+="(\\d{2})",y.push(e=>i.year=2e3+Number(e));break;case"MMMM":case"MMM":{const t=o(s,"MMMM"===e?"long":"short");c+=`(${[...t].sort((e,t)=>t.length-e.length).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|")})`,y.push(e=>{const r=e.toLocaleLowerCase(s),a=t.findIndex(e=>e.toLocaleLowerCase(s)===r);if(a<0)throw f();i.month=a});break}case"MM":case"M":c+=w(e,"MM","(\\d{1,2})"),y.push(e=>{const t=Number(e);M(t,1,12),i.month=t-1});break;case"DD":case"D":c+=w(e,"DD","(\\d{1,2})"),y.push(e=>{const t=Number(e);M(t,1,31),i.day=t});break;case"HH":case"H":c+=w(e,"HH","(\\d{1,2})"),y.push(e=>{const t=Number(e);M(t,0,23),i.hour=t});break;case"hh":case"h":c+=w(e,"hh","(\\d{1,2})"),y.push(e=>{const t=Number(e);M(t,1,12),i.hour=t});break;case"mm":case"m":c+=w(e,"mm","(\\d{1,2})"),y.push(e=>{const t=Number(e);M(t,0,59),i.minute=t});break;case"ss":case"s":c+=w(e,"ss","(\\d{1,2})"),y.push(e=>{const t=Number(e);M(t,0,59),i.second=t});break;case"SSS":c+="(\\d{3})",y.push(e=>i.millisecond=Number(e));break;case"kk":case"k":c+=w(e,"kk","(\\d{1,2})"),y.push(e=>{const t=Number(e);M(t,1,24),i.hour=t%24});break;case"Do":c+="(\\d{1,2})(?:st|nd|rd|th)",y.push(e=>{const t=Number(e);M(t,1,31),i.day=t});break;case"A":case"a":c+=`(${m(s)})`,y.push(e=>{u=!0,h=e.toLocaleLowerCase(s)===d(s).pm.toLocaleLowerCase(s)});break;case"X":c+="(-?\\d{1,16})",y.push(e=>l=1e3*Number(e));break;case"x":c+="(-?\\d{1,16})",y.push(e=>l=Number(e));break;case"Q":case"w":case"ww":case"wo":case"W":case"WW":case"Wo":c+="(\\d{1,2})(?:st|nd|rd|th)?",y.push(()=>{});break;default:c+=(e.startsWith("[")&&e.endsWith("]")?e.slice(1,-1):e).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}c+="$";const g=new RegExp(c,"i").exec(e.trim());if(!g)throw f();if(y.forEach((e,t)=>e(g[t+1])),null!==l)return new N(s,n,new Date(l));if(u&&(h&&i.hour<12&&(i.hour+=12),h||12!==i.hour||(i.hour=0)),i.day>t(i.year,i.month))throw f();return new N(s,n,a(i,n))}static inputParts(e){return Array.isArray(e)?{year:e[0],month:e[1],day:e[2],hour:e[3]??0,minute:e[4]??0,second:e[5]??0,millisecond:e[6]??0}:{year:e.year,month:e.month,day:e.date,hour:e.hour??0,minute:e.minute??0,second:e.second??0,millisecond:e.millisecond??0}}static resolveInput(e,t=N.guessTimezone()){return e instanceof N?e.toDate():e instanceof Date?new Date(e.getTime()):"string"==typeof e||"number"==typeof e?new Date(e):a(N.inputParts(e),t)}add(e,t){switch(t){case"millisecond":return this.withDate(new Date(this._date.getTime()+e));case"second":return this.withDate(new Date(this._date.getTime()+1e3*e));case"minute":return this.withDate(new Date(this._date.getTime()+6e4*e));case"hour":return this.withDate(new Date(this._date.getTime()+36e5*e));case"date":case"day":return this.rebuild({day:this.parts().day+e});case"week":return this.rebuild({day:this.parts().day+7*e});case"month":return this.addMonths(e);case"quarter":return this.addMonths(3*e);case"year":return this.addMonths(12*e);default:return this.clone()}}calendar(e=new Date,t={}){const r=this.diffCalendar(e,"day"),s=r<-6?"sameElse":r<-1?"lastWeek":-1===r?"lastDay":0===r?"sameDay":1===r?"nextDay":r<7?"nextWeek":"sameElse",a=t[s]??{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"}[s];return"function"==typeof a?a(this):this.formatPattern(a)}calendarMonth(e={}){const s=!1===e.selected?null:r(void 0===e.selected?this._date:this.toComparable(e.selected),this._timezone),a=this.rebuild({day:1}).startOf("day"),n=a.parts(),i=(n.weekday-this._weekStartsOn+7)%7,o=t(n.year,n.month),h=7*Math.ceil((i+o)/7),u=a.subtract(i,"day"),d=new N(this._locale,this._timezone,new Date,this._weekStartsOn).parts(),m=new Intl.DateTimeFormat(this._locale,{month:"long",year:"numeric",timeZone:this._timezone}).format(a.toDate()),l=Array.from({length:7},(e,t)=>{const r=(this._weekStartsOn+t)%7,s=new Date(Date.UTC(2020,5,7+r));return{day:r,isoDay:0===r?7:r,long:new Intl.DateTimeFormat(this._locale,{weekday:"long",timeZone:"UTC"}).format(s),short:new Intl.DateTimeFormat(this._locale,{weekday:"short",timeZone:"UTC"}).format(s),narrow:new Intl.DateTimeFormat(this._locale,{weekday:"narrow",timeZone:"UTC"}).format(s)}}),c=Array.from({length:h},(t,r)=>{const a=u.add(r,"day"),i=a.parts();return{value:a,isoDate:a.formatPattern("YYYY-MM-DD"),formatted:(o=a,null==e.dateFormat?o.format({year:"numeric",month:"2-digit",day:"2-digit"}):"function"==typeof e.dateFormat?e.dateFormat(o):"string"==typeof e.dateFormat?o.formatPattern(e.dateFormat):o.format(e.dateFormat)),year:i.year,month:i.month,date:i.day,day:i.weekday,isoDay:0===i.weekday?7:i.weekday,isCurrentMonth:i.year===n.year&&i.month===n.month,isToday:i.year===d.year&&i.month===d.month&&i.day===d.day,isSelected:Boolean(s&&i.year===s.year&&i.month===s.month&&i.day===s.day)};var o});return{year:n.year,month:n.month,label:m,weekdays:l,days:c,weeks:Array.from({length:c.length/7},(e,t)=>c.slice(7*t,7*t+7))}}clone(){return this.withDate(this._date)}date(e){return null==e?this.parts().day:this.rebuild({day:e})}dates(e){return null==e?this.date():this.date(e)}day(e){const t=this.parts();return null==e?t.weekday:this.rebuild({day:t.day-t.weekday+e})}dayOfYear(e){if(null==e){const e=this.parts(),t=Date.UTC(e.year,0,1),r=Date.UTC(e.year,e.month,e.day);return Math.round((r-t)/864e5)+1}return this.rebuild({month:0,day:e})}days(e){return null==e?this.day():this.day(e)}daysInMonth(){const e=this.parts();return t(e.year,e.month)}diff(e,t="millisecond",r=!1){const s=this.toComparable(e),a=this._date.getTime()-s.getTime(),n=e=>r?e:Math.trunc(e);switch(t){case"millisecond":default:return a;case"second":return n(a/1e3);case"minute":return n(a/6e4);case"hour":return n(a/36e5);case"date":case"day":return n(a/864e5);case"week":return n(a/6048e5);case"month":return r?this.preciseCalendarDiff(s,1):this.wholeMonthDiff(s,1);case"quarter":return r?this.preciseCalendarDiff(s,3):this.wholeMonthDiff(s,3);case"year":return r?this.preciseCalendarDiff(s,12):this.wholeMonthDiff(s,12)}}diffCalendar(e,t="day"){const r=this.withDate(this.toComparable(e));switch(t){case"date":case"day":return this.calendarDayNumber()-r.calendarDayNumber();case"week":return Math.trunc((this.startOf("week").calendarDayNumber()-r.startOf("week").calendarDayNumber())/7);case"month":{const e=this.parts(),t=r.parts();return 12*(e.year-t.year)+(e.month-t.month)}case"quarter":{const e=this.parts(),t=r.parts();return 4*(e.year-t.year)+(Math.floor(e.month/3)-Math.floor(t.month/3))}case"year":return this.parts().year-r.parts().year;default:return Number.NaN}}endOf(e){if("millisecond"===e)return this.clone();const t=this.startOf(e).add(1,e);return this.withDate(new Date(t.valueOf()-1))}format(e){const t="string"==typeof e?this.getPreset(e):e;return new Intl.DateTimeFormat(this._locale,{timeZone:this._timezone,...t}).format(this._date)}formatPattern(e){const t=this.parts(),r=e=>String(e).padStart(2,"0"),s=e=>new Intl.DateTimeFormat(this._locale,{timeZone:this._timezone,...e}).format(this._date),a=t.hour%12==0?12:t.hour%12,n=0===t.hour?24:t.hour,i=d(this._locale),o=t.hour<12?i.am:i.pm,h={YYYY:String(t.year).padStart(4,"0"),YY:r(t.year%100),MMMM:s({month:"long"}),MMM:s({month:"short"}),MM:r(t.month+1),M:String(t.month+1),Do:this.ordinal(),DD:r(t.day),D:String(t.day),dddd:s({weekday:"long"}),ddd:s({weekday:"short"}),dd:s({weekday:"narrow"}),d:String(t.weekday),HH:r(t.hour),H:String(t.hour),hh:r(a),h:String(a),kk:r(n),k:String(n),mm:r(t.minute),m:String(t.minute),SSS:String(t.millisecond).padStart(3,"0"),ss:r(t.second),s:String(t.second),A:o,a:o.toLocaleLowerCase(this._locale),Q:String(this.quarter()),ww:r(this.week()),w:String(this.week()),wo:this.ordinalFor(this.week()),WW:r(this.isoWeek()),W:String(this.isoWeek()),Wo:this.ordinalFor(this.isoWeek()),X:String(this.unix()),x:String(this.valueOf()),Z:this.offsetString(!0),ZZ:this.offsetString(!1)};return T(e,this._locale).map(e=>e.startsWith("[")&&e.endsWith("]")?e.slice(1,-1):e in h?h[e]:e).join("")}from(e,t=!1){const r=this._date.getTime()-this.toComparable(e).getTime(),s=N.duration(r,"millisecond",this._locale);return t?s.humanize():s.humanize(!0)}fromNow(e=!1){return this.from(new Date,e)}get(e){switch(e){case"millisecond":return this.millisecond();case"second":return this.second();case"minute":return this.minute();case"hour":return this.hour();case"date":return this.date();case"day":return this.day();case"week":return this.week();case"month":return this.month();case"quarter":return this.quarter();case"year":return this.year();case"dayOfYear":return this.dayOfYear();case"isoDay":return this.isoDay();case"isoWeek":return this.isoWeek();case"isoWeekYear":return this.isoWeekYear();case"isoWeeksInYear":return this.isoWeeksInYear();case"weekYear":return this.weekYear();case"weekday":return this.weekday();case"weeksInYear":return this.weeksInYear();case"daysInMonth":return this.daysInMonth();default:return Number.NaN}}hour(e){return null==e?this.parts().hour:this.rebuild({hour:e})}hours(e){return null==e?this.hour():this.hour(e)}isAfter(e){return this._date.getTime()>this.toComparable(e).getTime()}isBefore(e){return this._date.getTime()<this.toComparable(e).getTime()}isBetween(e,t,r=!1){const s=this._date.getTime(),a=this.toComparable(e).getTime(),n=this.toComparable(t).getTime(),i="boolean"==typeof r?r?"[]":"()":r,o="["===i[0]?s>=a:s>a,h="]"===i[1]?s<=n:s<n;return o&&h}isLeapYear(){const e=this.parts().year;return e%4==0&&e%100!=0||e%400==0}isSame(e,t){const r=this.toComparable(e);return t?this.startOf(t).valueOf()===this.withDate(r).startOf(t).valueOf():this._date.getTime()===r.getTime()}isSameOrAfter(e,t){return this.isSame(e,t)||this.isAfter(e)}isSameOrBefore(e,t){return this.isSame(e,t)||this.isBefore(e)}isToday(){return 0===this.diffCalendar(new Date,"day")}isTomorrow(){return 1===this.diffCalendar(new Date,"day")}isValid(){return N.isValid(this._date)}isYesterday(){return-1===this.diffCalendar(new Date,"day")}isoDay(){const e=this.parts().weekday;return 0===e?7:e}isoWeek(){const e=this.isoThursday(),t=new Date(Date.UTC(e.getUTCFullYear(),0,1));return Math.ceil(((e.getTime()-t.getTime())/864e5+1)/7)}isoWeekYear(){return this.weekYear()}isoWeeksInYear(){return this.weeksInYearBy(e=>e.isoWeek())}local(){return this.withTimezone(N.guessTimezone())}locale(){return this._locale}localeData(){const e=this._locale,t=d(e);return{months:()=>o(e,"long"),monthsShort:()=>o(e,"short"),weekdays:()=>h(e,"long"),weekdaysShort:()=>h(e,"short"),weekdaysMin:()=>h(e,"narrow"),firstDayOfWeek:()=>this._weekStartsOn,meridiems:()=>({...t}),meridiem:(r,s=!1)=>{const a=r<12?t.am:t.pm;return s?a.toLocaleLowerCase(e):a},ordinal:e=>this.ordinalFor(e)}}millisecond(e){return null==e?this.parts().millisecond:this.rebuild({millisecond:e})}milliseconds(e){return null==e?this.millisecond():this.millisecond(e)}minute(e){return null==e?this.parts().minute:this.rebuild({minute:e})}minutes(e){return null==e?this.minute():this.minute(e)}month(e){return null==e?this.parts().month:this.rebuild({month:e})}months(e){return null==e?this.month():this.month(e)}ordinal(){return this.ordinalFor(this.parts().day)}quarter(e){const t=this.parts().month;return null==e?Math.floor(t/3)+1:this.month(t%3+3*(e-1))}second(e){return null==e?this.parts().second:this.rebuild({second:e})}seconds(e){return null==e?this.second():this.second(e)}set(e,t){switch(e){case"millisecond":return this.millisecond(t);case"second":return this.second(t);case"minute":return this.minute(t);case"hour":return this.hour(t);case"date":return this.date(t);case"day":return this.day(t);case"month":return this.month(t);case"quarter":return this.quarter(t);case"year":return this.year(t);default:throw new Error(`Invalid unit for set(): ${e}`)}}startOf(e){const t=this.parts();switch(e){case"year":return this.rebuild({month:0,day:1,hour:0,minute:0,second:0,millisecond:0});case"quarter":return this.rebuild({month:3*Math.floor(t.month/3),day:1,hour:0,minute:0,second:0,millisecond:0});case"month":return this.rebuild({day:1,hour:0,minute:0,second:0,millisecond:0});case"week":{const e=(t.weekday-this._weekStartsOn+7)%7;return this.rebuild({day:t.day-e,hour:0,minute:0,second:0,millisecond:0})}case"date":case"day":return this.rebuild({hour:0,minute:0,second:0,millisecond:0});case"hour":return this.rebuild({minute:0,second:0,millisecond:0});case"minute":return this.rebuild({second:0,millisecond:0});case"second":return this.rebuild({millisecond:0});default:return this.clone()}}subtract(e,t){return this.add(-e,t)}timeAgo(e,t={}){const r=t.second??60,s=t.minute??60,a=t.hour??24,n=t.day??30,i=t.month??12,o=this._date.getTime()-Date.now(),h=new Intl.RelativeTimeFormat(this._locale,{numeric:"auto",...e}),u=o/1e3,d=u/60,m=d/60,l=m/24,c=l/30,y=l/365;return Math.abs(u)<r?h.format(Math.round(u),"second"):Math.abs(d)<s?h.format(Math.round(d),"minute"):Math.abs(m)<a?h.format(Math.round(m),"hour"):Math.abs(l)<n?h.format(Math.round(l),"day"):Math.abs(c)<i?h.format(Math.round(c),"month"):h.format(Math.round(y),"year")}timeAgoLive(e,t){return this.liveRelativeTime(()=>this.timeAgo(e,t))}timeAgoSubscribe(e,t,r){return this.timeAgoLive(t,r).subscribe(e)}timezone(){return this._timezone}to(e,t=!1){return this.withDate(e).from(this,t)}toArray(){const e=this.parts();return[e.year,e.month,e.day,e.hour,e.minute,e.second,e.millisecond]}toDate(){return new Date(this._date)}toISOString(){return this._date.toISOString()}toJSON(){return this.toISOString()}toNow(e=!1){return this.to(new Date,e)}toObject(){const e=this.parts();return{year:e.year,month:e.month,date:e.day,hour:e.hour,minute:e.minute,second:e.second,millisecond:e.millisecond,day:e.weekday}}toString(){return this._date.toString()}unix(){return Math.floor(this._date.getTime()/1e3)}utc(){return this.withTimezone("UTC")}utcOffset(){return s(this._date,this._timezone)/6e4}valueOf(){return this._date.getTime()}week(){const e=this.parts(),t=(new Date(Date.UTC(e.year,0,1)).getUTCDay()-this._weekStartsOn+7)%7;return Math.ceil((this.dayOfYear()+t)/7)}weekStart(){return this._weekStartsOn}weekYear(){return this.isoThursday().getUTCFullYear()}weekday(e){const t=this.parts(),r=(t.weekday-this._weekStartsOn+7)%7;return null==e?r:this.rebuild({day:t.day-r+e})}weeks(){return this.week()}weeksInYear(){return this.weeksInYearBy(e=>e.week())}withDate(e){return new N(this._locale,this._timezone,e,this._weekStartsOn,this._ordinal)}withLocale(e){return new N(e,this._timezone,this._date,this._weekStartsOn,this._ordinal)}withTimezone(e){return new N(this._locale,e,this._date,this._weekStartsOn,this._ordinal)}withWeekStart(e){return new N(this._locale,this._timezone,this._date,e,this._ordinal)}year(e){return null==e?this.parts().year:this.rebuild({year:e})}years(e){return null==e?this.year():this.year(e)}addMonths(e){const r=this.parts(),s=12*r.year+r.month+e,a=Math.floor(s/12),n=(s%12+12)%12,i=Math.min(r.day,t(a,n));return this.rebuild({year:a,month:n,day:i})}calendarDayNumber(){const e=this.parts();return Math.floor(Date.UTC(e.year,e.month,e.day)/864e5)}getPreset(e){switch(e){case"short":return{dateStyle:"short",timeStyle:"short"};case"medium":return{dateStyle:"medium",timeStyle:"medium"};case"long":return{dateStyle:"long",timeStyle:"long"};case"full":return{dateStyle:"full",timeStyle:"full"};case"dateOnly":return{year:"numeric",month:"long",day:"numeric"};case"timeOnly":return{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1};case"weekdayTime":return{weekday:"long",hour:"numeric",minute:"numeric"};case"isoStyle12h":return{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0};case"isoStyle24h":return{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1};default:return{}}}isoThursday(){const e=this.parts(),t=new Date(Date.UTC(e.year,e.month,e.day));return t.setUTCDate(t.getUTCDate()+4-(t.getUTCDay()||7)),t}liveRelativeTime(e){const t=this._date.getTime();let r;const s=new Set,a=()=>{r&&clearTimeout(r),r=void 0},n=()=>{const a=e();if(s.forEach(e=>e(a)),0===s.size)return;const i=Math.abs((Date.now()-t)/1e3);r=setTimeout(n,(e=>e<60?1e3:e<3600?3e4:e<86400?18e5:36e5)(i))};return{subscribe:t=>(s.add(t),1===s.size?n():t(e()),()=>{s.delete(t),0===s.size&&a()}),unsubscribe:()=>{s.clear(),a()}}}offsetString(e){const t=s(this._date,this._timezone)/6e4,r=t>=0?"+":"-",a=Math.abs(t),n=String(Math.floor(a/60)).padStart(2,"0"),i=String(Math.round(a%60)).padStart(2,"0");return e?`${r}${n}:${i}`:`${r}${n}${i}`}ordinalFor(e){return this._ordinal?this._ordinal(e):`${e}${(e=>{const t=e%100;if(t>=11&&t<=13)return"th";switch(e%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}})(e)}`}parts(){return r(this._date,this._timezone)}preciseCalendarDiff(e,t){const r=this.wholeMonthDiff(e,t),s=this.withDate(e),a=s.add(r*t,"month"),n=this._date.getTime()>=a.valueOf()?1:-1,i=s.add((r+n)*t,"month").valueOf()-a.valueOf();return r+(0===i?0:(this._date.getTime()-a.valueOf())/i)*n}rebuild(e){if(!this.isValid())throw new Error(`Invalid date: ${this._date}`);const t={...this.parts(),...e};return this.withDate(a(t,this._timezone))}toComparable(e){return e instanceof N?e.toDate():this.validateDate(e)}validateDate(e){if(!N.isValid(e))throw new Error(`Invalid date: ${e}`);return N.resolveInput(e,this._timezone)}weeksInYearBy(e){const t=e(this.rebuild({month:11,day:31}));return 1===t?e(this.rebuild({month:11,day:24})):t}wholeMonthDiff(e,t){const s=this.parts(),a=r(e,this._timezone);return Math.trunc((12*(s.year-a.year)+(s.month-a.month))/t)}}const O=e=>{const t=(t,r={})=>{const s={...e,...r},a=t instanceof N?t.toDate():t;return new N(s.locale??"en",s.timezone,a,s.weekStartsOn??0,s.ordinal)};return Object.assign(t,{duration:(t,r,s=e.locale??"en")=>N.duration(t,r,s),guessTimezone:N.guessTimezone,parse:(t,r,s=e.locale??"en",a=e.timezone??N.guessTimezone())=>N.parse(t,r,s,a),min:N.min,max:N.max,isValid:N.isValid,isDateTick:N.isDateTick,isDuration:L.isDuration,utc:(e,r={})=>t(e,{...r,timezone:"UTC"}),unix:(e,r={})=>t(new Date(1e3*e),r),withDefaults:t=>O({...e,...t})})},I=O({});e.DateTick=N,e.Duration=L,e.datetick=I,e.default=I,Object.defineProperty(e,"__esModule",{value:!0})});
package/junit.xml ADDED
@@ -0,0 +1,311 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <testsuites name="jest tests" tests="153" failures="0" errors="0" time="2.258">
3
+ <testsuite name="Tock" errors="0" failures="0" skipped="0" timestamp="2026-07-01T05:40:33" time="1.209" tests="153">
4
+ <testcase classname="src\index.test.ts" name="Tock construction should create with locale and timezone" time="0.001">
5
+ </testcase>
6
+ <testcase classname="src\index.test.ts" name="Tock construction should default to now when no date is provided" time="0.001">
7
+ </testcase>
8
+ <testcase classname="src\index.test.ts" name="Tock construction should accept a string date" time="0.001">
9
+ </testcase>
10
+ <testcase classname="src\index.test.ts" name="Tock construction should accept date parts objects and arrays as zoned wall-clock input" time="0.044">
11
+ </testcase>
12
+ <testcase classname="src\index.test.ts" name="Tock construction should clone a Date defensively so external mutation does not leak in" time="0">
13
+ </testcase>
14
+ <testcase classname="src\index.test.ts" name="Tock construction should expose locale and timezone" time="0">
15
+ </testcase>
16
+ <testcase classname="src\index.test.ts" name="Tock immutability should not mutate the original instance when setting" time="0.001">
17
+ </testcase>
18
+ <testcase classname="src\index.test.ts" name="Tock immutability clone should return an equal but distinct instance" time="0.001">
19
+ </testcase>
20
+ <testcase classname="src\index.test.ts" name="Tock getters and setters should get local date parts" time="0.001">
21
+ </testcase>
22
+ <testcase classname="src\index.test.ts" name="Tock getters and setters should set each unit immutably" time="0.002">
23
+ </testcase>
24
+ <testcase classname="src\index.test.ts" name="Tock getters and setters should get and set day of week" time="0.001">
25
+ </testcase>
26
+ <testcase classname="src\index.test.ts" name="Tock get() / set() should get values via get()" time="0.003">
27
+ </testcase>
28
+ <testcase classname="src\index.test.ts" name="Tock get() / set() should set values via set()" time="0.002">
29
+ </testcase>
30
+ <testcase classname="src\index.test.ts" name="Tock get() / set() should throw on invalid unit for set()" time="0.019">
31
+ </testcase>
32
+ <testcase classname="src\index.test.ts" name="Tock get() / set() returns NaN for unknown get units from untyped callers" time="0">
33
+ </testcase>
34
+ <testcase classname="src\index.test.ts" name="Tock weekday() is relative to the configured first day of the week, unlike day()" time="0.001">
35
+ </testcase>
36
+ <testcase classname="src\index.test.ts" name="Tock weekday() sets the date to the requested relative weekday" time="0.003">
37
+ </testcase>
38
+ <testcase classname="src\index.test.ts" name="Tock quarter() and dayOfYear() setters quarter(value) preserves the month offset within the quarter" time="0">
39
+ </testcase>
40
+ <testcase classname="src\index.test.ts" name="Tock quarter() and dayOfYear() setters dayOfYear(value) sets the day of the year, rolling into later months/years like native Date" time="0.001">
41
+ </testcase>
42
+ <testcase classname="src\index.test.ts" name="Tock add / subtract should add simple time units" time="0">
43
+ </testcase>
44
+ <testcase classname="src\index.test.ts" name="Tock add / subtract should add weeks" time="0.001">
45
+ </testcase>
46
+ <testcase classname="src\index.test.ts" name="Tock add / subtract should subtract as the inverse of add" time="0">
47
+ </testcase>
48
+ <testcase classname="src\index.test.ts" name="Tock add / subtract should clamp month overflow (Jan 31 + 1 month -&gt; Feb, not Mar)" time="0">
49
+ </testcase>
50
+ <testcase classname="src\index.test.ts" name="Tock add / subtract should land on Feb 29 in a leap year" time="0.001">
51
+ </testcase>
52
+ <testcase classname="src\index.test.ts" name="Tock add / subtract should add quarters" time="0">
53
+ </testcase>
54
+ <testcase classname="src\index.test.ts" name="Tock add / subtract should clamp year overflow for Feb 29" time="0">
55
+ </testcase>
56
+ <testcase classname="src\index.test.ts" name="Tock add / subtract returns a clone for unknown units from untyped callers" time="0.001">
57
+ </testcase>
58
+ <testcase classname="src\index.test.ts" name="Tock diff should compute differences in various units" time="0.001">
59
+ </testcase>
60
+ <testcase classname="src\index.test.ts" name="Tock diff should be negative when the wrapped date is earlier" time="0.001">
61
+ </testcase>
62
+ <testcase classname="src\index.test.ts" name="Tock diff should accept a Tock as input" time="0">
63
+ </testcase>
64
+ <testcase classname="src\index.test.ts" name="Tock diff should default to milliseconds" time="0.001">
65
+ </testcase>
66
+ <testcase classname="src\index.test.ts" name="Tock diff should compute quarter diff" time="0">
67
+ </testcase>
68
+ <testcase classname="src\index.test.ts" name="Tock diff falls back to millisecond diff for unknown units from untyped callers" time="0.001">
69
+ </testcase>
70
+ <testcase classname="src\index.test.ts" name="Tock diff should compute calendar-boundary differences separately from elapsed duration" time="0.002">
71
+ </testcase>
72
+ <testcase classname="src\index.test.ts" name="Tock diff returns NaN for unknown calendar diff units from untyped callers" time="0.001">
73
+ </testcase>
74
+ <testcase classname="src\index.test.ts" name="Tock diff precise=true returns a floating-point value for fixed-duration units" time="0">
75
+ </testcase>
76
+ <testcase classname="src\index.test.ts" name="Tock diff precise=true interpolates a fractional month/quarter/year" time="0.003">
77
+ </testcase>
78
+ <testcase classname="src\index.test.ts" name="Tock comparisons isAfter / isBefore" time="0">
79
+ </testcase>
80
+ <testcase classname="src\index.test.ts" name="Tock comparisons isSame exact" time="0.001">
81
+ </testcase>
82
+ <testcase classname="src\index.test.ts" name="Tock comparisons isSame with unit" time="0.003">
83
+ </testcase>
84
+ <testcase classname="src\index.test.ts" name="Tock comparisons isBetween exclusive and inclusive (boolean form)" time="0.001">
85
+ </testcase>
86
+ <testcase classname="src\index.test.ts" name="Tock comparisons isBetween supports independent per-side inclusivity" time="0.001">
87
+ </testcase>
88
+ <testcase classname="src\index.test.ts" name="Tock comparisons detects today, tomorrow and yesterday in the configured timezone" time="0.001">
89
+ </testcase>
90
+ <testcase classname="src\index.test.ts" name="Tock startOf / endOf startOf snaps down" time="0.002">
91
+ </testcase>
92
+ <testcase classname="src\index.test.ts" name="Tock startOf / endOf startOf week snaps to Sunday" time="0.001">
93
+ </testcase>
94
+ <testcase classname="src\index.test.ts" name="Tock startOf / endOf startOf quarter snaps to first month of quarter" time="0.001">
95
+ </testcase>
96
+ <testcase classname="src\index.test.ts" name="Tock startOf / endOf endOf is one ms before the next unit" time="0.001">
97
+ </testcase>
98
+ <testcase classname="src\index.test.ts" name="Tock startOf / endOf endOf year" time="0.001">
99
+ </testcase>
100
+ <testcase classname="src\index.test.ts" name="Tock startOf / endOf endOf millisecond returns a clone" time="0">
101
+ </testcase>
102
+ <testcase classname="src\index.test.ts" name="Tock startOf / endOf startOf returns a clone for unknown units from untyped callers" time="0">
103
+ </testcase>
104
+ <testcase classname="src\index.test.ts" name="Tock calendar helpers isLeapYear" time="0">
105
+ </testcase>
106
+ <testcase classname="src\index.test.ts" name="Tock calendar helpers daysInMonth" time="0.001">
107
+ </testcase>
108
+ <testcase classname="src\index.test.ts" name="Tock calendar helpers quarter" time="0">
109
+ </testcase>
110
+ <testcase classname="src\index.test.ts" name="Tock calendar helpers dayOfYear, week, isoWeek, isoDay" time="0">
111
+ </testcase>
112
+ <testcase classname="src\index.test.ts" name="Tock calendar helpers isoDay returns 7 for Sunday" time="0">
113
+ </testcase>
114
+ <testcase classname="src\index.test.ts" name="Tock calendar helpers weekYear, weeksInYear, isoWeekYear, isoWeeksInYear" time="0">
115
+ </testcase>
116
+ <testcase classname="src\index.test.ts" name="Tock static helpers isValid" time="0">
117
+ </testcase>
118
+ <testcase classname="src\index.test.ts" name="Tock static helpers max / min" time="0.001">
119
+ </testcase>
120
+ <testcase classname="src\index.test.ts" name="Tock static helpers isTock" time="0">
121
+ </testcase>
122
+ <testcase classname="src\index.test.ts" name="Tock static helpers guessTimezone" time="0">
123
+ </testcase>
124
+ <testcase classname="src\index.test.ts" name="Tock static helpers instance isValid" time="0.001">
125
+ </testcase>
126
+ <testcase classname="src\index.test.ts" name="Tock formatting formats with presets" time="0.002">
127
+ </testcase>
128
+ <testcase classname="src\index.test.ts" name="Tock formatting formats with explicit options" time="0">
129
+ </testcase>
130
+ <testcase classname="src\index.test.ts" name="Tock formatting formats with no argument" time="0">
131
+ </testcase>
132
+ <testcase classname="src\index.test.ts" name="Tock formatting falls back to default Intl formatting for unknown presets from untyped callers" time="0">
133
+ </testcase>
134
+ <testcase classname="src\index.test.ts" name="Tock formatting respects locale" time="0.001">
135
+ </testcase>
136
+ <testcase classname="src\index.test.ts" name="Tock token formatting (formatPattern) matches expected token output" time="0.004">
137
+ </testcase>
138
+ <testcase classname="src\index.test.ts" name="Tock token formatting (formatPattern) handles names, 12h clock, meridiem and milliseconds" time="0.004">
139
+ </testcase>
140
+ <testcase classname="src\index.test.ts" name="Tock token formatting (formatPattern) supports [escaped] literals" time="0.002">
141
+ </testcase>
142
+ <testcase classname="src\index.test.ts" name="Tock token formatting (formatPattern) treats an unclosed [ as a literal character rather than throwing" time="0.002">
143
+ </testcase>
144
+ <testcase classname="src\index.test.ts" name="Tock token formatting (formatPattern) emits the timezone offset (Z / ZZ) in the configured zone" time="0.004">
145
+ </testcase>
146
+ <testcase classname="src\index.test.ts" name="Tock token formatting (formatPattern) respects locale for month/weekday names" time="0.001">
147
+ </testcase>
148
+ <testcase classname="src\index.test.ts" name="Tock parsing (static parse) parses numeric patterns into the configured timezone" time="0">
149
+ </testcase>
150
+ <testcase classname="src\index.test.ts" name="Tock parsing (static parse) parses month names and 12-hour meridiem" time="0">
151
+ </testcase>
152
+ <testcase classname="src\index.test.ts" name="Tock parsing (static parse) round-trips with formatPattern" time="0.001">
153
+ </testcase>
154
+ <testcase classname="src\index.test.ts" name="Tock parsing (static parse) parses 2-digit years and milliseconds" time="0.001">
155
+ </testcase>
156
+ <testcase classname="src\index.test.ts" name="Tock parsing (static parse) throws on input that does not match the pattern" time="0.001">
157
+ </testcase>
158
+ <testcase classname="src\index.test.ts" name="Tock parsing (static parse) throws on unknown month names instead of falling back to January" time="0">
159
+ </testcase>
160
+ <testcase classname="src\index.test.ts" name="Tock parsing (static parse) throws on out-of-range date and time fields" time="0.008">
161
+ </testcase>
162
+ <testcase classname="src\index.test.ts" name="Tock ordinal &amp; isSameOrBefore/After ordinal day-of-month" time="0.001">
163
+ </testcase>
164
+ <testcase classname="src\index.test.ts" name="Tock ordinal &amp; isSameOrBefore/After isSameOrAfter / isSameOrBefore" time="0.002">
165
+ </testcase>
166
+ <testcase classname="src\index.test.ts" name="Tock advanced format tokens Do / Q / k / kk / X / x" time="0.005">
167
+ </testcase>
168
+ <testcase classname="src\index.test.ts" name="Tock advanced format tokens w / ww / W / WW" time="0.004">
169
+ </testcase>
170
+ <testcase classname="src\index.test.ts" name="Tock advanced format tokens wo / Wo (ordinal week of year)" time="0.004">
171
+ </testcase>
172
+ <testcase classname="src\index.test.ts" name="Tock advanced format tokens wo/Wo are consumed but ignored when parsing (derived values)" time="0.001">
173
+ </testcase>
174
+ <testcase classname="src\index.test.ts" name="Tock localized format tokens expands the L-family to English patterns" time="0.008">
175
+ </testcase>
176
+ <testcase classname="src\index.test.ts" name="Tock localized format tokens honours locale for names inside localized tokens" time="0.001">
177
+ </testcase>
178
+ <testcase classname="src\index.test.ts" name="Tock configurable first-day-of-week defaults to Sunday" time="0.003">
179
+ </testcase>
180
+ <testcase classname="src\index.test.ts" name="Tock configurable first-day-of-week respects a Monday week start" time="0.003">
181
+ </testcase>
182
+ <testcase classname="src\index.test.ts" name="Tock configurable first-day-of-week week() numbering shifts with the week start" time="0">
183
+ </testcase>
184
+ <testcase classname="src\index.test.ts" name="Tock configurable first-day-of-week is preserved across with* derivations" time="0">
185
+ </testcase>
186
+ <testcase classname="src\index.test.ts" name="Tock configurable first-day-of-week builds a padded calendar month using the configured week start" time="0.041">
187
+ </testcase>
188
+ <testcase classname="src\index.test.ts" name="Tock configurable first-day-of-week localizes calendar month labels and weekday labels" time="0.039">
189
+ </testcase>
190
+ <testcase classname="src\index.test.ts" name="Tock configurable first-day-of-week can render a viewed month with a separate selected date" time="0.037">
191
+ </testcase>
192
+ <testcase classname="src\index.test.ts" name="Tock configurable first-day-of-week formats calendar date cells with token, Intl and callback options" time="0.161">
193
+ </testcase>
194
+ <testcase classname="src\index.test.ts" name="Tock Day.js-style compatibility helpers formats calendar-style relative labels" time="0.009">
195
+ </testcase>
196
+ <testcase classname="src\index.test.ts" name="Tock Day.js-style compatibility helpers formats relative time with from/fromNow/to/toNow aliases" time="0.009">
197
+ </testcase>
198
+ <testcase classname="src\index.test.ts" name="Tock Day.js-style compatibility helpers exposes utc/local timezone helpers and utcOffset" time="0">
199
+ </testcase>
200
+ <testcase classname="src\index.test.ts" name="Tock Duration creates from amount + unit and converts (as*)" time="0.001">
201
+ </testcase>
202
+ <testcase classname="src\index.test.ts" name="Tock Duration creates from a components object" time="0">
203
+ </testcase>
204
+ <testcase classname="src\index.test.ts" name="Tock Duration identifies Duration instances" time="0">
205
+ </testcase>
206
+ <testcase classname="src\index.test.ts" name="Tock Duration decomposes into signed components" time="0.001">
207
+ </testcase>
208
+ <testcase classname="src\index.test.ts" name="Tock Duration humanizes (locale-aware, optional suffix)" time="0.001">
209
+ </testcase>
210
+ <testcase classname="src\index.test.ts" name="Tock Duration add / subtract" time="0.001">
211
+ </testcase>
212
+ <testcase classname="src\index.test.ts" name="Tock Duration defaults duration add/subtract units to milliseconds" time="0">
213
+ </testcase>
214
+ <testcase classname="src\index.test.ts" name="Tock Duration throws on invalid units from untyped callers" time="0.003">
215
+ </testcase>
216
+ <testcase classname="src\index.test.ts" name="Tock Duration toISOString / toJSON / valueOf" time="0.001">
217
+ </testcase>
218
+ <testcase classname="src\index.test.ts" name="Tock Duration omits the T-separator entirely for a date-only duration" time="0">
219
+ </testcase>
220
+ <testcase classname="src\index.test.ts" name="Tock Duration pairs naturally with diff" time="0">
221
+ </testcase>
222
+ <testcase classname="src\index.test.ts" name="Tock Duration exposes the full as*/component accessor surface" time="0">
223
+ </testcase>
224
+ <testcase classname="src\index.test.ts" name="Tock Duration supports Day.js-style duration get() and format()" time="0.001">
225
+ </testcase>
226
+ <testcase classname="src\index.test.ts" name="Tock Duration humanizes larger spans (minutes/days/years thresholds)" time="0.001">
227
+ </testcase>
228
+ <testcase classname="src\index.test.ts" name="Tock parsing advanced tokens parses Do, kk and consumes Q/w" time="0.001">
229
+ </testcase>
230
+ <testcase classname="src\index.test.ts" name="Tock parsing advanced tokens parses unix tokens X (seconds) and x (milliseconds)" time="0.001">
231
+ </testcase>
232
+ <testcase classname="src\index.test.ts" name="Tock conversion toDate returns a fresh Date" time="0">
233
+ </testcase>
234
+ <testcase classname="src\index.test.ts" name="Tock conversion toISOString / toJSON" time="0.001">
235
+ </testcase>
236
+ <testcase classname="src\index.test.ts" name="Tock conversion toArray / toObject return zoned calendar parts" time="0">
237
+ </testcase>
238
+ <testcase classname="src\index.test.ts" name="Tock conversion toString" time="0">
239
+ </testcase>
240
+ <testcase classname="src\index.test.ts" name="Tock conversion unix / valueOf" time="0">
241
+ </testcase>
242
+ <testcase classname="src\index.test.ts" name="Tock conversion valueOf enables numeric coercion" time="0">
243
+ </testcase>
244
+ <testcase classname="src\index.test.ts" name="Tock with* derivations withDate keeps locale &amp; timezone" time="0">
245
+ </testcase>
246
+ <testcase classname="src\index.test.ts" name="Tock with* derivations withLocale / withTimezone keep the date" time="0">
247
+ </testcase>
248
+ <testcase classname="src\index.test.ts" name="Tock timezone awareness reads components in the configured timezone, not the host" time="0.001">
249
+ </testcase>
250
+ <testcase classname="src\index.test.ts" name="Tock timezone awareness builds the right instant when setting wall-clock components in a zone" time="0.002">
251
+ </testcase>
252
+ <testcase classname="src\index.test.ts" name="Tock timezone awareness the same wall clock in different zones maps to different instants" time="0.004">
253
+ </testcase>
254
+ <testcase classname="src\index.test.ts" name="Tock timezone awareness day-of-week, quarter and week are computed in the configured zone" time="0.001">
255
+ </testcase>
256
+ <testcase classname="src\index.test.ts" name="Tock timezone awareness calendar add preserves wall-clock time across a DST spring-forward" time="0.002">
257
+ </testcase>
258
+ <testcase classname="src\index.test.ts" name="Tock timezone awareness resolves a wall-clock instant correctly even when constructed right at a DST boundary" time="0.002">
259
+ </testcase>
260
+ <testcase classname="src\index.test.ts" name="Tock timezone awareness startOf(&quot;day&quot;) snaps to local midnight in the zone" time="0">
261
+ </testcase>
262
+ <testcase classname="src\index.test.ts" name="Tock timezone awareness withTimezone keeps the instant but re-interprets the wall clock" time="0">
263
+ </testcase>
264
+ <testcase classname="src\index.test.ts" name="Tock validation throws when setting on an invalid date" time="0">
265
+ </testcase>
266
+ <testcase classname="src\index.test.ts" name="Tock validation throws in diff against an invalid input" time="0">
267
+ </testcase>
268
+ <testcase classname="src\index.test.ts" name="Tock timeAgo returns a string for a past date" time="0">
269
+ </testcase>
270
+ <testcase classname="src\index.test.ts" name="Tock timeAgo returns a string for a future date" time="0">
271
+ </testcase>
272
+ <testcase classname="src\index.test.ts" name="Tock timeAgo handles seconds, hours, days, months, years ranges" time="0">
273
+ </testcase>
274
+ <testcase classname="src\index.test.ts" name="Tock timeAgoLive emits a timeAgo string immediately" time="0">
275
+ </testcase>
276
+ <testcase classname="src\index.test.ts" name="Tock timeAgoLive refreshes on a timer (fake timers)" time="0.001">
277
+ </testcase>
278
+ <testcase classname="src\index.test.ts" name="Tock timeAgoLive supports the timeAgoSubscribe convenience helper" time="0.001">
279
+ </testcase>
280
+ <testcase classname="src\index.test.ts" name="Tock timeAgoLive gives a late subscriber an immediate value without restarting the shared timer" time="0">
281
+ </testcase>
282
+ <testcase classname="src\index.test.ts" name="Tock timeAgoLive adapts its refresh interval as the target moves further away (minute/hour/day tiers)" time="0">
283
+ </testcase>
284
+ <testcase classname="src\index.test.ts" name="Tock timeAgoLive uses the 30-minute tier once the target is more than an hour away (but under a day)" time="0.001">
285
+ </testcase>
286
+ <testcase classname="src\index.test.ts" name="Tock timeAgoLive uses the hour tier once the target is more than a day away" time="0">
287
+ </testcase>
288
+ <testcase classname="src\index.test.ts" name="Tock tock() factory creates a Tock from a string/Date/Tock" time="0">
289
+ </testcase>
290
+ <testcase classname="src\index.test.ts" name="Tock tock() factory defaults to now with no argument" time="0.001">
291
+ </testcase>
292
+ <testcase classname="src\index.test.ts" name="Tock tock() factory passes through locale, timezone and weekStartsOn options" time="0">
293
+ </testcase>
294
+ <testcase classname="src\index.test.ts" name="Tock tock() factory tock.utc shorthand fixes the timezone to UTC" time="0.001">
295
+ </testcase>
296
+ <testcase classname="src\index.test.ts" name="Tock tock() factory tock.unix builds from seconds" time="0">
297
+ </testcase>
298
+ <testcase classname="src\index.test.ts" name="Tock tock() factory tock.unix works with no options argument" time="0">
299
+ </testcase>
300
+ <testcase classname="src\index.test.ts" name="Tock tock() factory exposes static helpers (duration / parse / min / max / isValid / guessTimezone)" time="0.001">
301
+ </testcase>
302
+ <testcase classname="src\index.test.ts" name="Tock tock() factory withDefaults returns an independent factory without mutating the original" time="0">
303
+ </testcase>
304
+ <testcase classname="src\index.test.ts" name="Tock tock() factory withDefaults flows defaults into duration() and parse() too" time="0.001">
305
+ </testcase>
306
+ <testcase classname="src\index.test.ts" name="Tock tock() factory withDefaults merges progressively when chained" time="0">
307
+ </testcase>
308
+ <testcase classname="src\index.test.ts" name="Tock tock() factory withDefaults per-call options still override the factory defaults" time="0.001">
309
+ </testcase>
310
+ </testsuite>
311
+ </testsuites>
package/package.json ADDED
@@ -0,0 +1,145 @@
1
+ {
2
+ "name": "datetick",
3
+ "version": "1.0.0",
4
+ "description": "DateTick — a tiny, immutable, fully timezone-aware date toolkit: formatting, parsing, durations and live relative-time, for any framework.",
5
+ "sideEffects": false,
6
+ "main": "dist/index.js",
7
+ "module": "dist/index.js",
8
+ "browser": "dist/index.umd.min.js",
9
+ "private": false,
10
+ "types": "dist/index.d.ts",
11
+ "type": "module",
12
+ "exports": {
13
+ ".": {
14
+ "import": {
15
+ "types": "./dist/index.d.ts",
16
+ "default": "./dist/index.js"
17
+ },
18
+ "browser": "./dist/index.umd.min.js",
19
+ "types": "./dist/index.d.ts"
20
+ }
21
+ },
22
+ "scripts": {
23
+ "build": "rollup -c",
24
+ "format": "prettier --write .",
25
+ "format:check": "prettier --check .",
26
+ "lint": "eslint --fix",
27
+ "test": "cross-env TZ=UTC jest",
28
+ "test:ci": "cross-env TZ=UTC JEST_JUNIT_CLASSNAME=\"{filepath}\" jest --reporters=default --reporters=jest-junit",
29
+ "test:watch": "cross-env TZ=UTC jest --watch",
30
+ "test:coverage": "cross-env TZ=UTC jest --coverage",
31
+ "test:bundle": "npx bundlewatch",
32
+ "prepublishOnly": "npm run build",
33
+ "prepare": "husky"
34
+ },
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "https://github.com/andreasnicolaou/datetick.git"
38
+ },
39
+ "bugs": {
40
+ "url": "https://github.com/andreasnicolaou/datetick/issues"
41
+ },
42
+ "homepage": "https://andreasnicolaou.github.io/datetick/",
43
+ "author": {
44
+ "name": "Andreas Nicolaou",
45
+ "email": "anicolaou66@gmail.com"
46
+ },
47
+ "license": "MIT",
48
+ "jest": {
49
+ "transform": {
50
+ "^.+\\.(ts)$": [
51
+ "ts-jest"
52
+ ]
53
+ },
54
+ "testEnvironment": "jsdom",
55
+ "testPathIgnorePatterns": [
56
+ "/node_modules/",
57
+ "/dist/"
58
+ ]
59
+ },
60
+ "bundlewatch": {
61
+ "files": [
62
+ {
63
+ "path": "dist/index.js",
64
+ "maxSize": "20kB",
65
+ "compression": "gzip"
66
+ },
67
+ {
68
+ "path": "dist/index.umd.js",
69
+ "maxSize": "25kB",
70
+ "compression": "gzip"
71
+ },
72
+ {
73
+ "path": "dist/index.umd.min.js",
74
+ "maxSize": "10kB",
75
+ "compression": "gzip"
76
+ }
77
+ ]
78
+ },
79
+ "lint-staged": {
80
+ "*.{ts,js,mjs,cjs}": [
81
+ "eslint --fix",
82
+ "prettier --write"
83
+ ],
84
+ "*.{json,md,yml,yaml,html,css}": [
85
+ "prettier --write"
86
+ ]
87
+ },
88
+ "devDependencies": {
89
+ "@commitlint/cli": "^21.2.0",
90
+ "@commitlint/config-conventional": "^21.2.0",
91
+ "@eslint/eslintrc": "^3.3.5",
92
+ "@eslint/js": "^10.0.1",
93
+ "@rollup/plugin-commonjs": "^29.0.3",
94
+ "@rollup/plugin-node-resolve": "^16.0.3",
95
+ "@rollup/plugin-terser": "^1.0.0",
96
+ "@rollup/plugin-typescript": "^12.3.0",
97
+ "@types/jest": "^30.0.0",
98
+ "@types/node": "^26.1.0",
99
+ "@typescript-eslint/eslint-plugin": "^8.62.1",
100
+ "@typescript-eslint/parser": "^8.62.1",
101
+ "bundlewatch": "^0.4.2",
102
+ "cross-env": "^10.1.0",
103
+ "eslint": "^10.6.0",
104
+ "eslint-config-prettier": "^10.1.8",
105
+ "eslint-plugin-prettier": "^5.5.6",
106
+ "globals": "^17.7.0",
107
+ "husky": "^9.1.7",
108
+ "jest": "^30.4.2",
109
+ "jest-environment-jsdom": "^30.4.1",
110
+ "jest-junit": "^17.0.0",
111
+ "lint-staged": "^17.0.8",
112
+ "prettier": "3.9.4",
113
+ "rollup": "^4.62.2",
114
+ "rollup-plugin-dts": "^6.4.1",
115
+ "ts-jest": "^29.4.11",
116
+ "ts-node": "^10.9.2",
117
+ "tslib": "^2.8.1",
118
+ "typescript": "^6.0.3"
119
+ },
120
+ "overrides": {
121
+ "axios": "^1.18.1",
122
+ "js-yaml": "^4.2.0",
123
+ "serialize-javascript": "^7.0.6"
124
+ },
125
+ "keywords": [
126
+ "datetick",
127
+ "date",
128
+ "datetime",
129
+ "time",
130
+ "timezone",
131
+ "format",
132
+ "parse",
133
+ "duration",
134
+ "timeago",
135
+ "relative-time",
136
+ "immutable",
137
+ "reactive",
138
+ "framework-agnostic",
139
+ "angular",
140
+ "react",
141
+ "vue",
142
+ "typescript",
143
+ "andreasnicolaou"
144
+ ]
145
+ }