qrono 0.4.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -5,15 +5,17 @@ _**4kB** JavaScript date library with **100+ APIs** and **strict DST guarantees*
5
5
  [![MIT License][image-license]][url-license]
6
6
  [![CodeQL][image-codeql]][url-codeql]
7
7
  [![NPM version][image-npm-version]][url-npm]
8
- [![NPM downloads][image-npm-downloads]][url-npm-downloads]
8
+ [![NPM downloads][image-downloads]][url-downloads]
9
9
  [![gzip size][image-size]][url-size]
10
10
 
11
11
  ```js
12
12
  import { qrono } from 'qrono'
13
13
 
14
14
  // America/New_York — DST ends
15
- qrono('2026-03-29 01:30').plus({ hour: 1 }) // DST-safe
15
+ qrono({ localtime: true },'2026-03-29 01:30').plus({ hour: 1 }) // DST-safe
16
+ // UTC first
16
17
  qrono('2026-08-31 12:34').toString() === '2026-08-31T12:34.000Z'
18
+ // Flexible APIs
17
19
  qrono('2026-08-31 12:34') < qrono('2026-09-30 12:34')
18
20
  const today = qrono.date('2021-08-31')
19
21
  const tomorrow = qrono.date(today + 1)
@@ -26,18 +28,28 @@ tommorow - today === 1
26
28
 
27
29
  ## Design Philosophy 🎨
28
30
 
29
- - **Type-safe, immutable, and chainable**
30
- Covers the majority of common use cases.
31
- - **UTC-first with local time support**
32
- Supports only UTC (by default) and the environment’s local time zone. In most cases, supporting only the client’s time zone is sufficient.
33
- - **Strict DST handling**
34
- Provides explicit handling of ambiguous daylight saving time transitions through dedicated APIs.
35
- - **ISO 8601 compliant**
36
- Fully compliant with the ISO 8601 standard.
37
- - **Zero dependencies**
38
- Written in pure JavaScript with no external dependencies.
39
- - **Locale-agnostic**
40
- Delegates localization to the ECMAScript® Internationalization API.
31
+ #### 🔐 **Immutable, Intuitive and Chainable**
32
+ - All operations return new instances for safe, predictable data and intuitive API.
33
+ - Covers the majority of common use cases.
34
+
35
+ #### 🔷 **TypeScript Ready**
36
+ - Full TypeScript definitions included for type-safe development.
37
+ - Designed to work seamlessly in both server-side and browser-side JavaScript environments.
38
+
39
+ #### **Minimal and Focused**
40
+ - Pure JavaScript with zero dependencies.
41
+ - Lightweight (**4kB**) with **100+** APIs through focused design.
42
+
43
+ #### 🌍 **UTC-first with Local Time Support**
44
+ - Supports UTC by default and the environment's local time zone.
45
+ - Locale-agnostic design delegates localization to the [ECMAScript Internationalization API](https://402.ecma-international.org/#overview).
46
+
47
+ #### 🕐 **Strict DST Handling**
48
+ - Unique DST-aware APIs that no other library provides.
49
+ - Explicit handling of ambiguous daylight saving time transitions through dedicated APIs.
50
+
51
+ #### ✅ **ISO 8601 Compliant**
52
+ - Fully compliant with the [ISO 8601](https://www.iso.org/obp/ui/#iso:std:iso:8601:-1:ed-1:v1:en) standard for reliable date-time exchange and interoperability.
41
53
 
42
54
  ### Alternatives
43
55
 
@@ -59,17 +71,18 @@ tommorow - today === 1
59
71
  Provides 200+ pure functions for manipulating JavaScript `Date` objects. Implemented in TypeScript and fully tree-shakeable.
60
72
  Because it builds directly on the native `Date` object, it inherits limitations such as mutability and zero-based months.
61
73
 
62
- - **[The ECMA TC39 Temporal Proposal](https://tc39.es/proposal-temporal/docs/index.html)**
63
- A proposed ECMAScript® API that may become a future standard. The specification is rigorous and heavily inspired by `java.time`.
64
-
65
74
  None of these libraries provide dedicated APIs for strict DST transition handling.
66
75
  Qrono addresses this gap with a balanced and pragmatic approach.
67
76
 
77
+ - **[The ECMA TC39 Temporal Proposal](https://tc39.es/proposal-temporal/docs/index.html)**
78
+ A proposed ECMAScript API that may become a future standard. Temporal (TC39) defines a comprehensive and rigorous date-time model, including numerous classes such as `Instant`, `Duration`, and `ZonedDateTime`, and provides a complete API covering locale handling and the IANA time zone database. While this design ensures correctness and precision across a wide range of use cases, its breadth and strictness can make it heavyweight and difficult to grasp for developers who simply need to handle date and time operations.
79
+ In contrast, Qrono focuses on delivering the simplest possible API surface while remaining practical for real-world applications, prioritizing clarity and usability over exhaustive completeness.
80
+
68
81
  ### Repository Size Comparison
69
82
 
70
83
  [![Comparison of repository size](docs/public/comparison-repo-size.svg)](docs/public/comparison-repo-size.svg)
71
84
 
72
- This comparison shows that **Qrono clearly stands out for its remarkably small codebase** among other libraries. Its compact size reflects a strong focus on minimalism and efficiency, making it well suited for situations where bundle size and simplicity are important.
85
+ This comparison shows that **Qrono stands out for its small codebase** among other libraries. Its compact size reflects a strong focus on minimalism and efficiency, making it well suited for situations where bundle size and simplicity are important.
73
86
 
74
87
  For many of the other libraries, their larger size is due to the fact that a significant portion of the codebase is dedicated to supporting a wide range of locales. Meanwhile, the larger size of date-fns is intentional and not a drawback. It is designed with tree-shaking in mind, so unused functions are removed at build time, and its API is intentionally fine-grained and verbose to provide clarity and flexibility. The size difference therefore represents a difference in design philosophy, not a measure of overall quality.
75
88
 
@@ -84,7 +97,7 @@ For example, a user who resides in Japan may start using the application in the
84
97
 
85
98
  For this reason, to keep the system design simple, the server should avoid managing user-specific time zones. Instead, the server should store and handle time exclusively in UTC. All time values should be transmitted to clients in UTC (typically as ISO 8601–formatted strings), and converting them into local time should be the responsibility of the client.
86
99
 
87
- Even when support for multiple locales is required, storing time data in UTC is usually sufficient. In most cases, locale-specific formatting can be handled entirely on the client side by using the [ECMAScript® Internationalization API](https://402.ecma-international.org/#overview).
100
+ Even when support for multiple locales is required, storing time data in UTC is usually sufficient. In most cases, locale-specific formatting can be handled entirely on the client side by using the [ECMAScript Internationalization API](https://402.ecma-international.org/#overview).
88
101
 
89
102
  One important caveat of this design is that the time zone database of the client environment (OS) must be properly maintained. Daylight saving time rules — for example, in Brazil — may change from year to year, and time zone definitions themselves are determined by laws that are frequently revised. This means that the underlying time zone database must be kept up to date.
90
103
 
@@ -348,8 +361,8 @@ Copyright (c) 2021 [Urin](https://github.com/urin)
348
361
  [image-npm-version]: https://img.shields.io/npm/v/qrono.svg?style=flat
349
362
  [url-npm]: https://npmjs.org/package/qrono
350
363
 
351
- [image-npm-downloads]: https://img.shields.io/npm/dy/qrono.svg?style=flat
352
- [url-npm-downloads]: https://npmcharts.com/compare/qrono?minimal=true
364
+ [image-downloads]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/urin/my-actions/main/badges/downloads.json
365
+ [url-downloads]: https://npmcharts.com/compare/qrono?minimal=true
353
366
 
354
367
  [image-size]: https://img.badgesize.io/https://unpkg.com/qrono/dist/qrono.min.js?compression=gzip&color=blue
355
368
  [url-size]: https://unpkg.com/qrono/dist/qrono.min.js
package/dist/qrono.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var K=Object.defineProperty;var W=Object.getOwnPropertySymbols;var tt=Object.prototype.hasOwnProperty,et=Object.prototype.propertyIsEnumerable;var k=(t,e,n)=>e in t?K(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,A=(t,e)=>{for(var n in e||(e={}))tt.call(e,n)&&k(t,n,e[n]);if(W)for(var n of W(e))et.call(e,n)&&k(t,n,e[n]);return t};Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const nt=new Date(1915,0,1,12,0,0,0),M=7,L=24,v=60,E=v*L,B=60,it=B*v,ot=it*L,x=1e3,z=B*x,$=ot*x,Q=1,Z=2,U=3,T=4,q=5,V=6,G=7;function w(t,...e){return e.flat().some(t.hasOwnProperty,t)}function N(t){return Object.entries(t).filter(([,e])=>!rt(e)).map(([e])=>e)}function m(t){return t!==void 0}function rt(t){return t instanceof Function}function st(t){return typeof t=="string"||t instanceof String}function b(t){return t!==null&&typeof t=="object"&&t.constructor===Object}function J(t){return!isNaN(t.getTime())}function Y(t){return w(t,["year","month","day","hour","minute","second","millisecond"])}function C(t,e){const n=e.getTime(),c=new Date(n),a=new Date(n),o=t?1:-1;a.setDate(e.getDate()+o);const u=a.getTimezoneOffset()-e.getTimezoneOffset();if(t&&u<0||!t&&u>0){const y=new Date(n).setMinutes(e.getMinutes()+o*u),d=new Date(n).setUTCMinutes(e.getUTCMinutes()+o*u);y!==d&&(y-d)/z!==u&&c.setUTCMinutes(e.getUTCMinutes()+o*u)}return c}const F=i;i.date=r;const g={localtime:!1,interpretAsDst:!1};N(g).forEach(t=>{i[t]=function(e){return m(e)?(g[t]=e,this):g[t]}});i.context=function(t){return m(t)?(N(g).filter(e=>w(t,e)).forEach(e=>{g[e]=t[e]}),this):A({},g)};i.asUtc=function(){return g.localtime=!1,this};i.asLocaltime=function(){return g.localtime=!0,this};Object.assign(i,{monday:Q,tuesday:Z,wednesday:U,thursday:T,friday:q,saturday:V,sunday:G});const s=Symbol("Qrono.internal");function i(...t){var a;if(!new.target)return new i(...t);const e=this[s]={nativeDate:null,localtime:!1,interpretAsDst:!1,set:ht,parse:lt,valid:at,context:ut,getNative:ct};if(e.context(g),t[0]instanceof i){const o=t.shift();N(e).forEach(u=>{e[u]=o[u]()})}b(t[0])&&!Y(t[0])&&e.context(t.shift());const n=t[0],c=t[1];if(n==null)(a=e.nativeDate)!=null||(e.nativeDate=new Date);else if(n instanceof Date)e.nativeDate=new Date(n.getTime());else if(st(n))e.parse(n);else if(b(n)){if(!Y(n))throw RangeError("Missing time field (year, minute, day, hour, minute, second or millisecond)");e.set(n)}else if(Number.isFinite(n)&&!Number.isFinite(c))e.nativeDate=new Date(n);else if(Number.isFinite(n)||Array.isArray(n)){const o=t.flat().filter(u=>Number.isSafeInteger(u));if(o.length!==t.flat().length)throw RangeError("Should be safe integers");if(o.length>7)throw RangeError("Too many numbers");e.set({year:o[0],month:o[1],day:o[2],hour:o[3],minute:o[4],second:o[5],millisecond:o[6]})}else throw TypeError(`Invalid argument ${t}`);return this}function at(){return J(this.nativeDate)}function ut(t){if(t)return N(g).filter(e=>w(t,e)).forEach(e=>{this[e]=t[e]}),this}function ct(t){return this.nativeDate[`get${this.localtime?"":"UTC"}${t}`]()}function ht(t){var n,c,a,o,u,y,d,f,p,D,O,I,H,P,j,R;const e=A({},t);if(e.month=e.month&&e.month-1,this.localtime){const h=(n=this.nativeDate)!=null?n:new Date(0,0),S=new Date(nt.getTime());S.setFullYear((c=e.year)!=null?c:h.getFullYear(),(a=e.month)!=null?a:h.getMonth(),(o=e.day)!=null?o:h.getDate()),S.setHours((u=e.hour)!=null?u:h.getHours(),(y=e.minute)!=null?y:h.getMinutes(),(d=e.second)!=null?d:h.getSeconds(),(f=e.millisecond)!=null?f:h.getMilliseconds()),this.nativeDate=C(this.interpretAsDst,S)}else{const h=(p=this.nativeDate)!=null?p:new Date(0),S=new Date(0);S.setUTCFullYear((D=e.year)!=null?D:h.getUTCFullYear(),(O=e.month)!=null?O:h.getUTCMonth(),(I=e.day)!=null?I:h.getUTCDate()),S.setUTCHours((H=e.hour)!=null?H:h.getUTCHours(),(P=e.minute)!=null?P:h.getUTCMinutes(),(j=e.second)!=null?j:h.getUTCSeconds(),(R=e.millisecond)!=null?R:h.getUTCMilliseconds()),this.nativeDate=S}return this}const ft=new RegExp("^(\\d{4})(?:[-/]?([0-2]?\\d)(?:[-/]?([0-3]?\\d))?)?(?:[T\\s]([0-2]?\\d)(?::([0-5]?\\d)?(?::([0-6]?\\d)?(?:[.:](\\d{1,3})?\\d*)?)?)?)?(Z|[-+]\\d{2}:?\\d{2})?$");function lt(t){var O;const e=t.trim().toUpperCase(),n=e.match(ft);if(!n)throw RangeError(`Failed to parse '${t}'. Should be yyyy[[-|/]MM[[-|/]DD]][(T| )HH:mm[:ss[(.|:)SSS]]][Z|(+|-)hh:mm]`);const[c,a,o,u,y,d,f,p]=[+n[1],+n[2]||1,+n[3]||1,+n[4]||0,+n[5]||0,+n[6]||0,+((O=n[7])==null?void 0:O.padStart(3,"0"))||0,n[8]],D=new Date(e);if(!J(D))throw RangeError(`Failed to parse '${t}' by Date. Should be yyyy[[-|/]MM[[-|/]DD]][(T| )HH:mm[:ss[(.|:)SSS]]][Z|(+|-)hh:mm]`);return p?this.nativeDate=D:this.localtime?this.nativeDate=C(this.interpretAsDst,D):this.set({year:c,month:a,day:o,hour:u,minute:y,second:d,millisecond:f}),this}i.prototype.toString=function(){if(this[s].localtime){const t=this[s].nativeDate,e=-t.getTimezoneOffset(),n=Math.abs(e);return`${String(t.getFullYear()).padStart(4,"0")}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}T${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}.${String(t.getMilliseconds()).padStart(3,"0")}${(e>=0?"+":"-")+String(Math.trunc(n/v)).padStart(2,"0")+":"+String(n%v).padStart(2,"0")}`}return this[s].nativeDate.toISOString()};i.prototype.valueOf=function(){return this[s].nativeDate.valueOf()};i.prototype.clone=function(...t){return new i(this,...t)};i.prototype.context=function(t){return m(t)?this.clone(t):{localtime:this[s].localtime,interpretAsDst:this[s].interpretAsDst}};i.prototype.nativeDate=function(){return new Date(this[s].nativeDate.getTime())};i.prototype.offset=function(){return this[s].localtime?-this[s].nativeDate.getTimezoneOffset():0};i.prototype.localtime=function(t){return m(t)?this.clone({localtime:t}):this[s].localtime};i.prototype.interpretAsDst=function(t){return m(t)?this.clone({interpretAsDst:t}):this[s].interpretAsDst};i.prototype.valid=function(){return this[s].valid()};i.prototype.numeric=function(){return this[s].nativeDate.getTime()};i.prototype.toObject=function(){return{year:this.year(),month:this.month(),day:this.day(),hour:this.hour(),minute:this.minute(),second:this.second(),millisecond:this.millisecond()}};i.prototype.toArray=function(){return[this.year(),this.month(),this.day(),this.hour(),this.minute(),this.second(),this.millisecond()]};i.prototype.toDate=function(...t){return new r(this.clone(...t))};i.prototype.asUtc=function(){return this.clone({localtime:!1})};i.prototype.asLocaltime=function(){return this.clone({localtime:!0})};i.prototype.year=function(t){return m(t)?this.clone({year:t}):this[s].getNative("FullYear")};i.prototype.month=function(t){return m(t)?this.clone({month:t}):this[s].getNative("Month")+1};i.prototype.day=function(t){return m(t)?this.clone({day:t}):this[s].getNative("Date")};i.prototype.hour=function(t){return m(t)?this.clone({hour:t}):this[s].getNative("Hours")};i.prototype.minute=function(t){return m(t)?this.clone({minute:t}):this[s].getNative("Minutes")};i.prototype.second=function(t){return m(t)?this.clone({second:t}):this[s].getNative("Seconds")};i.prototype.millisecond=function(t){return m(t)?this.clone({millisecond:t}):this[s].getNative("Milliseconds")};i.prototype.dayOfWeek=function(){return 1+(this[s].getNative("Day")-1+M)%M};i.prototype.dayOfYear=function(){const t=this.toDate();return 1+t-t.startOfYear()};i.prototype.weekOfYear=function(){const t=this.toDate(),e=t.day(t.day()-t.dayOfWeek()+T),n=e.startOfYear(),c=n.dayOfWeek()===T?n:n.day(1+(T-n.dayOfWeek()+M)%M);return 1+Math.ceil((e-c)/M)};i.prototype.yearOfWeek=function(){const t=this.toDate();return t.day(t.day()-t.dayOfWeek()+T).year()};i.prototype.isLeapYear=function(){const t=this.year();return t%4===0&&(t%100!==0||t%400===0)};i.prototype.hasDstInYear=function(){if(!this[s].localtime)return!1;const t=this.offset();return[3,6,9,12].map(e=>this.month(e).offset()).some(e=>e!==t)};i.prototype.isInDst=function(){return this[s].localtime?this.offset()===Math.max(...[3,6,9,12].map(t=>this.month(t).offset())):!1};i.prototype.isDstTransitionDay=function(){return this[s].localtime?this.minutesInDay()!==E:!1};i.prototype.minutesInDay=function(){if(!this[s].localtime)return E;const t=this.startOfDay(),e=t.plus({day:1}).startOfDay();return t.day()===e.day()?E:(e-t)/z};i.prototype.daysInMonth=function(){const t=[31,28,31,30,31,30,31,31,30,31,30,31],e=this.month();return t[e-1]+(this.isLeapYear()&&e===2?1:0)};i.prototype.daysInYear=function(){return this.isLeapYear()?366:365};i.prototype.weeksInYear=function(){const t=this.toDate({month:12,day:31}),e=t.minus({year:1});return t.dayOfWeek()===T||e.dayOfWeek()===U?53:52};i.prototype.startOfYear=function(){return this.clone({month:1,day:1,hour:0,minute:0,second:0,millisecond:0})};i.prototype.startOfMonth=function(){return this.clone({day:1,hour:0,minute:0,second:0,millisecond:0})};i.prototype.startOfDay=function(){return this.clone({hour:0,minute:0,second:0,millisecond:0})};i.prototype.startOfHour=function(){return this.clone({minute:0,second:0,millisecond:0})};i.prototype.startOfMinute=function(){return this.clone({second:0,millisecond:0})};i.prototype.startOfSecond=function(){return this.clone({millisecond:0})};i.prototype.isSame=function(t){return+this==+t};i.prototype.isBefore=function(t){return this<t};i.prototype.isAfter=function(t){return this>t};i.prototype.isSameOrBefore=function(t){return this<=t};i.prototype.isSameOrAfter=function(t){return this>=t};i.prototype.isBetween=function(t,e){return t<=this&&this<=e||e<=this&&this<=t};i.prototype.plus=function(...t){return X.call(this,1,...t)};i.prototype.minus=function(...t){return X.call(this,-1,...t)};function X(t,...e){var y,d;const n=e[0],c=e[1];if(Number.isFinite(n)&&!Number.isFinite(c))return this.clone(this.numeric()+n);let a=null;if(b(n)){if(!Y(n))throw RangeError("Missing time field (year, minute, day, hour, minute, second or millisecond)");a=n}else if(Number.isFinite(n)||Array.isArray(n)){const f=e.flat().filter(p=>Number.isSafeInteger(p));if(f.length!==e.flat().length)throw RangeError("Should be safe integers");if(f.length>7)throw RangeError("Too many numbers");a={year:e[0],month:e[1],day:e[2],hour:e[3],minute:e[4],second:e[5],millisecond:e[6]}}else throw TypeError();const o=this.nativeDate(),u=this[s].localtime?"":"UTC";if(w(a,"year")||w(a,"month")){const f=this.year()+t*((y=a.year)!=null?y:0),p=this.month()+t*((d=a.month)!=null?d:0),D=new Date(o.getTime());D[`set${u}FullYear`](f,p,0);const O=D.getDate();O<this.day()?o[`set${u}FullYear`](f,D[`get${u}Month`](),O):o[`set${u}FullYear`](f,p-1)}return w(a,"day")&&o[`set${u}Date`](o[`get${u}Date`]()+t*a.day),[["hour","Hours"],["minute","Minutes"],["second","Seconds"],["millisecond","Milliseconds"]].forEach(([f,p])=>{w(a,f)&&o[`setUTC${p}`](o[`getUTC${p}`]()+t*a[f])}),this.clone(C(this[s].interpretAsDst,o))}const l=Symbol("QronoDate.internal");function r(...t){if(!new.target)return new r(...t);const e=this[l]={datetime:null};let n=null;t[0]instanceof r&&(n=t.shift().toDatetime());const c=t[0],a=t[1];return Number.isFinite(c)&&!Number.isFinite(a)&&(t[0]*=$),n=(n?n.clone(...t):F(...t)).startOfDay(),e.datetime=F({localtime:!1},n.toObject()),this}r.prototype.toString=function(){return this[l].datetime.toString().substring(0,10)};r.prototype.valueOf=function(){return this[l].datetime/$};r.prototype.valid=function(){return this[l].datetime.valid()};r.prototype.clone=function(...t){return new r(this,...t)};r.prototype.toDatetime=function(){return F(this[l].datetime.toArray())};r.prototype.numeric=function(){return this[l].datetime.numeric()/$};r.prototype.toObject=function(){return{year:this.year(),month:this.month(),day:this.day()}};r.prototype.toArray=function(){return[this.year(),this.month(),this.day()]};r.prototype.startOfYear=function(){return new r(this[l].datetime.startOfYear())};r.prototype.startOfMonth=function(){return new r(this[l].datetime.startOfMonth())};r.prototype.startOfDay=function(){return this[l].datetime.clone()};["year","month","day"].forEach(t=>{r.prototype[t]=function(e){return m(e)?new r(this[l].datetime[t](e)):this[l].datetime[t]()}});["dayOfWeek","dayOfYear","weekOfYear","yearOfWeek","isLeapYear","daysInMonth","daysInYear","weeksInYear"].forEach(t=>{r.prototype[t]=function(){return this[l].datetime[t]()}});["minutesInDay","hasDstInYear","isDstTransitionDay"].forEach(t=>{r.prototype[t]=function(){return this[l].datetime.localtime(!0)[t]()}});r.prototype.endOfYear=function(){return this.clone({month:12,day:31})};r.prototype.endOfMonth=function(){return this.clone({day:this.daysInMonth()})};r.prototype.isSame=function(t){return+this==+t};r.prototype.isBefore=function(t){return this<t};r.prototype.isAfter=function(t){return this>t};r.prototype.isSameOrBefore=function(t){return this<=t};r.prototype.isSameOrAfter=function(t){return this>=t};r.prototype.isBetween=function(t,e){return t<=this&&this<=e||e<=this&&this<=t};r.prototype.plus=function(...t){return _.call(this,1,...t)};r.prototype.minus=function(...t){return _.call(this,-1,...t)};function _(t,...e){var u,y,d;const n=e[0],c=e[1],a=this[l].datetime;if(Number.isFinite(n)&&!Number.isFinite(c))return a.plus({day:t*n}).toDate();let o=null;if(b(n)&&Y(n))o={year:t*((u=n.year)!=null?u:0),month:t*((y=n.month)!=null?y:0),day:t*((d=n.day)!=null?d:0)};else if(Number.isFinite(n)){if(e.length>3)throw RangeError("Too many arguments");o={year:e[0],month:e[1],day:e[2]}}else if(Array.isArray(n)){if(n.length>3)throw RangeError("Too many elements");o={year:n[0],month:n[1],day:n[2]}}else throw TypeError();return a.plus(o).toDate()}exports.friday=q;exports.monday=Q;exports.qrono=F;exports.saturday=V;exports.sunday=G;exports.thursday=T;exports.tuesday=Z;exports.wednesday=U;
1
+ "use strict";var _=Object.defineProperty;var W=Object.getOwnPropertySymbols;var K=Object.prototype.hasOwnProperty,tt=Object.prototype.propertyIsEnumerable;var k=(t,e,n)=>e in t?_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,N=(t,e)=>{for(var n in e||(e={}))K.call(e,n)&&k(t,n,e[n]);if(W)for(var n of W(e))tt.call(e,n)&&k(t,n,e[n]);return t};Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const et=new Date(1915,0,1,12,0,0,0),M=7,L=24,v=60,E=v*L,x=60,nt=x*v,it=nt*L,B=1e3,ot=x*B,$=it*B,z=1,Q=2,U=3,T=4,Z=5,q=6,V=7;function w(t,...e){return e.flat().some(t.hasOwnProperty,t)}function A(t){return Object.entries(t).filter(([,e])=>!rt(e)).map(([e])=>e)}function m(t){return t!==void 0}function rt(t){return t instanceof Function}function st(t){return typeof t=="string"||t instanceof String}function b(t){return t!==null&&typeof t=="object"&&t.constructor===Object}function G(t){return!isNaN(t.getTime())}function Y(t){return w(t,["year","month","day","hour","minute","second","millisecond"])}function C(t,e){const n=e.getTime(),c=new Date(n);if(t)return c;const a=new Date(n);a.setDate(e.getDate()+1);const o=new Date(n);o.setDate(e.getDate()-1);const u=a.getTimezoneOffset()-o.getTimezoneOffset();if(u===0)return c;const f=new Date(n).setMinutes(e.getMinutes()+u),d=new Date(n).setUTCMinutes(e.getUTCMinutes()+u);return f===d||u<0&&f===n||u>0&&f!==n?c:new Date(d)}const F=i;i.date=r;const g={localtime:!1,interpretAsDst:!0};A(g).forEach(t=>{i[t]=function(e){return m(e)?(g[t]=e,this):g[t]}});i.context=function(t){return m(t)?(A(g).filter(e=>w(t,e)).forEach(e=>{g[e]=t[e]}),this):N({},g)};i.asUtc=function(){return g.localtime=!1,this};i.asLocaltime=function(){return g.localtime=!0,this};Object.assign(i,{monday:z,tuesday:Q,wednesday:U,thursday:T,friday:Z,saturday:q,sunday:V});const s=Symbol("Qrono.internal");function i(...t){var a;if(!new.target)return new i(...t);const e=this[s]={nativeDate:null,localtime:!1,interpretAsDst:!1,set:ht,parse:lt,valid:at,context:ut,getNative:ct};if(e.context(g),t[0]instanceof i){const o=t.shift();A(e).forEach(u=>{e[u]=o[u]()})}b(t[0])&&!Y(t[0])&&e.context(t.shift());const n=t[0],c=t[1];if(n==null)(a=e.nativeDate)!=null||(e.nativeDate=new Date);else if(n instanceof Date)e.nativeDate=new Date(n.getTime());else if(st(n))e.parse(n);else if(b(n)){if(!Y(n))throw RangeError("Missing time field (year, minute, day, hour, minute, second or millisecond)");e.set(n)}else if(Number.isFinite(n)&&!Number.isFinite(c))e.nativeDate=new Date(n);else if(Number.isFinite(n)||Array.isArray(n)){const o=t.flat().filter(u=>Number.isSafeInteger(u));if(o.length!==t.flat().length)throw RangeError("Should be safe integers");if(o.length>7)throw RangeError("Too many numbers");e.set({year:o[0],month:o[1],day:o[2],hour:o[3],minute:o[4],second:o[5],millisecond:o[6]})}else throw TypeError(`Invalid argument ${t}`);return this}function at(){return G(this.nativeDate)}function ut(t){if(t)return A(g).filter(e=>w(t,e)).forEach(e=>{this[e]=t[e]}),this}function ct(t){return this.nativeDate[`get${this.localtime?"":"UTC"}${t}`]()}function ht(t){var n,c,a,o,u,f,d,l,p,D,O,I,H,P,j,R;const e=N({},t);if(e.month=e.month&&e.month-1,this.localtime){const h=(n=this.nativeDate)!=null?n:new Date(0,0),S=new Date(et.getTime());S.setFullYear((c=e.year)!=null?c:h.getFullYear(),(a=e.month)!=null?a:h.getMonth(),(o=e.day)!=null?o:h.getDate()),S.setHours((u=e.hour)!=null?u:h.getHours(),(f=e.minute)!=null?f:h.getMinutes(),(d=e.second)!=null?d:h.getSeconds(),(l=e.millisecond)!=null?l:h.getMilliseconds()),this.nativeDate=C(this.interpretAsDst,S)}else{const h=(p=this.nativeDate)!=null?p:new Date(0),S=new Date(0);S.setUTCFullYear((D=e.year)!=null?D:h.getUTCFullYear(),(O=e.month)!=null?O:h.getUTCMonth(),(I=e.day)!=null?I:h.getUTCDate()),S.setUTCHours((H=e.hour)!=null?H:h.getUTCHours(),(P=e.minute)!=null?P:h.getUTCMinutes(),(j=e.second)!=null?j:h.getUTCSeconds(),(R=e.millisecond)!=null?R:h.getUTCMilliseconds()),this.nativeDate=S}return this}const ft=new RegExp("^(\\d{4})(?:[-/]?([0-2]?\\d)(?:[-/]?([0-3]?\\d))?)?(?:[T\\s]([0-2]?\\d)(?::([0-5]?\\d)?(?::([0-6]?\\d)?(?:[.:](\\d{1,3})?\\d*)?)?)?)?(Z|[-+]\\d{2}:?\\d{2})?$");function lt(t){var O;const e=t.trim().toUpperCase(),n=e.match(ft);if(!n)throw RangeError(`Failed to parse '${t}'. Should be yyyy[[-|/]MM[[-|/]DD]][(T| )HH:mm[:ss[(.|:)SSS]]][Z|(+|-)hh:mm]`);const[c,a,o,u,f,d,l,p]=[+n[1],+n[2]||1,+n[3]||1,+n[4]||0,+n[5]||0,+n[6]||0,+((O=n[7])==null?void 0:O.padStart(3,"0"))||0,n[8]],D=new Date(e);if(!G(D))throw RangeError(`Failed to parse '${t}' by Date. Should be yyyy[[-|/]MM[[-|/]DD]][(T| )HH:mm[:ss[(.|:)SSS]]][Z|(+|-)hh:mm]`);return p?this.nativeDate=D:this.localtime?this.nativeDate=C(this.interpretAsDst,D):this.set({year:c,month:a,day:o,hour:u,minute:f,second:d,millisecond:l}),this}i.prototype.toString=function(){if(this[s].localtime){const t=this[s].nativeDate,e=-t.getTimezoneOffset(),n=Math.abs(e);return`${String(t.getFullYear()).padStart(4,"0")}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}T${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}.${String(t.getMilliseconds()).padStart(3,"0")}${(e>=0?"+":"-")+String(Math.trunc(n/v)).padStart(2,"0")+":"+String(n%v).padStart(2,"0")}`}return this[s].nativeDate.toISOString()};i.prototype.valueOf=function(){return this[s].nativeDate.valueOf()};i.prototype.clone=function(...t){return new i(this,...t)};i.prototype.context=function(t){return m(t)?this.clone(t):{localtime:this[s].localtime,interpretAsDst:this[s].interpretAsDst}};i.prototype.nativeDate=function(){return new Date(this[s].nativeDate.getTime())};i.prototype.offset=function(){return this[s].localtime?-this[s].nativeDate.getTimezoneOffset():0};i.prototype.localtime=function(t){return m(t)?this.clone({localtime:t}):this[s].localtime};i.prototype.interpretAsDst=function(t){return m(t)?this.clone({interpretAsDst:t}):this[s].interpretAsDst};i.prototype.valid=function(){return this[s].valid()};i.prototype.numeric=function(){return this[s].nativeDate.getTime()};i.prototype.toObject=function(){return{year:this.year(),month:this.month(),day:this.day(),hour:this.hour(),minute:this.minute(),second:this.second(),millisecond:this.millisecond()}};i.prototype.toArray=function(){return[this.year(),this.month(),this.day(),this.hour(),this.minute(),this.second(),this.millisecond()]};i.prototype.toDate=function(...t){return new r(this.clone(...t))};i.prototype.asUtc=function(){return this.clone({localtime:!1})};i.prototype.asLocaltime=function(){return this.clone({localtime:!0})};i.prototype.year=function(t){return m(t)?this.clone({year:t}):this[s].getNative("FullYear")};i.prototype.month=function(t){return m(t)?this.clone({month:t}):this[s].getNative("Month")+1};i.prototype.day=function(t){return m(t)?this.clone({day:t}):this[s].getNative("Date")};i.prototype.hour=function(t){return m(t)?this.clone({hour:t}):this[s].getNative("Hours")};i.prototype.minute=function(t){return m(t)?this.clone({minute:t}):this[s].getNative("Minutes")};i.prototype.second=function(t){return m(t)?this.clone({second:t}):this[s].getNative("Seconds")};i.prototype.millisecond=function(t){return m(t)?this.clone({millisecond:t}):this[s].getNative("Milliseconds")};i.prototype.dayOfWeek=function(){return 1+(this[s].getNative("Day")-1+M)%M};i.prototype.dayOfYear=function(){const t=this.toDate();return 1+t-t.startOfYear()};i.prototype.weekOfYear=function(){const t=this.toDate(),e=t.day(t.day()-t.dayOfWeek()+T),n=e.startOfYear(),c=n.dayOfWeek()===T?n:n.day(1+(T-n.dayOfWeek()+M)%M);return 1+Math.ceil((e-c)/M)};i.prototype.yearOfWeek=function(){const t=this.toDate();return t.day(t.day()-t.dayOfWeek()+T).year()};i.prototype.isLeapYear=function(){const t=this.year();return t%4===0&&(t%100!==0||t%400===0)};i.prototype.hasDstInYear=function(){if(!this[s].localtime)return!1;const t=this.offset();return[3,6,9,12].map(e=>this.month(e).offset()).some(e=>e!==t)};i.prototype.isInDst=function(){return this[s].localtime?this.offset()===Math.max(...[3,6,9,12].map(t=>this.month(t).offset())):!1};i.prototype.isDstTransitionDay=function(){return this[s].localtime?this.minutesInDay()!==E:!1};i.prototype.minutesInDay=function(){if(!this[s].localtime)return E;const t=this.startOfDay(),e=t.plus({day:1}).startOfDay();return t.day()===e.day()?E:(e-t)/ot};i.prototype.daysInMonth=function(){const t=[31,28,31,30,31,30,31,31,30,31,30,31],e=this.month();return t[e-1]+(this.isLeapYear()&&e===2?1:0)};i.prototype.daysInYear=function(){return this.isLeapYear()?366:365};i.prototype.weeksInYear=function(){const t=this.toDate({month:12,day:31}),e=t.minus({year:1});return t.dayOfWeek()===T||e.dayOfWeek()===U?53:52};i.prototype.startOfYear=function(){return this.clone({month:1,day:1,hour:0,minute:0,second:0,millisecond:0})};i.prototype.startOfMonth=function(){return this.clone({day:1,hour:0,minute:0,second:0,millisecond:0})};i.prototype.startOfDay=function(){return this.clone({hour:0,minute:0,second:0,millisecond:0})};i.prototype.startOfHour=function(){return this.clone({minute:0,second:0,millisecond:0})};i.prototype.startOfMinute=function(){return this.clone({second:0,millisecond:0})};i.prototype.startOfSecond=function(){return this.clone({millisecond:0})};i.prototype.isSame=function(t){return+this==+t};i.prototype.isBefore=function(t){return this<t};i.prototype.isAfter=function(t){return this>t};i.prototype.isSameOrBefore=function(t){return this<=t};i.prototype.isSameOrAfter=function(t){return this>=t};i.prototype.isBetween=function(t,e){return t<=this&&this<=e||e<=this&&this<=t};i.prototype.plus=function(...t){return J.call(this,1,...t)};i.prototype.minus=function(...t){return J.call(this,-1,...t)};function J(t,...e){var f,d;const n=e[0],c=e[1];if(Number.isFinite(n)&&!Number.isFinite(c))return this.clone(this.numeric()+n);let a=null;if(b(n)){if(!Y(n))throw RangeError("Missing time field (year, minute, day, hour, minute, second or millisecond)");a=n}else if(Number.isFinite(n)||Array.isArray(n)){const l=e.flat().filter(p=>Number.isSafeInteger(p));if(l.length!==e.flat().length)throw RangeError("Should be safe integers");if(l.length>7)throw RangeError("Too many numbers");a={year:e[0],month:e[1],day:e[2],hour:e[3],minute:e[4],second:e[5],millisecond:e[6]}}else throw TypeError();const o=this.nativeDate(),u=this[s].localtime?"":"UTC";if(w(a,"year")||w(a,"month")){const l=this.year()+t*((f=a.year)!=null?f:0),p=this.month()+t*((d=a.month)!=null?d:0),D=new Date(o.getTime());D[`set${u}FullYear`](l,p,0);const O=D.getDate();O<this.day()?o[`set${u}FullYear`](l,D[`get${u}Month`](),O):o[`set${u}FullYear`](l,p-1)}return w(a,"day")&&o[`set${u}Date`](o[`get${u}Date`]()+t*a.day),[["hour","Hours"],["minute","Minutes"],["second","Seconds"],["millisecond","Milliseconds"]].forEach(([l,p])=>{w(a,l)&&o[`setUTC${p}`](o[`getUTC${p}`]()+t*a[l])}),this.clone(C(this[s].interpretAsDst,o))}const y=Symbol("QronoDate.internal");function r(...t){if(!new.target)return new r(...t);const e=this[y]={datetime:null};let n=null;t[0]instanceof r&&(n=t.shift().toDatetime());const c=t[0],a=t[1];return Number.isFinite(c)&&!Number.isFinite(a)&&(t[0]*=$),n=(n?n.clone(...t):F(...t)).startOfDay(),e.datetime=F({localtime:!1},n.toObject()),this}r.prototype.toString=function(){return this[y].datetime.toString().substring(0,10)};r.prototype.valueOf=function(){return this[y].datetime/$};r.prototype.valid=function(){return this[y].datetime.valid()};r.prototype.clone=function(...t){return new r(this,...t)};r.prototype.toDatetime=function(){return F(this[y].datetime.toArray())};r.prototype.numeric=function(){return this[y].datetime.numeric()/$};r.prototype.toObject=function(){return{year:this.year(),month:this.month(),day:this.day()}};r.prototype.toArray=function(){return[this.year(),this.month(),this.day()]};r.prototype.startOfYear=function(){return new r(this[y].datetime.startOfYear())};r.prototype.startOfMonth=function(){return new r(this[y].datetime.startOfMonth())};r.prototype.startOfDay=function(){return this[y].datetime.clone()};["year","month","day"].forEach(t=>{r.prototype[t]=function(e){return m(e)?new r(this[y].datetime[t](e)):this[y].datetime[t]()}});["dayOfWeek","dayOfYear","weekOfYear","yearOfWeek","isLeapYear","daysInMonth","daysInYear","weeksInYear"].forEach(t=>{r.prototype[t]=function(){return this[y].datetime[t]()}});["minutesInDay","hasDstInYear","isDstTransitionDay"].forEach(t=>{r.prototype[t]=function(){return this[y].datetime.localtime(!0)[t]()}});r.prototype.endOfYear=function(){return this.clone({month:12,day:31})};r.prototype.endOfMonth=function(){return this.clone({day:this.daysInMonth()})};r.prototype.isSame=function(t){return+this==+t};r.prototype.isBefore=function(t){return this<t};r.prototype.isAfter=function(t){return this>t};r.prototype.isSameOrBefore=function(t){return this<=t};r.prototype.isSameOrAfter=function(t){return this>=t};r.prototype.isBetween=function(t,e){return t<=this&&this<=e||e<=this&&this<=t};r.prototype.plus=function(...t){return X.call(this,1,...t)};r.prototype.minus=function(...t){return X.call(this,-1,...t)};function X(t,...e){var u,f,d;const n=e[0],c=e[1],a=this[y].datetime;if(Number.isFinite(n)&&!Number.isFinite(c))return a.plus({day:t*n}).toDate();let o=null;if(b(n)&&Y(n))o={year:t*((u=n.year)!=null?u:0),month:t*((f=n.month)!=null?f:0),day:t*((d=n.day)!=null?d:0)};else if(Number.isFinite(n)){if(e.length>3)throw RangeError("Too many arguments");o={year:e[0],month:e[1],day:e[2]}}else if(Array.isArray(n)){if(n.length>3)throw RangeError("Too many elements");o={year:n[0],month:n[1],day:n[2]}}else throw TypeError();return a.plus(o).toDate()}exports.friday=Z;exports.monday=z;exports.qrono=F;exports.saturday=q;exports.sunday=V;exports.thursday=T;exports.tuesday=Q;exports.wednesday=U;
2
2
  //# sourceMappingURL=qrono.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"qrono.cjs","sources":["../src/helpers.js","../src/qrono.js"],"sourcesContent":["export const epoch = new Date(0)\n\n// When creating or updating a local time, both `Date.setFullYear` and `Date.setHours` are used.\n// Noon is used as the initial reference point to avoid the time after `setFullYear`\n// from falling into an ambiguous DST period. Historically, DST transitions in all countries\n// have been scheduled around midnight, and it should be the same in the future.\n// The reason for selecting 1915 as the initial value is as follows.\n// Since DST was first established in 1916, the initial value should be set to a year prior to that.\n// If a year too far in the past is chosen, it may correspond to a period when time zones were not yet\n// precisely defined in some regions, which could result in unexpected timezone offsets.\nexport const initialSafeDate = new Date(1915, 0, 1, 12, 0, 0, 0)\n\nexport const daysPerWeek = 7\nexport const hoursPerDay = 24\nexport const hoursPerWeek = hoursPerDay * daysPerWeek\nexport const minutesPerHour = 60\nexport const minutesPerDay = minutesPerHour * hoursPerDay\nexport const minutesPerWeek = minutesPerDay * daysPerWeek\nexport const secondsPerMinute = 60\nexport const secondsPerHour = secondsPerMinute * minutesPerHour\nexport const secondsPerDay = secondsPerHour * hoursPerDay\nexport const secondsPerWeek = secondsPerDay * daysPerWeek\nexport const millisecondsPerSecond = 1000\nexport const millisecondsPerMinute = secondsPerMinute * millisecondsPerSecond\nexport const millisecondsPerHour = secondsPerHour * millisecondsPerSecond\nexport const millisecondsPerDay = secondsPerDay * millisecondsPerSecond\nexport const millisecondsPerWeek = secondsPerWeek * millisecondsPerSecond\n\nexport const monday = 1\nexport const tuesday = 2\nexport const wednesday = 3\nexport const thursday = 4\nexport const friday = 5\nexport const saturday = 6\nexport const sunday = 7\n\nexport function has(object, ...keys) {\n return keys.flat().some(object.hasOwnProperty, object)\n}\n\nexport function fields(object) {\n return Object.entries(object)\n .filter(([, value]) => !isFunction(value))\n .map(([key]) => key)\n}\n\nexport function given(arg) {\n return arg !== undefined\n}\n\nexport function isFunction(a) {\n return a instanceof Function\n}\n\nexport function isString(a) {\n return typeof a === 'string' || a instanceof String\n}\n\nexport function isObject(a) {\n return a !== null && typeof a === 'object' && a.constructor === Object\n}\n\nexport function isValidDate(date) {\n return !isNaN(date.getTime())\n}\n\nexport function hasDateField(object) {\n return has(object, ['year', 'month', 'day'])\n}\n\nexport function hasTimeField(object) {\n return has(object, ['hour', 'minute', 'second', 'millisecond'])\n}\n\nexport function hasDatetimeField(object) {\n return has(object, [\n 'year',\n 'month',\n 'day',\n 'hour',\n 'minute',\n 'second',\n 'millisecond',\n ])\n}\n\nexport function asDst(interpretAsDst, date) {\n const numeric = date.getTime()\n const result = new Date(numeric)\n const adjacentDay = new Date(numeric)\n const sign = interpretAsDst ? 1 : -1\n adjacentDay.setDate(date.getDate() + sign)\n const adjust = adjacentDay.getTimezoneOffset() - date.getTimezoneOffset()\n if ((interpretAsDst && adjust < 0) || (!interpretAsDst && adjust > 0)) {\n const adjusted = new Date(numeric).setMinutes(\n date.getMinutes() + sign * adjust\n )\n const adjustedUTC = new Date(numeric).setUTCMinutes(\n date.getUTCMinutes() + sign * adjust\n )\n if (\n adjusted !== adjustedUTC &&\n (adjusted - adjustedUTC) / millisecondsPerMinute !== adjust\n ) {\n result.setUTCMinutes(date.getUTCMinutes() + sign * adjust)\n }\n }\n return result\n}\n","/* @ts-self-types=\"../types/qrono.d.ts\" */\nimport {\n has,\n given,\n fields,\n isObject,\n isString,\n isValidDate,\n asDst,\n hasDatetimeField,\n initialSafeDate,\n daysPerWeek,\n minutesPerDay,\n minutesPerHour,\n millisecondsPerMinute,\n millisecondsPerDay,\n monday,\n tuesday,\n wednesday,\n thursday,\n friday,\n saturday,\n sunday,\n} from './helpers.js'\n\n// -----------------------------------------------------------------------------\n// Exports\n// -----------------------------------------------------------------------------\nconst qrono = Qrono\n\nexport { qrono }\n\nexport {\n monday,\n tuesday,\n wednesday,\n thursday,\n friday,\n saturday,\n sunday,\n} from './helpers'\n\n// -----------------------------------------------------------------------------\n// Static\n// -----------------------------------------------------------------------------\nQrono.date = QronoDate\n\n// NOTE Must be flat object for shallow cloning.\nconst defaultContext = {\n localtime: false,\n interpretAsDst: false,\n}\n\nfields(defaultContext).forEach(key => {\n Qrono[key] = function (arg) {\n if (given(arg)) {\n defaultContext[key] = arg\n return this\n }\n return defaultContext[key]\n }\n})\n\nQrono.context = function (context) {\n if (given(context)) {\n fields(defaultContext)\n .filter(key => has(context, key))\n .forEach(key => {\n defaultContext[key] = context[key]\n })\n return this\n }\n return { ...defaultContext }\n}\n\nQrono.asUtc = function () {\n defaultContext.localtime = false\n return this\n}\n\nQrono.asLocaltime = function () {\n defaultContext.localtime = true\n return this\n}\n\nObject.assign(Qrono, {\n monday,\n tuesday,\n wednesday,\n thursday,\n friday,\n saturday,\n sunday,\n})\n\n// -----------------------------------------------------------------------------\n// Constructor\n// -----------------------------------------------------------------------------\nconst internal = Symbol('Qrono.internal')\n\nfunction Qrono(...args) {\n if (!new.target) {\n return new Qrono(...args)\n }\n const self = (this[internal] = {\n // properties\n nativeDate: null,\n localtime: false,\n interpretAsDst: false,\n // methods\n set,\n parse,\n valid,\n context,\n getNative,\n })\n\n // Construction\n self.context(defaultContext)\n if (args[0] instanceof Qrono) {\n const source = args.shift()\n fields(self).forEach(key => {\n self[key] = source[key]()\n })\n }\n if (isObject(args[0]) && !hasDatetimeField(args[0])) {\n self.context(args.shift())\n }\n const first = args[0]\n const second = args[1]\n if (first == null) {\n self.nativeDate ??= new Date()\n } else if (first instanceof Date) {\n self.nativeDate = new Date(first.getTime())\n } else if (isString(first)) {\n self.parse(first)\n } else if (isObject(first)) {\n if (!hasDatetimeField(first)) {\n throw RangeError(\n 'Missing time field' +\n ' (year, minute, day, hour, minute, second or millisecond)'\n )\n }\n self.set(first)\n } else if (Number.isFinite(first) && !Number.isFinite(second)) {\n self.nativeDate = new Date(first)\n } else if (Number.isFinite(first) || Array.isArray(first)) {\n const values = args.flat().filter(v => Number.isSafeInteger(v))\n if (values.length !== args.flat().length) {\n throw RangeError('Should be safe integers')\n }\n if (values.length > 7) {\n throw RangeError('Too many numbers')\n }\n self.set({\n year: values[0],\n month: values[1],\n day: values[2],\n hour: values[3],\n minute: values[4],\n second: values[5],\n millisecond: values[6],\n })\n } else {\n throw TypeError(`Invalid argument ${args}`)\n }\n return this\n}\n\n// -----------------------------------------------------------------------------\n// Private methods\n// -----------------------------------------------------------------------------\nfunction valid() {\n return isValidDate(this.nativeDate)\n}\n\nfunction context(context) {\n if (!context) {\n return\n }\n fields(defaultContext)\n .filter(key => has(context, key))\n .forEach(key => {\n this[key] = context[key]\n })\n return this\n}\n\nfunction getNative(name) {\n return this.nativeDate[`get${this.localtime ? '' : 'UTC'}${name}`]()\n}\n\nfunction set(values) {\n const args = { ...values }\n args.month = args.month && args.month - 1\n if (this.localtime) {\n const baseDate = this.nativeDate ?? new Date(0, 0)\n const newDate = new Date(initialSafeDate.getTime())\n newDate.setFullYear(\n args.year ?? baseDate.getFullYear(),\n args.month ?? baseDate.getMonth(),\n args.day ?? baseDate.getDate()\n )\n newDate.setHours(\n args.hour ?? baseDate.getHours(),\n args.minute ?? baseDate.getMinutes(),\n args.second ?? baseDate.getSeconds(),\n args.millisecond ?? baseDate.getMilliseconds()\n )\n this.nativeDate = asDst(this.interpretAsDst, newDate)\n } else {\n const baseDate = this.nativeDate ?? new Date(0)\n const newDate = new Date(0)\n newDate.setUTCFullYear(\n args.year ?? baseDate.getUTCFullYear(),\n args.month ?? baseDate.getUTCMonth(),\n args.day ?? baseDate.getUTCDate()\n )\n newDate.setUTCHours(\n args.hour ?? baseDate.getUTCHours(),\n args.minute ?? baseDate.getUTCMinutes(),\n args.second ?? baseDate.getUTCSeconds(),\n args.millisecond ?? baseDate.getUTCMilliseconds()\n )\n this.nativeDate = newDate\n }\n return this\n}\n\nconst parsePattern = new RegExp(\n // yyyy[[-|/]MM[[-|/]DD]]\n '^(\\\\d{4})(?:[-/]?([0-2]?\\\\d)(?:[-/]?([0-3]?\\\\d))?)?' +\n // [(T| )HH[:]mm[[:]ss[(.|:)SSS]]]\n '(?:[T\\\\s]([0-2]?\\\\d)(?::([0-5]?\\\\d)?(?::([0-6]?\\\\d)?(?:[.:](\\\\d{1,3})?\\\\d*)?)?)?)?' +\n // [Z|(+|-)hh:mm]\n '(Z|[-+]\\\\d{2}:?\\\\d{2})?$'\n)\n\nfunction parse(str) {\n const text = str.trim().toUpperCase()\n const values = text.match(parsePattern)\n if (!values) {\n throw RangeError(\n `Failed to parse '${str}'.` +\n ' Should be yyyy[[-|/]MM[[-|/]DD]][(T| )HH:mm[:ss[(.|:)SSS]]][Z|(+|-)hh:mm]'\n )\n }\n const [year, month, day, hour, minute, second, millisecond, offset] = [\n +values[1],\n +values[2] || 1,\n +values[3] || 1,\n +values[4] || 0,\n +values[5] || 0,\n +values[6] || 0,\n +values[7]?.padStart(3, '0') || 0,\n values[8],\n ]\n const native = new Date(text)\n if (!isValidDate(native)) {\n throw RangeError(\n `Failed to parse '${str}' by Date.` +\n ' Should be yyyy[[-|/]MM[[-|/]DD]][(T| )HH:mm[:ss[(.|:)SSS]]][Z|(+|-)hh:mm]'\n )\n }\n if (offset) {\n this.nativeDate = native\n } else if (this.localtime) {\n this.nativeDate = asDst(this.interpretAsDst, native)\n } else {\n this.set({ year, month, day, hour, minute, second, millisecond })\n }\n return this\n}\n\n// -----------------------------------------------------------------------------\n// Public methods\n// -----------------------------------------------------------------------------\n// Basic\nQrono.prototype.toString = function () {\n if (this[internal].localtime) {\n const t = this[internal].nativeDate\n const offset = -t.getTimezoneOffset()\n const offsetAbs = Math.abs(offset)\n return `${String(t.getFullYear()).padStart(4, '0')}-${String(\n t.getMonth() + 1\n ).padStart(2, '0')}-${String(t.getDate()).padStart(2, '0')}T${String(\n t.getHours()\n ).padStart(2, '0')}:${String(t.getMinutes()).padStart(2, '0')}:${String(\n t.getSeconds()\n ).padStart(2, '0')}.${String(t.getMilliseconds()).padStart(3, '0')}${\n (offset >= 0 ? '+' : '-') +\n String(Math.trunc(offsetAbs / minutesPerHour)).padStart(2, '0') +\n ':' +\n String(offsetAbs % minutesPerHour).padStart(2, '0')\n }`\n }\n return this[internal].nativeDate.toISOString()\n}\n\nQrono.prototype.valueOf = function () {\n return this[internal].nativeDate.valueOf()\n}\n\nQrono.prototype.clone = function (...args) {\n return new Qrono(this, ...args)\n}\n\nQrono.prototype.context = function (context) {\n return given(context)\n ? this.clone(context)\n : {\n localtime: this[internal].localtime,\n interpretAsDst: this[internal].interpretAsDst,\n }\n}\n\nQrono.prototype.nativeDate = function () {\n return new Date(this[internal].nativeDate.getTime())\n}\n\nQrono.prototype.offset = function () {\n return this[internal].localtime\n ? -this[internal].nativeDate.getTimezoneOffset()\n : 0\n}\n\nQrono.prototype.localtime = function (arg) {\n return given(arg) ? this.clone({ localtime: arg }) : this[internal].localtime\n}\n\nQrono.prototype.interpretAsDst = function (arg) {\n return given(arg)\n ? this.clone({ interpretAsDst: arg })\n : this[internal].interpretAsDst\n}\n\nQrono.prototype.valid = function () {\n return this[internal].valid()\n}\n\n// Transform\nQrono.prototype.numeric = function () {\n return this[internal].nativeDate.getTime()\n}\n\nQrono.prototype.toObject = function () {\n return {\n year: this.year(),\n month: this.month(),\n day: this.day(),\n hour: this.hour(),\n minute: this.minute(),\n second: this.second(),\n millisecond: this.millisecond(),\n }\n}\n\nQrono.prototype.toArray = function () {\n return [\n this.year(),\n this.month(),\n this.day(),\n this.hour(),\n this.minute(),\n this.second(),\n this.millisecond(),\n ]\n}\n\nQrono.prototype.toDate = function (...args) {\n return new QronoDate(this.clone(...args))\n}\n\n// Context\nQrono.prototype.asUtc = function () {\n return this.clone({ localtime: false })\n}\n\nQrono.prototype.asLocaltime = function () {\n return this.clone({ localtime: true })\n}\n\n// Accessor\nQrono.prototype.year = function (value) {\n return given(value)\n ? this.clone({ year: value })\n : this[internal].getNative('FullYear')\n}\n\nQrono.prototype.month = function (value) {\n return given(value)\n ? this.clone({ month: value })\n : this[internal].getNative('Month') + 1\n}\n\nQrono.prototype.day = function (value) {\n return given(value)\n ? this.clone({ day: value })\n : this[internal].getNative('Date')\n}\n\nQrono.prototype.hour = function (value) {\n return given(value)\n ? this.clone({ hour: value })\n : this[internal].getNative('Hours')\n}\n\nQrono.prototype.minute = function (value) {\n return given(value)\n ? this.clone({ minute: value })\n : this[internal].getNative('Minutes')\n}\n\nQrono.prototype.second = function (value) {\n return given(value)\n ? this.clone({ second: value })\n : this[internal].getNative('Seconds')\n}\n\nQrono.prototype.millisecond = function (value) {\n return given(value)\n ? this.clone({ millisecond: value })\n : this[internal].getNative('Milliseconds')\n}\n\n// Getter\nQrono.prototype.dayOfWeek = function () {\n return 1 + ((this[internal].getNative('Day') - 1 + daysPerWeek) % daysPerWeek)\n}\n\nQrono.prototype.dayOfYear = function () {\n const date = this.toDate()\n return 1 + date - date.startOfYear()\n}\n\nQrono.prototype.weekOfYear = function () {\n const date = this.toDate()\n const theThursday = date.day(date.day() - date.dayOfWeek() + thursday)\n const startOfYear = theThursday.startOfYear()\n const firstThursday =\n startOfYear.dayOfWeek() === thursday\n ? startOfYear\n : startOfYear.day(\n 1 + ((thursday - startOfYear.dayOfWeek() + daysPerWeek) % daysPerWeek)\n )\n return 1 + Math.ceil((theThursday - firstThursday) / daysPerWeek)\n}\n\nQrono.prototype.yearOfWeek = function () {\n const date = this.toDate()\n return date.day(date.day() - date.dayOfWeek() + thursday).year()\n}\n\nQrono.prototype.isLeapYear = function () {\n const year = this.year()\n return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0)\n}\n\nQrono.prototype.hasDstInYear = function () {\n if (!this[internal].localtime) {\n return false\n }\n const currentOffset = this.offset()\n return [3, 6, 9, 12]\n .map(month => this.month(month).offset())\n .some(offset => offset !== currentOffset)\n}\n\nQrono.prototype.isInDst = function () {\n if (!this[internal].localtime) {\n return false\n }\n return (\n this.offset() ===\n Math.max(...[3, 6, 9, 12].map(month => this.month(month).offset()))\n )\n}\n\nQrono.prototype.isDstTransitionDay = function () {\n if (!this[internal].localtime) {\n return false\n }\n return this.minutesInDay() !== minutesPerDay\n}\n\nQrono.prototype.minutesInDay = function () {\n if (!this[internal].localtime) {\n return minutesPerDay\n }\n const startOfDay = this.startOfDay()\n const nextDay = startOfDay.plus({ day: 1 }).startOfDay()\n if (startOfDay.day() === nextDay.day()) {\n return minutesPerDay\n }\n return (nextDay - startOfDay) / millisecondsPerMinute\n}\n\nQrono.prototype.daysInMonth = function () {\n const days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\n const month = this.month()\n return days[month - 1] + (this.isLeapYear() && month === 2 ? 1 : 0)\n}\n\nQrono.prototype.daysInYear = function () {\n return this.isLeapYear() ? 366 : 365\n}\n\nQrono.prototype.weeksInYear = function () {\n const endOfYear = this.toDate({ month: 12, day: 31 })\n const endOfLastYear = endOfYear.minus({ year: 1 })\n if (\n endOfYear.dayOfWeek() === thursday ||\n endOfLastYear.dayOfWeek() === wednesday\n ) {\n return 53\n }\n return 52\n}\n\nQrono.prototype.startOfYear = function () {\n return this.clone({\n month: 1,\n day: 1,\n hour: 0,\n minute: 0,\n second: 0,\n millisecond: 0,\n })\n}\n\nQrono.prototype.startOfMonth = function () {\n return this.clone({\n day: 1,\n hour: 0,\n minute: 0,\n second: 0,\n millisecond: 0,\n })\n}\n\nQrono.prototype.startOfDay = function () {\n return this.clone({\n hour: 0,\n minute: 0,\n second: 0,\n millisecond: 0,\n })\n}\n\nQrono.prototype.startOfHour = function () {\n return this.clone({\n minute: 0,\n second: 0,\n millisecond: 0,\n })\n}\n\nQrono.prototype.startOfMinute = function () {\n return this.clone({\n second: 0,\n millisecond: 0,\n })\n}\n\nQrono.prototype.startOfSecond = function () {\n return this.clone({\n millisecond: 0,\n })\n}\n\nQrono.prototype.isSame = function (another) {\n return +this === +another\n}\nQrono.prototype.isBefore = function (another) {\n return this < another\n}\nQrono.prototype.isAfter = function (another) {\n return this > another\n}\nQrono.prototype.isSameOrBefore = function (another) {\n return this <= another\n}\nQrono.prototype.isSameOrAfter = function (another) {\n return this >= another\n}\nQrono.prototype.isBetween = function (a, b) {\n return (a <= this && this <= b) || (b <= this && this <= a)\n}\n\n// Calculation\nQrono.prototype.plus = function (...args) {\n return plus.call(this, 1, ...args)\n}\n\nQrono.prototype.minus = function (...args) {\n return plus.call(this, -1, ...args)\n}\n\nfunction plus(sign, ...args) {\n const arg0 = args[0]\n const arg1 = args[1]\n if (Number.isFinite(arg0) && !Number.isFinite(arg1)) {\n return this.clone(this.numeric() + arg0)\n }\n let timeFields = null\n if (isObject(arg0)) {\n if (!hasDatetimeField(arg0)) {\n throw RangeError(\n 'Missing time field' +\n ' (year, minute, day, hour, minute, second or millisecond)'\n )\n }\n timeFields = arg0\n } else if (Number.isFinite(arg0) || Array.isArray(arg0)) {\n const values = args.flat().filter(v => Number.isSafeInteger(v))\n if (values.length !== args.flat().length) {\n throw RangeError('Should be safe integers')\n }\n if (values.length > 7) {\n throw RangeError('Too many numbers')\n }\n timeFields = {\n year: args[0],\n month: args[1],\n day: args[2],\n hour: args[3],\n minute: args[4],\n second: args[5],\n millisecond: args[6],\n }\n } else {\n throw TypeError()\n }\n const date = this.nativeDate()\n const utc = this[internal].localtime ? '' : 'UTC'\n if (has(timeFields, 'year') || has(timeFields, 'month')) {\n const year = this.year() + sign * (timeFields.year ?? 0)\n const month = this.month() + sign * (timeFields.month ?? 0)\n const endOfMonth = new Date(date.getTime())\n endOfMonth[`set${utc}FullYear`](year, month, 0)\n const lastDay = endOfMonth.getDate()\n if (lastDay < this.day()) {\n date[`set${utc}FullYear`](year, endOfMonth[`get${utc}Month`](), lastDay)\n } else {\n date[`set${utc}FullYear`](year, month - 1)\n }\n }\n if (has(timeFields, 'day')) {\n date[`set${utc}Date`](date[`get${utc}Date`]() + sign * timeFields.day)\n }\n ;[\n ['hour', 'Hours'],\n ['minute', 'Minutes'],\n ['second', 'Seconds'],\n ['millisecond', 'Milliseconds'],\n ].forEach(([key, nativeKey]) => {\n if (has(timeFields, key)) {\n date[`setUTC${nativeKey}`](\n date[`getUTC${nativeKey}`]() + sign * timeFields[key]\n )\n }\n })\n return this.clone(asDst(this[internal].interpretAsDst, date))\n}\n\n// -----------------------------------------------------------------------------\n// QronoDate Class\n// -----------------------------------------------------------------------------\nconst internalDate = Symbol('QronoDate.internal')\n\nfunction QronoDate(...args) {\n if (!new.target) {\n return new QronoDate(...args)\n }\n const self = (this[internalDate] = {\n datetime: null,\n })\n let source = null\n if (args[0] instanceof QronoDate) {\n source = args.shift().toDatetime()\n }\n const first = args[0]\n const second = args[1]\n if (Number.isFinite(first) && !Number.isFinite(second)) {\n args[0] *= millisecondsPerDay\n }\n source = (source ? source.clone(...args) : qrono(...args)).startOfDay()\n self.datetime = qrono({ localtime: false }, source.toObject())\n return this\n}\n\nQronoDate.prototype.toString = function () {\n return this[internalDate].datetime.toString().substring(0, 10)\n}\n\nQronoDate.prototype.valueOf = function () {\n return this[internalDate].datetime / millisecondsPerDay\n}\n\nQronoDate.prototype.valid = function () {\n return this[internalDate].datetime.valid()\n}\n\nQronoDate.prototype.clone = function (...args) {\n return new QronoDate(this, ...args)\n}\n\nQronoDate.prototype.toDatetime = function () {\n return qrono(this[internalDate].datetime.toArray())\n}\n\nQronoDate.prototype.numeric = function () {\n return this[internalDate].datetime.numeric() / millisecondsPerDay\n}\n\nQronoDate.prototype.toObject = function () {\n return {\n year: this.year(),\n month: this.month(),\n day: this.day(),\n }\n}\n\nQronoDate.prototype.toArray = function () {\n return [this.year(), this.month(), this.day()]\n}\n\nQronoDate.prototype.startOfYear = function () {\n return new QronoDate(this[internalDate].datetime.startOfYear())\n}\n\nQronoDate.prototype.startOfMonth = function () {\n return new QronoDate(this[internalDate].datetime.startOfMonth())\n}\n\nQronoDate.prototype.startOfDay = function () {\n return this[internalDate].datetime.clone()\n}\n;['year', 'month', 'day'].forEach(field => {\n QronoDate.prototype[field] = function (value) {\n if (given(value)) {\n return new QronoDate(this[internalDate].datetime[field](value))\n }\n return this[internalDate].datetime[field]()\n }\n})\n;[\n 'dayOfWeek',\n 'dayOfYear',\n 'weekOfYear',\n 'yearOfWeek',\n 'isLeapYear',\n 'daysInMonth',\n 'daysInYear',\n 'weeksInYear',\n].forEach(method => {\n QronoDate.prototype[method] = function () {\n return this[internalDate].datetime[method]()\n }\n})\n;['minutesInDay', 'hasDstInYear', 'isDstTransitionDay'].forEach(method => {\n QronoDate.prototype[method] = function () {\n return this[internalDate].datetime.localtime(true)[method]()\n }\n})\n\nQronoDate.prototype.endOfYear = function () {\n return this.clone({ month: 12, day: 31 })\n}\n\nQronoDate.prototype.endOfMonth = function () {\n return this.clone({ day: this.daysInMonth() })\n}\n\nQronoDate.prototype.isSame = function (another) {\n return +this === +another\n}\nQronoDate.prototype.isBefore = function (another) {\n return this < another\n}\nQronoDate.prototype.isAfter = function (another) {\n return this > another\n}\nQronoDate.prototype.isSameOrBefore = function (another) {\n return this <= another\n}\nQronoDate.prototype.isSameOrAfter = function (another) {\n return this >= another\n}\nQronoDate.prototype.isBetween = function (a, b) {\n return (a <= this && this <= b) || (b <= this && this <= a)\n}\n\nQronoDate.prototype.plus = function (...args) {\n return plusDate.call(this, 1, ...args)\n}\n\nQronoDate.prototype.minus = function (...args) {\n return plusDate.call(this, -1, ...args)\n}\n\nfunction plusDate(sign, ...args) {\n const arg0 = args[0]\n const arg1 = args[1]\n const datetime = this[internalDate].datetime\n if (Number.isFinite(arg0) && !Number.isFinite(arg1)) {\n return datetime.plus({ day: sign * arg0 }).toDate()\n }\n let timeFields = null\n if (isObject(arg0) && hasDatetimeField(arg0)) {\n timeFields = {\n year: sign * (arg0.year ?? 0),\n month: sign * (arg0.month ?? 0),\n day: sign * (arg0.day ?? 0),\n }\n } else if (Number.isFinite(arg0)) {\n if (args.length > 3) {\n throw RangeError('Too many arguments')\n }\n timeFields = { year: args[0], month: args[1], day: args[2] }\n } else if (Array.isArray(arg0)) {\n if (arg0.length > 3) {\n throw RangeError('Too many elements')\n }\n timeFields = { year: arg0[0], month: arg0[1], day: arg0[2] }\n } else {\n throw TypeError()\n }\n return datetime.plus(timeFields).toDate()\n}\n"],"names":["initialSafeDate","daysPerWeek","hoursPerDay","minutesPerHour","minutesPerDay","secondsPerMinute","secondsPerHour","secondsPerDay","millisecondsPerSecond","millisecondsPerMinute","millisecondsPerDay","monday","tuesday","wednesday","thursday","friday","saturday","sunday","has","object","keys","fields","value","isFunction","key","given","arg","a","isString","isObject","isValidDate","date","hasDatetimeField","asDst","interpretAsDst","numeric","result","adjacentDay","sign","adjust","adjusted","adjustedUTC","qrono","Qrono","QronoDate","defaultContext","context","__spreadValues","internal","args","self","set","parse","valid","getNative","source","first","second","_a","values","v","name","baseDate","newDate","_b","_c","_d","_e","_f","_g","_h","_i","_j","_k","_l","_m","_n","_o","_p","parsePattern","str","text","year","month","day","hour","minute","millisecond","offset","native","offsetAbs","theThursday","startOfYear","firstThursday","currentOffset","startOfDay","nextDay","days","endOfYear","endOfLastYear","another","b","plus","arg0","arg1","timeFields","utc","endOfMonth","lastDay","nativeKey","internalDate","field","method","plusDate","datetime"],"mappings":"6aAUO,MAAMA,GAAkB,IAAI,KAAK,KAAM,EAAG,EAAG,GAAI,EAAG,EAAG,CAAC,EAElDC,EAAc,EACdC,EAAc,GAEdC,EAAiB,GACjBC,EAAgBD,EAAiBD,EAEjCG,EAAmB,GACnBC,GAAiBD,EAAmBF,EACpCI,GAAgBD,GAAiBJ,EAEjCM,EAAwB,IACxBC,EAAwBJ,EAAmBG,EAE3CE,EAAqBH,GAAgBC,EAGrCG,EAAS,EACTC,EAAU,EACVC,EAAY,EACZC,EAAW,EACXC,EAAS,EACTC,EAAW,EACXC,EAAS,EAEf,SAASC,EAAIC,KAAWC,EAAM,CACnC,O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AOgE,EAAS,KAAK,KAAM,GAAI,GAAGhE,CAAI,CACxC,EAEA,SAASgE,EAAS3E,KAASW,EAAM,WAC/B,MAAMsD,EAAOtD,EAAK,CAAC,EACbuD,EAAOvD,EAAK,CAAC,EACbiE,EAAW,KAAKJ,CAAY,EAAE,SACpC,GAAI,OAAO,SAASP,CAAI,GAAK,CAAC,OAAO,SAASC,CAAI,EAChD,OAAOU,EAAS,KAAK,CAAE,IAAK5E,EAAOiE,CAAI,CAAE,EAAE,OAAM,EAEnD,IAAIE,EAAa,KACjB,GAAI5E,EAAS0E,CAAI,GAAKvE,EAAiBuE,CAAI,EACzCE,EAAa,CACX,KAAMnE,IAAQoB,EAAA6C,EAAK,OAAL,KAAA7C,EAAa,GAC3B,MAAOpB,IAAQ0B,EAAAuC,EAAK,QAAL,KAAAvC,EAAc,GAC7B,IAAK1B,IAAQ2B,EAAAsC,EAAK,MAAL,KAAAtC,EAAY,EAC/B,UACa,OAAO,SAASsC,CAAI,EAAG,CAChC,GAAItD,EAAK,OAAS,EAChB,MAAM,WAAW,oBAAoB,EAEvCwD,EAAa,CAAE,KAAMxD,EAAK,CAAC,EAAG,MAAOA,EAAK,CAAC,EAAG,IAAKA,EAAK,CAAC,CAAC,CAC5D,SAAW,MAAM,QAAQsD,CAAI,EAAG,CAC9B,GAAIA,EAAK,OAAS,EAChB,MAAM,WAAW,mBAAmB,EAEtCE,EAAa,CAAE,KAAMF,EAAK,CAAC,EAAG,MAAOA,EAAK,CAAC,EAAG,IAAKA,EAAK,CAAC,CAAC,CAC5D,KACE,OAAM,UAAS,EAEjB,OAAOW,EAAS,KAAKT,CAAU,EAAE,OAAM,CACzC"}
1
+ {"version":3,"file":"qrono.cjs","sources":["../src/helpers.js","../src/qrono.js"],"sourcesContent":["export const epoch = new Date(0)\n\n/**\n * When creating or updating a local time, both `Date.setFullYear` and `Date.setHours` are used.\n * Noon is used as the initial reference point to avoid the time after `setFullYear`\n * from falling into an ambiguous DST period. Historically, DST transitions in all countries\n * have been scheduled around midnight, and it should be the same in the future.\n * The reason for selecting 1915 as the initial value is as follows.\n * Since DST was first established in 1916, the initial value should be set to a year prior to that.\n * If a year too far in the past is chosen, it may correspond to a period when time zones were not yet\n * precisely defined in some regions, which could result in unexpected timezone offsets.\n */\nexport const initialSafeDate = new Date(1915, 0, 1, 12, 0, 0, 0)\n\nexport const daysPerWeek = 7\nexport const hoursPerDay = 24\nexport const hoursPerWeek = hoursPerDay * daysPerWeek\nexport const minutesPerHour = 60\nexport const minutesPerDay = minutesPerHour * hoursPerDay\nexport const minutesPerWeek = minutesPerDay * daysPerWeek\nexport const secondsPerMinute = 60\nexport const secondsPerHour = secondsPerMinute * minutesPerHour\nexport const secondsPerDay = secondsPerHour * hoursPerDay\nexport const secondsPerWeek = secondsPerDay * daysPerWeek\nexport const millisecondsPerSecond = 1000\nexport const millisecondsPerMinute = secondsPerMinute * millisecondsPerSecond\nexport const millisecondsPerHour = secondsPerHour * millisecondsPerSecond\nexport const millisecondsPerDay = secondsPerDay * millisecondsPerSecond\nexport const millisecondsPerWeek = secondsPerWeek * millisecondsPerSecond\n\nexport const monday = 1\nexport const tuesday = 2\nexport const wednesday = 3\nexport const thursday = 4\nexport const friday = 5\nexport const saturday = 6\nexport const sunday = 7\n\nexport function has(object, ...keys) {\n return keys.flat().some(object.hasOwnProperty, object)\n}\n\nexport function fields(object) {\n return Object.entries(object)\n .filter(([, value]) => !isFunction(value))\n .map(([key]) => key)\n}\n\nexport function given(arg) {\n return arg !== undefined\n}\n\nexport function isFunction(a) {\n return a instanceof Function\n}\n\nexport function isString(a) {\n return typeof a === 'string' || a instanceof String\n}\n\nexport function isObject(a) {\n return a !== null && typeof a === 'object' && a.constructor === Object\n}\n\nexport function isValidDate(date) {\n return !isNaN(date.getTime())\n}\n\nexport function hasDateField(object) {\n return has(object, ['year', 'month', 'day'])\n}\n\nexport function hasTimeField(object) {\n return has(object, ['hour', 'minute', 'second', 'millisecond'])\n}\n\nexport function hasDatetimeField(object) {\n return has(object, [\n 'year',\n 'month',\n 'day',\n 'hour',\n 'minute',\n 'second',\n 'millisecond',\n ])\n}\n\n/**\n * Adjust a Date to respect the caller's interpretation of DST (Daylight Saving Time).\n *\n * - If `interpretAsDst` is true, the function returns a copy of the original `date`\n * unchanged. `Date` always treats the ambiguous time as DST.\n * - If `interpretAsDst` is false, the function will attempt to detect a nearby DST\n * offset change and adjust the moment in time so that the returned `Date` represents\n * the same nominal local fields but interpreted as the non-DST side of the\n * transition. This helps disambiguate ambiguous local times by moving to the\n * corresponding instant in UTC that matches the requested DST interpretation.\n */\nexport function asDst(interpretAsDst, date) {\n const numeric = date.getTime()\n const original = new Date(numeric)\n if (interpretAsDst) { return original }\n const nextDay = new Date(numeric)\n nextDay.setDate(date.getDate() + 1)\n const prevDay = new Date(numeric)\n prevDay.setDate(date.getDate() - 1)\n const adjust = nextDay.getTimezoneOffset() - prevDay.getTimezoneOffset()\n if (adjust === 0) { return original }\n const adjusted = new Date(numeric).setMinutes(date.getMinutes() + adjust)\n const adjustedUTC = new Date(numeric).setUTCMinutes(date.getUTCMinutes() + adjust)\n if (adjusted === adjustedUTC || (\n (adjust < 0 && adjusted === numeric) ||\n (adjust > 0 && adjusted !== numeric)\n )) {\n return original\n }\n return new Date(adjustedUTC)\n}\n","/* @ts-self-types=\"../types/qrono.d.ts\" */\nimport {\n has,\n given,\n fields,\n isObject,\n isString,\n isValidDate,\n asDst,\n hasDatetimeField,\n initialSafeDate,\n daysPerWeek,\n minutesPerDay,\n minutesPerHour,\n millisecondsPerMinute,\n millisecondsPerDay,\n monday,\n tuesday,\n wednesday,\n thursday,\n friday,\n saturday,\n sunday,\n} from './helpers.js'\n\n// -----------------------------------------------------------------------------\n// Exports\n// -----------------------------------------------------------------------------\nconst qrono = Qrono\n\nexport { qrono }\n\nexport {\n monday,\n tuesday,\n wednesday,\n thursday,\n friday,\n saturday,\n sunday,\n} from './helpers'\n\n// -----------------------------------------------------------------------------\n// Static\n// -----------------------------------------------------------------------------\nQrono.date = QronoDate\n\n// NOTE Must be flat object for shallow cloning.\nconst defaultContext = {\n localtime: false,\n interpretAsDst: true,\n}\n\nfields(defaultContext).forEach(key => {\n Qrono[key] = function (arg) {\n if (given(arg)) {\n defaultContext[key] = arg\n return this\n }\n return defaultContext[key]\n }\n})\n\nQrono.context = function (context) {\n if (given(context)) {\n fields(defaultContext)\n .filter(key => has(context, key))\n .forEach(key => {\n defaultContext[key] = context[key]\n })\n return this\n }\n return { ...defaultContext }\n}\n\nQrono.asUtc = function () {\n defaultContext.localtime = false\n return this\n}\n\nQrono.asLocaltime = function () {\n defaultContext.localtime = true\n return this\n}\n\nObject.assign(Qrono, {\n monday,\n tuesday,\n wednesday,\n thursday,\n friday,\n saturday,\n sunday,\n})\n\n// -----------------------------------------------------------------------------\n// Constructor\n// -----------------------------------------------------------------------------\nconst internal = Symbol('Qrono.internal')\n\nfunction Qrono(...args) {\n if (!new.target) {\n return new Qrono(...args)\n }\n const self = (this[internal] = {\n // properties\n nativeDate: null,\n localtime: false,\n interpretAsDst: false,\n // methods\n set,\n parse,\n valid,\n context,\n getNative,\n })\n\n // Construction\n self.context(defaultContext)\n if (args[0] instanceof Qrono) {\n const source = args.shift()\n fields(self).forEach(key => {\n self[key] = source[key]()\n })\n }\n if (isObject(args[0]) && !hasDatetimeField(args[0])) {\n self.context(args.shift())\n }\n const first = args[0]\n const second = args[1]\n if (first == null) {\n self.nativeDate ??= new Date()\n } else if (first instanceof Date) {\n self.nativeDate = new Date(first.getTime())\n } else if (isString(first)) {\n self.parse(first)\n } else if (isObject(first)) {\n if (!hasDatetimeField(first)) {\n throw RangeError(\n 'Missing time field' +\n ' (year, minute, day, hour, minute, second or millisecond)'\n )\n }\n self.set(first)\n } else if (Number.isFinite(first) && !Number.isFinite(second)) {\n self.nativeDate = new Date(first)\n } else if (Number.isFinite(first) || Array.isArray(first)) {\n const values = args.flat().filter(v => Number.isSafeInteger(v))\n if (values.length !== args.flat().length) {\n throw RangeError('Should be safe integers')\n }\n if (values.length > 7) {\n throw RangeError('Too many numbers')\n }\n self.set({\n year: values[0],\n month: values[1],\n day: values[2],\n hour: values[3],\n minute: values[4],\n second: values[5],\n millisecond: values[6],\n })\n } else {\n throw TypeError(`Invalid argument ${args}`)\n }\n return this\n}\n\n// -----------------------------------------------------------------------------\n// Private methods\n// -----------------------------------------------------------------------------\nfunction valid() {\n return isValidDate(this.nativeDate)\n}\n\nfunction context(context) {\n if (!context) {\n return\n }\n fields(defaultContext)\n .filter(key => has(context, key))\n .forEach(key => {\n this[key] = context[key]\n })\n return this\n}\n\nfunction getNative(name) {\n return this.nativeDate[`get${this.localtime ? '' : 'UTC'}${name}`]()\n}\n\nfunction set(values) {\n const args = { ...values }\n args.month = args.month && args.month - 1\n if (this.localtime) {\n const baseDate = this.nativeDate ?? new Date(0, 0)\n const newDate = new Date(initialSafeDate.getTime())\n newDate.setFullYear(\n args.year ?? baseDate.getFullYear(),\n args.month ?? baseDate.getMonth(),\n args.day ?? baseDate.getDate()\n )\n newDate.setHours(\n args.hour ?? baseDate.getHours(),\n args.minute ?? baseDate.getMinutes(),\n args.second ?? baseDate.getSeconds(),\n args.millisecond ?? baseDate.getMilliseconds()\n )\n this.nativeDate = asDst(this.interpretAsDst, newDate)\n } else {\n const baseDate = this.nativeDate ?? new Date(0)\n const newDate = new Date(0)\n newDate.setUTCFullYear(\n args.year ?? baseDate.getUTCFullYear(),\n args.month ?? baseDate.getUTCMonth(),\n args.day ?? baseDate.getUTCDate()\n )\n newDate.setUTCHours(\n args.hour ?? baseDate.getUTCHours(),\n args.minute ?? baseDate.getUTCMinutes(),\n args.second ?? baseDate.getUTCSeconds(),\n args.millisecond ?? baseDate.getUTCMilliseconds()\n )\n this.nativeDate = newDate\n }\n return this\n}\n\nconst parsePattern = new RegExp(\n // yyyy[[-|/]MM[[-|/]DD]]\n '^(\\\\d{4})(?:[-/]?([0-2]?\\\\d)(?:[-/]?([0-3]?\\\\d))?)?' +\n // [(T| )HH[:]mm[[:]ss[(.|:)SSS]]]\n '(?:[T\\\\s]([0-2]?\\\\d)(?::([0-5]?\\\\d)?(?::([0-6]?\\\\d)?(?:[.:](\\\\d{1,3})?\\\\d*)?)?)?)?' +\n // [Z|(+|-)hh:mm]\n '(Z|[-+]\\\\d{2}:?\\\\d{2})?$'\n)\n\nfunction parse(str) {\n const text = str.trim().toUpperCase()\n const values = text.match(parsePattern)\n if (!values) {\n throw RangeError(\n `Failed to parse '${str}'.` +\n ' Should be yyyy[[-|/]MM[[-|/]DD]][(T| )HH:mm[:ss[(.|:)SSS]]][Z|(+|-)hh:mm]'\n )\n }\n const [year, month, day, hour, minute, second, millisecond, offset] = [\n +values[1],\n +values[2] || 1,\n +values[3] || 1,\n +values[4] || 0,\n +values[5] || 0,\n +values[6] || 0,\n +values[7]?.padStart(3, '0') || 0,\n values[8],\n ]\n const native = new Date(text)\n if (!isValidDate(native)) {\n throw RangeError(\n `Failed to parse '${str}' by Date.` +\n ' Should be yyyy[[-|/]MM[[-|/]DD]][(T| )HH:mm[:ss[(.|:)SSS]]][Z|(+|-)hh:mm]'\n )\n }\n if (offset) {\n this.nativeDate = native\n } else if (this.localtime) {\n this.nativeDate = asDst(this.interpretAsDst, native)\n } else {\n this.set({ year, month, day, hour, minute, second, millisecond })\n }\n return this\n}\n\n// -----------------------------------------------------------------------------\n// Public methods\n// -----------------------------------------------------------------------------\n// Basic\nQrono.prototype.toString = function () {\n if (this[internal].localtime) {\n const t = this[internal].nativeDate\n const offset = -t.getTimezoneOffset()\n const offsetAbs = Math.abs(offset)\n return `${String(t.getFullYear()).padStart(4, '0')}-${String(\n t.getMonth() + 1\n ).padStart(2, '0')}-${String(t.getDate()).padStart(2, '0')}T${String(\n t.getHours()\n ).padStart(2, '0')}:${String(t.getMinutes()).padStart(2, '0')}:${String(\n t.getSeconds()\n ).padStart(2, '0')}.${String(t.getMilliseconds()).padStart(3, '0')}${\n (offset >= 0 ? '+' : '-') +\n String(Math.trunc(offsetAbs / minutesPerHour)).padStart(2, '0') +\n ':' +\n String(offsetAbs % minutesPerHour).padStart(2, '0')\n }`\n }\n return this[internal].nativeDate.toISOString()\n}\n\nQrono.prototype.valueOf = function () {\n return this[internal].nativeDate.valueOf()\n}\n\nQrono.prototype.clone = function (...args) {\n return new Qrono(this, ...args)\n}\n\nQrono.prototype.context = function (context) {\n return given(context)\n ? this.clone(context)\n : {\n localtime: this[internal].localtime,\n interpretAsDst: this[internal].interpretAsDst,\n }\n}\n\nQrono.prototype.nativeDate = function () {\n return new Date(this[internal].nativeDate.getTime())\n}\n\nQrono.prototype.offset = function () {\n return this[internal].localtime\n ? -this[internal].nativeDate.getTimezoneOffset()\n : 0\n}\n\nQrono.prototype.localtime = function (arg) {\n return given(arg) ? this.clone({ localtime: arg }) : this[internal].localtime\n}\n\nQrono.prototype.interpretAsDst = function (arg) {\n return given(arg)\n ? this.clone({ interpretAsDst: arg })\n : this[internal].interpretAsDst\n}\n\nQrono.prototype.valid = function () {\n return this[internal].valid()\n}\n\n// Transform\nQrono.prototype.numeric = function () {\n return this[internal].nativeDate.getTime()\n}\n\nQrono.prototype.toObject = function () {\n return {\n year: this.year(),\n month: this.month(),\n day: this.day(),\n hour: this.hour(),\n minute: this.minute(),\n second: this.second(),\n millisecond: this.millisecond(),\n }\n}\n\nQrono.prototype.toArray = function () {\n return [\n this.year(),\n this.month(),\n this.day(),\n this.hour(),\n this.minute(),\n this.second(),\n this.millisecond(),\n ]\n}\n\nQrono.prototype.toDate = function (...args) {\n return new QronoDate(this.clone(...args))\n}\n\n// Context\nQrono.prototype.asUtc = function () {\n return this.clone({ localtime: false })\n}\n\nQrono.prototype.asLocaltime = function () {\n return this.clone({ localtime: true })\n}\n\n// Accessor\nQrono.prototype.year = function (value) {\n return given(value)\n ? this.clone({ year: value })\n : this[internal].getNative('FullYear')\n}\n\nQrono.prototype.month = function (value) {\n return given(value)\n ? this.clone({ month: value })\n : this[internal].getNative('Month') + 1\n}\n\nQrono.prototype.day = function (value) {\n return given(value)\n ? this.clone({ day: value })\n : this[internal].getNative('Date')\n}\n\nQrono.prototype.hour = function (value) {\n return given(value)\n ? this.clone({ hour: value })\n : this[internal].getNative('Hours')\n}\n\nQrono.prototype.minute = function (value) {\n return given(value)\n ? this.clone({ minute: value })\n : this[internal].getNative('Minutes')\n}\n\nQrono.prototype.second = function (value) {\n return given(value)\n ? this.clone({ second: value })\n : this[internal].getNative('Seconds')\n}\n\nQrono.prototype.millisecond = function (value) {\n return given(value)\n ? this.clone({ millisecond: value })\n : this[internal].getNative('Milliseconds')\n}\n\n// Getter\nQrono.prototype.dayOfWeek = function () {\n return 1 + ((this[internal].getNative('Day') - 1 + daysPerWeek) % daysPerWeek)\n}\n\nQrono.prototype.dayOfYear = function () {\n const date = this.toDate()\n return 1 + date - date.startOfYear()\n}\n\nQrono.prototype.weekOfYear = function () {\n const date = this.toDate()\n const theThursday = date.day(date.day() - date.dayOfWeek() + thursday)\n const startOfYear = theThursday.startOfYear()\n const firstThursday =\n startOfYear.dayOfWeek() === thursday\n ? startOfYear\n : startOfYear.day(\n 1 + ((thursday - startOfYear.dayOfWeek() + daysPerWeek) % daysPerWeek)\n )\n return 1 + Math.ceil((theThursday - firstThursday) / daysPerWeek)\n}\n\nQrono.prototype.yearOfWeek = function () {\n const date = this.toDate()\n return date.day(date.day() - date.dayOfWeek() + thursday).year()\n}\n\nQrono.prototype.isLeapYear = function () {\n const year = this.year()\n return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0)\n}\n\nQrono.prototype.hasDstInYear = function () {\n if (!this[internal].localtime) {\n return false\n }\n const currentOffset = this.offset()\n return [3, 6, 9, 12]\n .map(month => this.month(month).offset())\n .some(offset => offset !== currentOffset)\n}\n\nQrono.prototype.isInDst = function () {\n if (!this[internal].localtime) {\n return false\n }\n return (\n this.offset() ===\n Math.max(...[3, 6, 9, 12].map(month => this.month(month).offset()))\n )\n}\n\nQrono.prototype.isDstTransitionDay = function () {\n if (!this[internal].localtime) {\n return false\n }\n return this.minutesInDay() !== minutesPerDay\n}\n\nQrono.prototype.minutesInDay = function () {\n if (!this[internal].localtime) {\n return minutesPerDay\n }\n const startOfDay = this.startOfDay()\n const nextDay = startOfDay.plus({ day: 1 }).startOfDay()\n if (startOfDay.day() === nextDay.day()) {\n return minutesPerDay\n }\n return (nextDay - startOfDay) / millisecondsPerMinute\n}\n\nQrono.prototype.daysInMonth = function () {\n const days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\n const month = this.month()\n return days[month - 1] + (this.isLeapYear() && month === 2 ? 1 : 0)\n}\n\nQrono.prototype.daysInYear = function () {\n return this.isLeapYear() ? 366 : 365\n}\n\nQrono.prototype.weeksInYear = function () {\n const endOfYear = this.toDate({ month: 12, day: 31 })\n const endOfLastYear = endOfYear.minus({ year: 1 })\n if (\n endOfYear.dayOfWeek() === thursday ||\n endOfLastYear.dayOfWeek() === wednesday\n ) {\n return 53\n }\n return 52\n}\n\nQrono.prototype.startOfYear = function () {\n return this.clone({\n month: 1,\n day: 1,\n hour: 0,\n minute: 0,\n second: 0,\n millisecond: 0,\n })\n}\n\nQrono.prototype.startOfMonth = function () {\n return this.clone({\n day: 1,\n hour: 0,\n minute: 0,\n second: 0,\n millisecond: 0,\n })\n}\n\nQrono.prototype.startOfDay = function () {\n return this.clone({\n hour: 0,\n minute: 0,\n second: 0,\n millisecond: 0,\n })\n}\n\nQrono.prototype.startOfHour = function () {\n return this.clone({\n minute: 0,\n second: 0,\n millisecond: 0,\n })\n}\n\nQrono.prototype.startOfMinute = function () {\n return this.clone({\n second: 0,\n millisecond: 0,\n })\n}\n\nQrono.prototype.startOfSecond = function () {\n return this.clone({\n millisecond: 0,\n })\n}\n\nQrono.prototype.isSame = function (another) {\n return +this === +another\n}\nQrono.prototype.isBefore = function (another) {\n return this < another\n}\nQrono.prototype.isAfter = function (another) {\n return this > another\n}\nQrono.prototype.isSameOrBefore = function (another) {\n return this <= another\n}\nQrono.prototype.isSameOrAfter = function (another) {\n return this >= another\n}\nQrono.prototype.isBetween = function (a, b) {\n return (a <= this && this <= b) || (b <= this && this <= a)\n}\n\n// Calculation\nQrono.prototype.plus = function (...args) {\n return plus.call(this, 1, ...args)\n}\n\nQrono.prototype.minus = function (...args) {\n return plus.call(this, -1, ...args)\n}\n\nfunction plus(sign, ...args) {\n const arg0 = args[0]\n const arg1 = args[1]\n if (Number.isFinite(arg0) && !Number.isFinite(arg1)) {\n return this.clone(this.numeric() + arg0)\n }\n let timeFields = null\n if (isObject(arg0)) {\n if (!hasDatetimeField(arg0)) {\n throw RangeError(\n 'Missing time field' +\n ' (year, minute, day, hour, minute, second or millisecond)'\n )\n }\n timeFields = arg0\n } else if (Number.isFinite(arg0) || Array.isArray(arg0)) {\n const values = args.flat().filter(v => Number.isSafeInteger(v))\n if (values.length !== args.flat().length) {\n throw RangeError('Should be safe integers')\n }\n if (values.length > 7) {\n throw RangeError('Too many numbers')\n }\n timeFields = {\n year: args[0],\n month: args[1],\n day: args[2],\n hour: args[3],\n minute: args[4],\n second: args[5],\n millisecond: args[6],\n }\n } else {\n throw TypeError()\n }\n const date = this.nativeDate()\n const utc = this[internal].localtime ? '' : 'UTC'\n if (has(timeFields, 'year') || has(timeFields, 'month')) {\n const year = this.year() + sign * (timeFields.year ?? 0)\n const month = this.month() + sign * (timeFields.month ?? 0)\n const endOfMonth = new Date(date.getTime())\n endOfMonth[`set${utc}FullYear`](year, month, 0)\n const lastDay = endOfMonth.getDate()\n if (lastDay < this.day()) {\n date[`set${utc}FullYear`](year, endOfMonth[`get${utc}Month`](), lastDay)\n } else {\n date[`set${utc}FullYear`](year, month - 1)\n }\n }\n if (has(timeFields, 'day')) {\n date[`set${utc}Date`](date[`get${utc}Date`]() + sign * timeFields.day)\n }\n ;[\n ['hour', 'Hours'],\n ['minute', 'Minutes'],\n ['second', 'Seconds'],\n ['millisecond', 'Milliseconds'],\n ].forEach(([key, nativeKey]) => {\n if (has(timeFields, key)) {\n date[`setUTC${nativeKey}`](\n date[`getUTC${nativeKey}`]() + sign * timeFields[key]\n )\n }\n })\n return this.clone(asDst(this[internal].interpretAsDst, date))\n}\n\n// -----------------------------------------------------------------------------\n// QronoDate Class\n// -----------------------------------------------------------------------------\nconst internalDate = Symbol('QronoDate.internal')\n\nfunction QronoDate(...args) {\n if (!new.target) {\n return new QronoDate(...args)\n }\n const self = (this[internalDate] = {\n datetime: null,\n })\n let source = null\n if (args[0] instanceof QronoDate) {\n source = args.shift().toDatetime()\n }\n const first = args[0]\n const second = args[1]\n if (Number.isFinite(first) && !Number.isFinite(second)) {\n args[0] *= millisecondsPerDay\n }\n source = (source ? source.clone(...args) : qrono(...args)).startOfDay()\n self.datetime = qrono({ localtime: false }, source.toObject())\n return this\n}\n\nQronoDate.prototype.toString = function () {\n return this[internalDate].datetime.toString().substring(0, 10)\n}\n\nQronoDate.prototype.valueOf = function () {\n return this[internalDate].datetime / millisecondsPerDay\n}\n\nQronoDate.prototype.valid = function () {\n return this[internalDate].datetime.valid()\n}\n\nQronoDate.prototype.clone = function (...args) {\n return new QronoDate(this, ...args)\n}\n\nQronoDate.prototype.toDatetime = function () {\n return qrono(this[internalDate].datetime.toArray())\n}\n\nQronoDate.prototype.numeric = function () {\n return this[internalDate].datetime.numeric() / millisecondsPerDay\n}\n\nQronoDate.prototype.toObject = function () {\n return {\n year: this.year(),\n month: this.month(),\n day: this.day(),\n }\n}\n\nQronoDate.prototype.toArray = function () {\n return [this.year(), this.month(), this.day()]\n}\n\nQronoDate.prototype.startOfYear = function () {\n return new QronoDate(this[internalDate].datetime.startOfYear())\n}\n\nQronoDate.prototype.startOfMonth = function () {\n return new QronoDate(this[internalDate].datetime.startOfMonth())\n}\n\nQronoDate.prototype.startOfDay = function () {\n return this[internalDate].datetime.clone()\n}\n;['year', 'month', 'day'].forEach(field => {\n QronoDate.prototype[field] = function (value) {\n if (given(value)) {\n return new QronoDate(this[internalDate].datetime[field](value))\n }\n return this[internalDate].datetime[field]()\n }\n})\n;[\n 'dayOfWeek',\n 'dayOfYear',\n 'weekOfYear',\n 'yearOfWeek',\n 'isLeapYear',\n 'daysInMonth',\n 'daysInYear',\n 'weeksInYear',\n].forEach(method => {\n QronoDate.prototype[method] = function () {\n return this[internalDate].datetime[method]()\n }\n})\n;['minutesInDay', 'hasDstInYear', 'isDstTransitionDay'].forEach(method => {\n QronoDate.prototype[method] = function () {\n return this[internalDate].datetime.localtime(true)[method]()\n }\n})\n\nQronoDate.prototype.endOfYear = function () {\n return this.clone({ month: 12, day: 31 })\n}\n\nQronoDate.prototype.endOfMonth = function () {\n return this.clone({ day: this.daysInMonth() })\n}\n\nQronoDate.prototype.isSame = function (another) {\n return +this === +another\n}\nQronoDate.prototype.isBefore = function (another) {\n return this < another\n}\nQronoDate.prototype.isAfter = function (another) {\n return this > another\n}\nQronoDate.prototype.isSameOrBefore = function (another) {\n return this <= another\n}\nQronoDate.prototype.isSameOrAfter = function (another) {\n return this >= another\n}\nQronoDate.prototype.isBetween = function (a, b) {\n return (a <= this && this <= b) || (b <= this && this <= a)\n}\n\nQronoDate.prototype.plus = function (...args) {\n return plusDate.call(this, 1, ...args)\n}\n\nQronoDate.prototype.minus = function (...args) {\n return plusDate.call(this, -1, ...args)\n}\n\nfunction plusDate(sign, ...args) {\n const arg0 = args[0]\n const arg1 = args[1]\n const datetime = this[internalDate].datetime\n if (Number.isFinite(arg0) && !Number.isFinite(arg1)) {\n return datetime.plus({ day: sign * arg0 }).toDate()\n }\n let timeFields = null\n if (isObject(arg0) && hasDatetimeField(arg0)) {\n timeFields = {\n year: sign * (arg0.year ?? 0),\n month: sign * (arg0.month ?? 0),\n day: sign * (arg0.day ?? 0),\n }\n } else if (Number.isFinite(arg0)) {\n if (args.length > 3) {\n throw RangeError('Too many arguments')\n }\n timeFields = { year: args[0], month: args[1], day: args[2] }\n } else if (Array.isArray(arg0)) {\n if (arg0.length > 3) {\n throw RangeError('Too many elements')\n }\n timeFields = { year: arg0[0], month: arg0[1], day: arg0[2] }\n } else {\n throw TypeError()\n }\n return datetime.plus(timeFields).toDate()\n}\n"],"names":["initialSafeDate","daysPerWeek","hoursPerDay","minutesPerHour","minutesPerDay","secondsPerMinute","secondsPerHour","secondsPerDay","millisecondsPerSecond","millisecondsPerMinute","millisecondsPerDay","monday","tuesday","wednesday","thursday","friday","saturday","sunday","has","object","keys","fields","value","isFunction","key","given","arg","a","isString","isObject","isValidDate","date","hasDatetimeField","asDst","interpretAsDst","numeric","original","nextDay","prevDay","adjust","adjusted","adjustedUTC","qrono","Qrono","QronoDate","defaultContext","context","__spreadValues","internal","args","self","set","parse","valid","getNative","source","first","second","_a","values","v","name","baseDate","newDate","_b","_c","_d","_e","_f","_g","_h","_i","_j","_k","_l","_m","_n","_o","_p","parsePattern","str","text","year","month","day","hour","minute","millisecond","offset","native","offsetAbs","theThursday","startOfYear","firstThursday","currentOffset","startOfDay","days","endOfYear","endOfLastYear","another","b","plus","sign","arg0","arg1","timeFields","utc","endOfMonth","lastDay","nativeKey","internalDate","field","method","plusDate","datetime"],"mappings":"2aAYO,MAAMA,GAAkB,IAAI,KAAK,KAAM,EAAG,EAAG,GAAI,EAAG,EAAG,CAAC,EAElDC,EAAc,EACdC,EAAc,GAEdC,EAAiB,GACjBC,EAAgBD,EAAiBD,EAEjCG,EAAmB,GACnBC,GAAiBD,EAAmBF,EACpCI,GAAgBD,GAAiBJ,EAEjCM,EAAwB,IACxBC,GAAwBJ,EAAmBG,EAE3CE,EAAqBH,GAAgBC,EAGrCG,EAAS,EACTC,EAAU,EACVC,EAAY,EACZC,EAAW,EACXC,EAAS,EACTC,EAAW,EACXC,EAAS,EAEf,SAASC,EAAIC,KAAWC,EAAM,CACnC,OAAOA,EAAK,KAAI,EAAG,KAAKD,EAAO,eAAgBA,CAAM,CACvD,CAEO,SAASE,EAAOF,EAAQ,CAC7B,OAAO,OAAO,QAAQA,CAAM,EACzB,OAAO,CAAC,CAAA,CAAGG,CAAK,IAAM,CAACC,GAAWD,CAAK,CAAC,EACxC,IAAI,CAAC,CAACE,CAAG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