chronos-date 1.0.2 → 1.1.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.
Files changed (76) hide show
  1. package/dist/basic-DIp_pxR2.cjs +450 -0
  2. package/dist/basic-Dputob9z.mjs +366 -0
  3. package/dist/constants.cjs +27 -1
  4. package/dist/constants.mjs +5 -1
  5. package/dist/convert-CNVL-mop.mjs +22 -0
  6. package/dist/convert-dQuGWhVm.cjs +33 -0
  7. package/dist/greet-B8ZtypgG.cjs +40 -0
  8. package/dist/greet-B9j4afzD.mjs +35 -0
  9. package/dist/guards.cjs +119 -1
  10. package/dist/guards.mjs +110 -1
  11. package/dist/helpers-CrMc9iJZ.mjs +185 -0
  12. package/dist/helpers-M_SfAbAv.cjs +262 -0
  13. package/dist/index.cjs +1461 -1
  14. package/dist/index.mjs +1458 -1
  15. package/dist/non-primitives-CT4vszrX.cjs +52 -0
  16. package/dist/non-primitives-DrQfPj1r.mjs +22 -0
  17. package/dist/plugins/banglaPlugin.cjs +121 -1
  18. package/dist/plugins/banglaPlugin.mjs +120 -1
  19. package/dist/plugins/businessPlugin.cjs +118 -1
  20. package/dist/plugins/businessPlugin.mjs +117 -1
  21. package/dist/plugins/dateRangePlugin.cjs +46 -1
  22. package/dist/plugins/dateRangePlugin.mjs +45 -1
  23. package/dist/plugins/dayPartPlugin.cjs +26 -1
  24. package/dist/plugins/dayPartPlugin.mjs +25 -1
  25. package/dist/plugins/durationPlugin.cjs +91 -1
  26. package/dist/plugins/durationPlugin.mjs +90 -1
  27. package/dist/plugins/fromNowPlugin.cjs +80 -1
  28. package/dist/plugins/fromNowPlugin.mjs +79 -1
  29. package/dist/plugins/greetingPlugin.cjs +19 -1
  30. package/dist/plugins/greetingPlugin.mjs +18 -1
  31. package/dist/plugins/palindromePlugin.cjs +22 -1
  32. package/dist/plugins/palindromePlugin.mjs +21 -1
  33. package/dist/plugins/relativeTimePlugin.cjs +74 -1
  34. package/dist/plugins/relativeTimePlugin.mjs +73 -1
  35. package/dist/plugins/roundPlugin.cjs +69 -1
  36. package/dist/plugins/roundPlugin.mjs +68 -1
  37. package/dist/plugins/seasonPlugin.cjs +31 -1
  38. package/dist/plugins/seasonPlugin.mjs +30 -1
  39. package/dist/plugins/timeZonePlugin.cjs +139 -1
  40. package/dist/plugins/timeZonePlugin.mjs +138 -1
  41. package/dist/plugins/zodiacPlugin.cjs +51 -1
  42. package/dist/plugins/zodiacPlugin.mjs +50 -1
  43. package/dist/primitives-BME3_QrA.cjs +49 -0
  44. package/dist/primitives-DEt6I7Sy.mjs +19 -0
  45. package/dist/seasons-CHnjrIKK.mjs +352 -0
  46. package/dist/seasons-CcZicoe1.cjs +418 -0
  47. package/dist/timezone-BfBXeMK_.mjs +5573 -0
  48. package/dist/timezone-DYVJJYKz.cjs +5609 -0
  49. package/dist/types.mjs +1 -1
  50. package/dist/utilities-BU4MSYS7.mjs +43 -0
  51. package/dist/utilities-CGL7F6R9.cjs +72 -0
  52. package/dist/utilities-CtOZhIYv.mjs +241 -0
  53. package/dist/utilities-bXwTPJaD.cjs +318 -0
  54. package/dist/utils.cjs +76 -1
  55. package/dist/utils.mjs +44 -1
  56. package/package.json +1 -1
  57. package/dist/basic-CKxaRSHQ.cjs +0 -1
  58. package/dist/basic-e46DaNAi.mjs +0 -1
  59. package/dist/convert-Bmp63ats.mjs +0 -1
  60. package/dist/convert-DrLrcgqz.cjs +0 -1
  61. package/dist/greet-BBsrvmkn.mjs +0 -1
  62. package/dist/greet-C-6mruI9.cjs +0 -1
  63. package/dist/helpers-DGzYnP81.cjs +0 -1
  64. package/dist/helpers-N1X_Rj_V.mjs +0 -1
  65. package/dist/non-primitives-B2EE6D6s.mjs +0 -1
  66. package/dist/non-primitives-Bu3a4WL4.cjs +0 -1
  67. package/dist/primitives-Cxss_JVF.mjs +0 -1
  68. package/dist/primitives-Db2FUp4e.cjs +0 -1
  69. package/dist/seasons-ChAIVphi.mjs +0 -1
  70. package/dist/seasons-oABOhHcX.cjs +0 -1
  71. package/dist/timezone-B10UItNO.mjs +0 -1
  72. package/dist/timezone-CWxbK_7I.cjs +0 -1
  73. package/dist/utilities-B8dOAQVD.cjs +0 -1
  74. package/dist/utilities-BJE06bms.mjs +0 -1
  75. package/dist/utilities-D2-p26DX.cjs +0 -1
  76. package/dist/utilities-DV_ohS37.mjs +0 -1
@@ -1 +1,73 @@
1
- import{s as e}from"../basic-e46DaNAi.mjs";const t=t=>{let{toNewDate:n}=t[e];t.prototype.getRelativeYear=function(e){let t=this.toDate(),r=n(this,e),i=t.getFullYear()-r.getFullYear();return(r.getMonth()<t.getMonth()||r.getMonth()===t.getMonth()&&r.getDate()<t.getDate())&&i--,i},t.prototype.getRelativeMonth=function(e){let t=this.toDate(),r=n(this,e),i=(t.getFullYear()-r.getFullYear())*12+(t.getMonth()-r.getMonth());return r.getDate()<t.getDate()&&i--,i},t.prototype.getRelativeWeek=function(e){let t=this.getRelativeDay(e);return Math.floor(t/7)},t.prototype.getRelativeDay=function(e){let t=n(this,e);t.setHours(0,0,0,0);let r=new Date(this.toDate());r.setHours(0,0,0,0);let i=r.getTime()-t.getTime();return Math.floor(i/(1e3*60*60*24))},t.prototype.getRelativeHour=function(e){let t=this.getTimeStamp()-n(this,e).getTime();return Math.floor(t/(1e3*60*60))},t.prototype.getRelativeMinute=function(e){let t=this.getTimeStamp()-n(this,e).getTime();return Math.floor(t/(1e3*60))},t.prototype.getRelativeSecond=function(e){let t=this.getTimeStamp()-n(this,e).getTime();return Math.floor(t/1e3)},t.prototype.getRelativeMilliSecond=function(e){return this.getTimeStamp()-n(this,e).getTime()},t.prototype.compare=function(e=`minute`,t){switch(e){case`year`:return this.getRelativeYear(t);case`month`:return this.getRelativeMonth(t);case`day`:return this.getRelativeDay(t);case`week`:return this.getRelativeWeek(t);case`hour`:return this.getRelativeHour(t);case`minute`:return this.getRelativeMinute(t);case`second`:return this.getRelativeSecond(t);case`millisecond`:return this.getRelativeMilliSecond(t);default:throw RangeError(`Unsupported time unit: ${e}`)}},t.prototype.isToday=function(){return this.getRelativeDay()===0},t.prototype.isTomorrow=function(){return this.getRelativeDay()===1},t.prototype.isYesterday=function(){return this.getRelativeDay()===-1}};export{t as relativeTimePlugin};
1
+ import { s as INTERNALS } from "../basic-Dputob9z.mjs";
2
+
3
+ //#region src/plugins/relativeTimePlugin.ts
4
+ /** * Plugin to inject `relative time` related methods */
5
+ const relativeTimePlugin = ($Chronos) => {
6
+ const { toNewDate } = $Chronos[INTERNALS];
7
+ $Chronos.prototype.getRelativeYear = function(time) {
8
+ const $date = this.toDate();
9
+ const now = toNewDate(this, time);
10
+ let years = $date.getFullYear() - now.getFullYear();
11
+ if (now.getMonth() < $date.getMonth() || now.getMonth() === $date.getMonth() && now.getDate() < $date.getDate()) years--;
12
+ return years;
13
+ };
14
+ $Chronos.prototype.getRelativeMonth = function(time) {
15
+ const $date = this.toDate();
16
+ const now = toNewDate(this, time);
17
+ let months = ($date.getFullYear() - now.getFullYear()) * 12 + ($date.getMonth() - now.getMonth());
18
+ if (now.getDate() < $date.getDate()) months--;
19
+ return months;
20
+ };
21
+ $Chronos.prototype.getRelativeWeek = function(time) {
22
+ const relativeDays = this.getRelativeDay(time);
23
+ return Math.floor(relativeDays / 7);
24
+ };
25
+ $Chronos.prototype.getRelativeDay = function(time) {
26
+ const now = toNewDate(this, time);
27
+ now.setHours(0, 0, 0, 0);
28
+ const $date = new Date(this.toDate());
29
+ $date.setHours(0, 0, 0, 0);
30
+ const diffTime = $date.getTime() - now.getTime();
31
+ return Math.floor(diffTime / (1e3 * 60 * 60 * 24));
32
+ };
33
+ $Chronos.prototype.getRelativeHour = function(time) {
34
+ const diff = this.getTimeStamp() - toNewDate(this, time).getTime();
35
+ return Math.floor(diff / (1e3 * 60 * 60));
36
+ };
37
+ $Chronos.prototype.getRelativeMinute = function(time) {
38
+ const diff = this.getTimeStamp() - toNewDate(this, time).getTime();
39
+ return Math.floor(diff / (1e3 * 60));
40
+ };
41
+ $Chronos.prototype.getRelativeSecond = function(time) {
42
+ const diff = this.getTimeStamp() - toNewDate(this, time).getTime();
43
+ return Math.floor(diff / 1e3);
44
+ };
45
+ $Chronos.prototype.getRelativeMilliSecond = function(time) {
46
+ return this.getTimeStamp() - toNewDate(this, time).getTime();
47
+ };
48
+ $Chronos.prototype.compare = function(unit = "minute", time) {
49
+ switch (unit) {
50
+ case "year": return this.getRelativeYear(time);
51
+ case "month": return this.getRelativeMonth(time);
52
+ case "day": return this.getRelativeDay(time);
53
+ case "week": return this.getRelativeWeek(time);
54
+ case "hour": return this.getRelativeHour(time);
55
+ case "minute": return this.getRelativeMinute(time);
56
+ case "second": return this.getRelativeSecond(time);
57
+ case "millisecond": return this.getRelativeMilliSecond(time);
58
+ default: throw new RangeError(`Unsupported time unit: ${unit}`);
59
+ }
60
+ };
61
+ $Chronos.prototype.isToday = function() {
62
+ return this.getRelativeDay() === 0;
63
+ };
64
+ $Chronos.prototype.isTomorrow = function() {
65
+ return this.getRelativeDay() === 1;
66
+ };
67
+ $Chronos.prototype.isYesterday = function() {
68
+ return this.getRelativeDay() === -1;
69
+ };
70
+ };
71
+
72
+ //#endregion
73
+ export { relativeTimePlugin };
@@ -1 +1,69 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../basic-CKxaRSHQ.cjs`),t=require(`../utilities-D2-p26DX.cjs`),n=n=>{let{internalDate:r,withOrigin:i,offset:a}=n[e.s];n.prototype.round=function(o,s=1){let c=new Date(r(this));switch(o){case`millisecond`:{let e=t.r(c.getMilliseconds(),s);c.setMilliseconds(e);break}case`second`:{let e=t.r(c.getSeconds()+c.getMilliseconds()/1e3,s);c.setSeconds(e,0);break}case`minute`:{let e=t.r(c.getMinutes()+c.getSeconds()/60+c.getMilliseconds()/6e4,s);c.setMinutes(e,0,0);break}case`hour`:{let e=t.r(c.getHours()+c.getMinutes()/60+c.getSeconds()/3600+c.getMilliseconds()/36e5,s);c.setHours(e,0,0,0);break}case`day`:{let n=t.r(c.getDate()+(c.getHours()/24+c.getMinutes()/1440+c.getSeconds()/86400+c.getMilliseconds()/e.u),s);c.setDate(n),c.setHours(0,0,0,0);break}case`week`:{let e=(c.getDay()+6)%7,t=new Date(c);t.setDate(t.getDate()-e),t.setHours(0,0,0,0);let r=new Date(t);r.setDate(r.getDate()+7);let a=Math.abs(c.getTime()-t.getTime());return i(new n(Math.abs(r.getTime()-c.getTime())<a?r:t),`round`)}case`month`:{let e=t.r(c.getMonth()+c.getDate()/this.lastDateOfMonth,s);c.setMonth(e,1),c.setHours(0,0,0,0);break}case`year`:{let n=Math.floor((c.getTime()-new Date(c.getFullYear(),0,1).getTime())/e.u),r=new Date(c.getFullYear(),1,29).getDate()===29?366:365,i=t.r(c.getFullYear()+n/r,s);c.setFullYear(i,0,1),c.setHours(0,0,0,0);break}default:return this}return i(new n(c),`round`,a(this),this.timeZoneName,this.timeZoneId,this.$tzTracker)}};exports.roundPlugin=n;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_basic = require('../basic-DIp_pxR2.cjs');
3
+ const require_utilities = require('../utilities-CGL7F6R9.cjs');
4
+
5
+ //#region src/plugins/roundPlugin.ts
6
+ /** * Plugin to inject `round` method */
7
+ const roundPlugin = ($Chronos) => {
8
+ const { internalDate, withOrigin, offset } = $Chronos[require_basic.INTERNALS];
9
+ $Chronos.prototype.round = function(unit, nearest = 1) {
10
+ const date = new Date(internalDate(this));
11
+ switch (unit) {
12
+ case "millisecond": {
13
+ const rounded = require_utilities.roundToNearest(date.getMilliseconds(), nearest);
14
+ date.setMilliseconds(rounded);
15
+ break;
16
+ }
17
+ case "second": {
18
+ const rounded = require_utilities.roundToNearest(date.getSeconds() + date.getMilliseconds() / 1e3, nearest);
19
+ date.setSeconds(rounded, 0);
20
+ break;
21
+ }
22
+ case "minute": {
23
+ const rounded = require_utilities.roundToNearest(date.getMinutes() + date.getSeconds() / 60 + date.getMilliseconds() / 6e4, nearest);
24
+ date.setMinutes(rounded, 0, 0);
25
+ break;
26
+ }
27
+ case "hour": {
28
+ const rounded = require_utilities.roundToNearest(date.getHours() + date.getMinutes() / 60 + date.getSeconds() / 3600 + date.getMilliseconds() / 36e5, nearest);
29
+ date.setHours(rounded, 0, 0, 0);
30
+ break;
31
+ }
32
+ case "day": {
33
+ const rounded = require_utilities.roundToNearest(date.getDate() + (date.getHours() / 24 + date.getMinutes() / 1440 + date.getSeconds() / 86400 + date.getMilliseconds() / require_basic.MS_PER_DAY), nearest);
34
+ date.setDate(rounded);
35
+ date.setHours(0, 0, 0, 0);
36
+ break;
37
+ }
38
+ case "week": {
39
+ const offsetToMonday = (date.getDay() + 6) % 7;
40
+ const startOfWeek = new Date(date);
41
+ startOfWeek.setDate(startOfWeek.getDate() - offsetToMonday);
42
+ startOfWeek.setHours(0, 0, 0, 0);
43
+ const endOfWeek = new Date(startOfWeek);
44
+ endOfWeek.setDate(endOfWeek.getDate() + 7);
45
+ const diffToStart = Math.abs(date.getTime() - startOfWeek.getTime());
46
+ return withOrigin(new $Chronos(Math.abs(endOfWeek.getTime() - date.getTime()) < diffToStart ? endOfWeek : startOfWeek), "round");
47
+ }
48
+ case "month": {
49
+ const roundedMonth = require_utilities.roundToNearest(date.getMonth() + date.getDate() / this.lastDateOfMonth, nearest);
50
+ date.setMonth(roundedMonth, 1);
51
+ date.setHours(0, 0, 0, 0);
52
+ break;
53
+ }
54
+ case "year": {
55
+ const dayOfYear = Math.floor((date.getTime() - new Date(date.getFullYear(), 0, 1).getTime()) / require_basic.MS_PER_DAY);
56
+ const totalDays = new Date(date.getFullYear(), 1, 29).getDate() === 29 ? 366 : 365;
57
+ const roundedYear = require_utilities.roundToNearest(date.getFullYear() + dayOfYear / totalDays, nearest);
58
+ date.setFullYear(roundedYear, 0, 1);
59
+ date.setHours(0, 0, 0, 0);
60
+ break;
61
+ }
62
+ default: return this;
63
+ }
64
+ return withOrigin(new $Chronos(date), "round", offset(this), this.timeZoneName, this.timeZoneId, this.$tzTracker);
65
+ };
66
+ };
67
+
68
+ //#endregion
69
+ exports.roundPlugin = roundPlugin;
@@ -1 +1,68 @@
1
- import{s as e,u as t}from"../basic-e46DaNAi.mjs";import{r as n}from"../utilities-BJE06bms.mjs";const r=r=>{let{internalDate:i,withOrigin:a,offset:o}=r[e];r.prototype.round=function(e,s=1){let c=new Date(i(this));switch(e){case`millisecond`:{let e=n(c.getMilliseconds(),s);c.setMilliseconds(e);break}case`second`:{let e=n(c.getSeconds()+c.getMilliseconds()/1e3,s);c.setSeconds(e,0);break}case`minute`:{let e=n(c.getMinutes()+c.getSeconds()/60+c.getMilliseconds()/6e4,s);c.setMinutes(e,0,0);break}case`hour`:{let e=n(c.getHours()+c.getMinutes()/60+c.getSeconds()/3600+c.getMilliseconds()/36e5,s);c.setHours(e,0,0,0);break}case`day`:{let e=n(c.getDate()+(c.getHours()/24+c.getMinutes()/1440+c.getSeconds()/86400+c.getMilliseconds()/t),s);c.setDate(e),c.setHours(0,0,0,0);break}case`week`:{let e=(c.getDay()+6)%7,t=new Date(c);t.setDate(t.getDate()-e),t.setHours(0,0,0,0);let n=new Date(t);n.setDate(n.getDate()+7);let i=Math.abs(c.getTime()-t.getTime());return a(new r(Math.abs(n.getTime()-c.getTime())<i?n:t),`round`)}case`month`:{let e=n(c.getMonth()+c.getDate()/this.lastDateOfMonth,s);c.setMonth(e,1),c.setHours(0,0,0,0);break}case`year`:{let e=Math.floor((c.getTime()-new Date(c.getFullYear(),0,1).getTime())/t),r=new Date(c.getFullYear(),1,29).getDate()===29?366:365,i=n(c.getFullYear()+e/r,s);c.setFullYear(i,0,1),c.setHours(0,0,0,0);break}default:return this}return a(new r(c),`round`,o(this),this.timeZoneName,this.timeZoneId,this.$tzTracker)}};export{r as roundPlugin};
1
+ import { s as INTERNALS, u as MS_PER_DAY } from "../basic-Dputob9z.mjs";
2
+ import { r as roundToNearest } from "../utilities-BU4MSYS7.mjs";
3
+
4
+ //#region src/plugins/roundPlugin.ts
5
+ /** * Plugin to inject `round` method */
6
+ const roundPlugin = ($Chronos) => {
7
+ const { internalDate, withOrigin, offset } = $Chronos[INTERNALS];
8
+ $Chronos.prototype.round = function(unit, nearest = 1) {
9
+ const date = new Date(internalDate(this));
10
+ switch (unit) {
11
+ case "millisecond": {
12
+ const rounded = roundToNearest(date.getMilliseconds(), nearest);
13
+ date.setMilliseconds(rounded);
14
+ break;
15
+ }
16
+ case "second": {
17
+ const rounded = roundToNearest(date.getSeconds() + date.getMilliseconds() / 1e3, nearest);
18
+ date.setSeconds(rounded, 0);
19
+ break;
20
+ }
21
+ case "minute": {
22
+ const rounded = roundToNearest(date.getMinutes() + date.getSeconds() / 60 + date.getMilliseconds() / 6e4, nearest);
23
+ date.setMinutes(rounded, 0, 0);
24
+ break;
25
+ }
26
+ case "hour": {
27
+ const rounded = roundToNearest(date.getHours() + date.getMinutes() / 60 + date.getSeconds() / 3600 + date.getMilliseconds() / 36e5, nearest);
28
+ date.setHours(rounded, 0, 0, 0);
29
+ break;
30
+ }
31
+ case "day": {
32
+ const rounded = roundToNearest(date.getDate() + (date.getHours() / 24 + date.getMinutes() / 1440 + date.getSeconds() / 86400 + date.getMilliseconds() / MS_PER_DAY), nearest);
33
+ date.setDate(rounded);
34
+ date.setHours(0, 0, 0, 0);
35
+ break;
36
+ }
37
+ case "week": {
38
+ const offsetToMonday = (date.getDay() + 6) % 7;
39
+ const startOfWeek = new Date(date);
40
+ startOfWeek.setDate(startOfWeek.getDate() - offsetToMonday);
41
+ startOfWeek.setHours(0, 0, 0, 0);
42
+ const endOfWeek = new Date(startOfWeek);
43
+ endOfWeek.setDate(endOfWeek.getDate() + 7);
44
+ const diffToStart = Math.abs(date.getTime() - startOfWeek.getTime());
45
+ return withOrigin(new $Chronos(Math.abs(endOfWeek.getTime() - date.getTime()) < diffToStart ? endOfWeek : startOfWeek), "round");
46
+ }
47
+ case "month": {
48
+ const roundedMonth = roundToNearest(date.getMonth() + date.getDate() / this.lastDateOfMonth, nearest);
49
+ date.setMonth(roundedMonth, 1);
50
+ date.setHours(0, 0, 0, 0);
51
+ break;
52
+ }
53
+ case "year": {
54
+ const dayOfYear = Math.floor((date.getTime() - new Date(date.getFullYear(), 0, 1).getTime()) / MS_PER_DAY);
55
+ const totalDays = new Date(date.getFullYear(), 1, 29).getDate() === 29 ? 366 : 365;
56
+ const roundedYear = roundToNearest(date.getFullYear() + dayOfYear / totalDays, nearest);
57
+ date.setFullYear(roundedYear, 0, 1);
58
+ date.setHours(0, 0, 0, 0);
59
+ break;
60
+ }
61
+ default: return this;
62
+ }
63
+ return withOrigin(new $Chronos(date), "round", offset(this), this.timeZoneName, this.timeZoneId, this.$tzTracker);
64
+ };
65
+ };
66
+
67
+ //#endregion
68
+ export { roundPlugin };
@@ -1 +1,31 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../seasons-oABOhHcX.cjs`),t=t=>{t.prototype.season=function(t){let{preset:n=`default`}=t??{},r=t?.seasons??e.u[n],i=this.format(`MM-DD`);for(let{name:e,boundary:t}of r)if(`startDate`in t&&`endDate`in t){let n=t.startDate,r=t.endDate;if(n<=r){if(i>=n&&i<=r)return e}else if(i>=n||i<=r)return e}else if(`startMonth`in t&&`endMonth`in t){let{startMonth:n,endMonth:r}=t;if(n<=r){if(this.month>=n&&this.month<=r)return e}else if(this.month>=n||this.month<=r)return e}return`Unknown`},t.prototype.getSeasonName=function(e){return this.season(e)}};exports.seasonPlugin=t;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_seasons = require('../seasons-CcZicoe1.cjs');
3
+
4
+ //#region src/plugins/seasonPlugin.ts
5
+ /** * Plugin to inject `season`/`getSeasonName` method */
6
+ const seasonPlugin = ($Chronos) => {
7
+ $Chronos.prototype.season = function(options) {
8
+ const { preset = "default" } = options ?? {};
9
+ const seasonSet = options?.seasons ?? require_seasons.SEASON_PRESETS[preset];
10
+ const dateStr = this.format("MM-DD");
11
+ for (const { name, boundary } of seasonSet) if ("startDate" in boundary && "endDate" in boundary) {
12
+ const start = boundary.startDate;
13
+ const end = boundary.endDate;
14
+ if (start <= end) {
15
+ if (dateStr >= start && dateStr <= end) return name;
16
+ } else if (dateStr >= start || dateStr <= end) return name;
17
+ } else if ("startMonth" in boundary && "endMonth" in boundary) {
18
+ const { startMonth, endMonth } = boundary;
19
+ if (startMonth <= endMonth) {
20
+ if (this.month >= startMonth && this.month <= endMonth) return name;
21
+ } else if (this.month >= startMonth || this.month <= endMonth) return name;
22
+ }
23
+ return "Unknown";
24
+ };
25
+ $Chronos.prototype.getSeasonName = function(options) {
26
+ return this.season(options);
27
+ };
28
+ };
29
+
30
+ //#endregion
31
+ exports.seasonPlugin = seasonPlugin;
@@ -1 +1,30 @@
1
- import{u as e}from"../seasons-ChAIVphi.mjs";const t=t=>{t.prototype.season=function(t){let{preset:n=`default`}=t??{},r=t?.seasons??e[n],i=this.format(`MM-DD`);for(let{name:e,boundary:t}of r)if(`startDate`in t&&`endDate`in t){let n=t.startDate,r=t.endDate;if(n<=r){if(i>=n&&i<=r)return e}else if(i>=n||i<=r)return e}else if(`startMonth`in t&&`endMonth`in t){let{startMonth:n,endMonth:r}=t;if(n<=r){if(this.month>=n&&this.month<=r)return e}else if(this.month>=n||this.month<=r)return e}return`Unknown`},t.prototype.getSeasonName=function(e){return this.season(e)}};export{t as seasonPlugin};
1
+ import { u as SEASON_PRESETS } from "../seasons-CHnjrIKK.mjs";
2
+
3
+ //#region src/plugins/seasonPlugin.ts
4
+ /** * Plugin to inject `season`/`getSeasonName` method */
5
+ const seasonPlugin = ($Chronos) => {
6
+ $Chronos.prototype.season = function(options) {
7
+ const { preset = "default" } = options ?? {};
8
+ const seasonSet = options?.seasons ?? SEASON_PRESETS[preset];
9
+ const dateStr = this.format("MM-DD");
10
+ for (const { name, boundary } of seasonSet) if ("startDate" in boundary && "endDate" in boundary) {
11
+ const start = boundary.startDate;
12
+ const end = boundary.endDate;
13
+ if (start <= end) {
14
+ if (dateStr >= start && dateStr <= end) return name;
15
+ } else if (dateStr >= start || dateStr <= end) return name;
16
+ } else if ("startMonth" in boundary && "endMonth" in boundary) {
17
+ const { startMonth, endMonth } = boundary;
18
+ if (startMonth <= endMonth) {
19
+ if (this.month >= startMonth && this.month <= endMonth) return name;
20
+ } else if (this.month >= startMonth || this.month <= endMonth) return name;
21
+ }
22
+ return "Unknown";
23
+ };
24
+ $Chronos.prototype.getSeasonName = function(options) {
25
+ return this.season(options);
26
+ };
27
+ };
28
+
29
+ //#endregion
30
+ export { seasonPlugin };
@@ -1 +1,139 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../basic-CKxaRSHQ.cjs`),t=require(`../timezone-CWxbK_7I.cjs`),n=require(`../guards.cjs`),r=require(`../helpers-DGzYnP81.cjs`),i=require(`../utilities-B8dOAQVD.cjs`),a=a=>{let{internalDate:o,withOrigin:s,offset:c}=a[e.s],l=e=>e===`UTC+00:00`||e===`UTC-00:00`,u=e=>e?e in t.o:!1,d=e=>e in t.r,f=e=>{if(u(e))return t.o[e]},p=(e,t)=>{let n=[`long`,`longOffset`],i={tzId:e};for(let a of n){let n=a===`long`?`tzName`:`offset`;try{let o=r.p(e,a,t);i[n]=a===`longOffset`?r.s(o):o}catch{i[n]=void 0}}return i},m=new Map(t.n.reduce((e,t)=>{let{offset:n}=p(t);if(n){let r=e.get(n)??[];r.push(t),e.set(n,r)}return e},new Map)),h=new Map(Object.entries(t.r).map(([e,{offset:t,tzName:n}])=>[t,{tzAbbr:e,tzName:n}])),g=e=>{let t=m.get(e);if(!(!t||t?.length===0))return t?.length===1?t[0]:t},_=(e,r)=>{if(l(e))return`Greenwich Mean Time`;if(n.isValidUTCOffset(e)){let t=f(e);return!t&&h.has(e)?h.get(e)?.tzName:t}else if(d(e))return t.r[e].tzName;else{let{offset:t,tzName:n}=p(e,r);return n||f(t)}};a.prototype.timeZone=function(e){let r,c;n.isValidUTCOffset(e)?(r=e,c=g(r)||r):d(e)?(r=t.r[e].offset,c=g(r)||r):(r=p(e,o(this)).offset||t.r.UTC.offset,c=e);let l=e||r,u=_(l,o(this))??r,f=i.r(r)-this.getTimeZoneOffsetMinutes();return s(new a(new Date(o(this).getTime()+f*60*1e3)),`timeZone`,r,u,c,l)},a.prototype.getTimeZoneName=function(e){let t=e||c(this);return _(e||this?.$tzTracker||c(this),o(this))??t};let v=new Map,y=e=>e.split(/\s+/).map(e=>e[0]).join(``).replace(/\W/g,``);a.prototype.getTimeZoneNameShort=function(e){let t=this?.$tzTracker,r=e||c(this),i=e||t||c(this);if(l(i))return`GMT`;if(!e&&t&&d(t))return t;if(n.isValidUTCOffset(i)){if(v.has(i))return v.get(i);if(h.has(i))return h.get(i)?.tzAbbr;let e=f(i);if(e){let t=y(e);return v.set(i,t),t}}let a=_(i,o(this))??r;if(v.has(`name-${a}`))return v.get(a);let s=n.isValidUTCOffset(a)?a:y(a);return v.set(`name-${a}`,s),s},a.prototype.getTimeZoneNameAbbr=function(e){return this.getTimeZoneNameShort(e)}};exports.timeZonePlugin=a;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_basic = require('../basic-DIp_pxR2.cjs');
3
+ const require_timezone = require('../timezone-DYVJJYKz.cjs');
4
+ const require_guards = require('../guards.cjs');
5
+ const require_helpers = require('../helpers-M_SfAbAv.cjs');
6
+ const require_utilities = require('../utilities-bXwTPJaD.cjs');
7
+
8
+ //#region src/plugins/timeZonePlugin.ts
9
+ /** * Plugin to inject `timeZone` related methods */
10
+ const timeZonePlugin = ($Chronos) => {
11
+ const { internalDate: $Date, withOrigin, offset } = $Chronos[require_basic.INTERNALS];
12
+ /** Check if a time zone factor represents GMT */
13
+ const _isGMT = (factor) => {
14
+ return factor === "UTC+00:00" || factor === "UTC-00:00";
15
+ };
16
+ /** Check if a string is the key of `TIME_ZONE_LABELS` constant */
17
+ const _isLabelKey = (offset) => {
18
+ return offset ? offset in require_timezone.TIME_ZONE_LABELS : false;
19
+ };
20
+ /** Check if a string is time zone abbreviation */
21
+ const _isValidTzAbbr = (tz) => {
22
+ return tz in require_timezone.TIME_ZONES;
23
+ };
24
+ /** Resolve time zone name from `TIME_ZONE_LABELS` constant using UTC offset or get undefined */
25
+ const _resolveTzName = (offset) => {
26
+ if (_isLabelKey(offset)) return require_timezone.TIME_ZONE_LABELS[offset];
27
+ };
28
+ /**
29
+ * * Retrieves comprehensive time zone details using the {@link Intl.supportedValuesOf} API.
30
+ * @param tzId Time zone identifier. Defaults to the system timezone.
31
+ * @param date Date for which to resolve the information.
32
+ * @returns Object containing time zone identifier, name, and offset.
33
+ */
34
+ const _getTimeZoneDetails = (tzId, date) => {
35
+ const TZ_NAME_TYPES = ["long", "longOffset"];
36
+ const obj = { tzId };
37
+ for (const type of TZ_NAME_TYPES) {
38
+ const key = type === "long" ? "tzName" : "offset";
39
+ try {
40
+ const partValue = require_helpers._resolveNativeTzName(tzId, type, date);
41
+ obj[key] = type === "longOffset" ? require_helpers._gmtToUtcOffset(partValue) : partValue;
42
+ } catch {
43
+ obj[key] = void 0;
44
+ }
45
+ }
46
+ return obj;
47
+ };
48
+ /** Cache to store time zone id (from {@link Intl.supportedValuesOf}) against UTC offset */
49
+ const TZ_ID_MAP = new Map(require_timezone.NATIVE_TZ_IDS.reduce((tzIds, id) => {
50
+ const { offset } = _getTimeZoneDetails(id);
51
+ if (offset) {
52
+ const arr = tzIds.get(offset) ?? [];
53
+ arr.push(id);
54
+ tzIds.set(offset, arr);
55
+ }
56
+ return tzIds;
57
+ }, /* @__PURE__ */ new Map()));
58
+ /** Cache to store time zone name and abbreviation against UTC offset from {@link TIME_ZONES} */
59
+ const TZ_NAME_ABBR_MAP = new Map(Object.entries(require_timezone.TIME_ZONES).map(([tzAbbr, { offset, tzName }]) => [offset, {
60
+ tzAbbr,
61
+ tzName
62
+ }]));
63
+ /** Get time zone identifier from {@link TZ_ID_MAP} using UTC offset */
64
+ const _getTimeZoneId = (utc) => {
65
+ const tzIds = TZ_ID_MAP.get(utc);
66
+ if (!tzIds || tzIds?.length === 0) return void 0;
67
+ if (tzIds?.length === 1) return tzIds[0];
68
+ return tzIds;
69
+ };
70
+ /** Get time zone name from `Intl.supportedValuesOf('timeZone')`, `TIME_ZONE_LABELS` or `TIME_ZONES` constants using UTC offset, time zone identifier or time zone abbreviation */
71
+ const _getTimeZoneName = (zone, date) => {
72
+ if (_isGMT(zone)) return "Greenwich Mean Time";
73
+ if (require_guards.isValidUTCOffset(zone)) {
74
+ const tzName = _resolveTzName(zone);
75
+ if (!tzName && TZ_NAME_ABBR_MAP.has(zone)) return TZ_NAME_ABBR_MAP.get(zone)?.tzName;
76
+ return tzName;
77
+ } else if (_isValidTzAbbr(zone)) return require_timezone.TIME_ZONES[zone].tzName;
78
+ else {
79
+ const { offset, tzName } = _getTimeZoneDetails(zone, date);
80
+ return tzName || _resolveTzName(offset);
81
+ }
82
+ };
83
+ $Chronos.prototype.timeZone = function(zone) {
84
+ let offset;
85
+ let tzId;
86
+ if (require_guards.isValidUTCOffset(zone)) {
87
+ offset = zone;
88
+ tzId = _getTimeZoneId(offset) || offset;
89
+ } else if (_isValidTzAbbr(zone)) {
90
+ offset = require_timezone.TIME_ZONES[zone].offset;
91
+ tzId = _getTimeZoneId(offset) || offset;
92
+ } else {
93
+ offset = _getTimeZoneDetails(zone, $Date(this)).offset || require_timezone.TIME_ZONES["UTC"].offset;
94
+ tzId = zone;
95
+ }
96
+ const $zone = zone || offset;
97
+ const tzName = _getTimeZoneName($zone, $Date(this)) ?? offset;
98
+ const relativeOffset = require_utilities.extractMinutesFromUTC(offset) - this.getTimeZoneOffsetMinutes();
99
+ return withOrigin(new $Chronos(new Date($Date(this).getTime() + relativeOffset * 60 * 1e3)), `timeZone`, offset, tzName, tzId, $zone);
100
+ };
101
+ $Chronos.prototype.getTimeZoneName = function(utc) {
102
+ const UTC = utc || offset(this);
103
+ return _getTimeZoneName(utc || this?.$tzTracker || offset(this), $Date(this)) ?? UTC;
104
+ };
105
+ /** Cache to store abbreviated time zone names */
106
+ const TZ_ABBR_CACHE = /* @__PURE__ */ new Map();
107
+ /** Abbreviate full time zone name */
108
+ const _abbreviate = (name) => {
109
+ return name.split(/\s+/).map((w) => w[0]).join("").replace(/\W/g, "");
110
+ };
111
+ $Chronos.prototype.getTimeZoneNameShort = function(utc) {
112
+ const tracker = this?.$tzTracker;
113
+ const UTC = utc || offset(this);
114
+ const tzMapKey = utc || tracker || offset(this);
115
+ if (_isGMT(tzMapKey)) return "GMT";
116
+ if (!utc && tracker && _isValidTzAbbr(tracker)) return tracker;
117
+ if (require_guards.isValidUTCOffset(tzMapKey)) {
118
+ if (TZ_ABBR_CACHE.has(tzMapKey)) return TZ_ABBR_CACHE.get(tzMapKey);
119
+ if (TZ_NAME_ABBR_MAP.has(tzMapKey)) return TZ_NAME_ABBR_MAP.get(tzMapKey)?.tzAbbr;
120
+ const tzName = _resolveTzName(tzMapKey);
121
+ if (tzName) {
122
+ const tzAbbr = _abbreviate(tzName);
123
+ TZ_ABBR_CACHE.set(tzMapKey, tzAbbr);
124
+ return tzAbbr;
125
+ }
126
+ }
127
+ const zone = _getTimeZoneName(tzMapKey, $Date(this)) ?? UTC;
128
+ if (TZ_ABBR_CACHE.has(`name-${zone}`)) return TZ_ABBR_CACHE.get(zone);
129
+ const customAbbr = require_guards.isValidUTCOffset(zone) ? zone : _abbreviate(zone);
130
+ TZ_ABBR_CACHE.set(`name-${zone}`, customAbbr);
131
+ return customAbbr;
132
+ };
133
+ $Chronos.prototype.getTimeZoneNameAbbr = function(utc) {
134
+ return this.getTimeZoneNameShort(utc);
135
+ };
136
+ };
137
+
138
+ //#endregion
139
+ exports.timeZonePlugin = timeZonePlugin;
@@ -1 +1,138 @@
1
- import{s as e}from"../basic-e46DaNAi.mjs";import{n as t,o as n,r}from"../timezone-B10UItNO.mjs";import{isValidUTCOffset as i}from"../guards.mjs";import{p as a,s as o}from"../helpers-N1X_Rj_V.mjs";import{r as s}from"../utilities-DV_ohS37.mjs";const c=c=>{let{internalDate:l,withOrigin:u,offset:d}=c[e],f=e=>e===`UTC+00:00`||e===`UTC-00:00`,p=e=>e?e in n:!1,m=e=>e in r,h=e=>{if(p(e))return n[e]},g=(e,t)=>{let n=[`long`,`longOffset`],r={tzId:e};for(let i of n){let n=i===`long`?`tzName`:`offset`;try{let s=a(e,i,t);r[n]=i===`longOffset`?o(s):s}catch{r[n]=void 0}}return r},_=new Map(t.reduce((e,t)=>{let{offset:n}=g(t);if(n){let r=e.get(n)??[];r.push(t),e.set(n,r)}return e},new Map)),v=new Map(Object.entries(r).map(([e,{offset:t,tzName:n}])=>[t,{tzAbbr:e,tzName:n}])),y=e=>{let t=_.get(e);if(!(!t||t?.length===0))return t?.length===1?t[0]:t},b=(e,t)=>{if(f(e))return`Greenwich Mean Time`;if(i(e)){let t=h(e);return!t&&v.has(e)?v.get(e)?.tzName:t}else if(m(e))return r[e].tzName;else{let{offset:n,tzName:r}=g(e,t);return r||h(n)}};c.prototype.timeZone=function(e){let t,n;i(e)?(t=e,n=y(t)||t):m(e)?(t=r[e].offset,n=y(t)||t):(t=g(e,l(this)).offset||r.UTC.offset,n=e);let a=e||t,o=b(a,l(this))??t,d=s(t)-this.getTimeZoneOffsetMinutes();return u(new c(new Date(l(this).getTime()+d*60*1e3)),`timeZone`,t,o,n,a)},c.prototype.getTimeZoneName=function(e){let t=e||d(this);return b(e||this?.$tzTracker||d(this),l(this))??t};let x=new Map,S=e=>e.split(/\s+/).map(e=>e[0]).join(``).replace(/\W/g,``);c.prototype.getTimeZoneNameShort=function(e){let t=this?.$tzTracker,n=e||d(this),r=e||t||d(this);if(f(r))return`GMT`;if(!e&&t&&m(t))return t;if(i(r)){if(x.has(r))return x.get(r);if(v.has(r))return v.get(r)?.tzAbbr;let e=h(r);if(e){let t=S(e);return x.set(r,t),t}}let a=b(r,l(this))??n;if(x.has(`name-${a}`))return x.get(a);let o=i(a)?a:S(a);return x.set(`name-${a}`,o),o},c.prototype.getTimeZoneNameAbbr=function(e){return this.getTimeZoneNameShort(e)}};export{c as timeZonePlugin};
1
+ import { s as INTERNALS } from "../basic-Dputob9z.mjs";
2
+ import { n as NATIVE_TZ_IDS, o as TIME_ZONE_LABELS, r as TIME_ZONES } from "../timezone-BfBXeMK_.mjs";
3
+ import { isValidUTCOffset } from "../guards.mjs";
4
+ import { p as _resolveNativeTzName, s as _gmtToUtcOffset } from "../helpers-CrMc9iJZ.mjs";
5
+ import { r as extractMinutesFromUTC } from "../utilities-CtOZhIYv.mjs";
6
+
7
+ //#region src/plugins/timeZonePlugin.ts
8
+ /** * Plugin to inject `timeZone` related methods */
9
+ const timeZonePlugin = ($Chronos) => {
10
+ const { internalDate: $Date, withOrigin, offset } = $Chronos[INTERNALS];
11
+ /** Check if a time zone factor represents GMT */
12
+ const _isGMT = (factor) => {
13
+ return factor === "UTC+00:00" || factor === "UTC-00:00";
14
+ };
15
+ /** Check if a string is the key of `TIME_ZONE_LABELS` constant */
16
+ const _isLabelKey = (offset) => {
17
+ return offset ? offset in TIME_ZONE_LABELS : false;
18
+ };
19
+ /** Check if a string is time zone abbreviation */
20
+ const _isValidTzAbbr = (tz) => {
21
+ return tz in TIME_ZONES;
22
+ };
23
+ /** Resolve time zone name from `TIME_ZONE_LABELS` constant using UTC offset or get undefined */
24
+ const _resolveTzName = (offset) => {
25
+ if (_isLabelKey(offset)) return TIME_ZONE_LABELS[offset];
26
+ };
27
+ /**
28
+ * * Retrieves comprehensive time zone details using the {@link Intl.supportedValuesOf} API.
29
+ * @param tzId Time zone identifier. Defaults to the system timezone.
30
+ * @param date Date for which to resolve the information.
31
+ * @returns Object containing time zone identifier, name, and offset.
32
+ */
33
+ const _getTimeZoneDetails = (tzId, date) => {
34
+ const TZ_NAME_TYPES = ["long", "longOffset"];
35
+ const obj = { tzId };
36
+ for (const type of TZ_NAME_TYPES) {
37
+ const key = type === "long" ? "tzName" : "offset";
38
+ try {
39
+ const partValue = _resolveNativeTzName(tzId, type, date);
40
+ obj[key] = type === "longOffset" ? _gmtToUtcOffset(partValue) : partValue;
41
+ } catch {
42
+ obj[key] = void 0;
43
+ }
44
+ }
45
+ return obj;
46
+ };
47
+ /** Cache to store time zone id (from {@link Intl.supportedValuesOf}) against UTC offset */
48
+ const TZ_ID_MAP = new Map(NATIVE_TZ_IDS.reduce((tzIds, id) => {
49
+ const { offset } = _getTimeZoneDetails(id);
50
+ if (offset) {
51
+ const arr = tzIds.get(offset) ?? [];
52
+ arr.push(id);
53
+ tzIds.set(offset, arr);
54
+ }
55
+ return tzIds;
56
+ }, /* @__PURE__ */ new Map()));
57
+ /** Cache to store time zone name and abbreviation against UTC offset from {@link TIME_ZONES} */
58
+ const TZ_NAME_ABBR_MAP = new Map(Object.entries(TIME_ZONES).map(([tzAbbr, { offset, tzName }]) => [offset, {
59
+ tzAbbr,
60
+ tzName
61
+ }]));
62
+ /** Get time zone identifier from {@link TZ_ID_MAP} using UTC offset */
63
+ const _getTimeZoneId = (utc) => {
64
+ const tzIds = TZ_ID_MAP.get(utc);
65
+ if (!tzIds || tzIds?.length === 0) return void 0;
66
+ if (tzIds?.length === 1) return tzIds[0];
67
+ return tzIds;
68
+ };
69
+ /** Get time zone name from `Intl.supportedValuesOf('timeZone')`, `TIME_ZONE_LABELS` or `TIME_ZONES` constants using UTC offset, time zone identifier or time zone abbreviation */
70
+ const _getTimeZoneName = (zone, date) => {
71
+ if (_isGMT(zone)) return "Greenwich Mean Time";
72
+ if (isValidUTCOffset(zone)) {
73
+ const tzName = _resolveTzName(zone);
74
+ if (!tzName && TZ_NAME_ABBR_MAP.has(zone)) return TZ_NAME_ABBR_MAP.get(zone)?.tzName;
75
+ return tzName;
76
+ } else if (_isValidTzAbbr(zone)) return TIME_ZONES[zone].tzName;
77
+ else {
78
+ const { offset, tzName } = _getTimeZoneDetails(zone, date);
79
+ return tzName || _resolveTzName(offset);
80
+ }
81
+ };
82
+ $Chronos.prototype.timeZone = function(zone) {
83
+ let offset;
84
+ let tzId;
85
+ if (isValidUTCOffset(zone)) {
86
+ offset = zone;
87
+ tzId = _getTimeZoneId(offset) || offset;
88
+ } else if (_isValidTzAbbr(zone)) {
89
+ offset = TIME_ZONES[zone].offset;
90
+ tzId = _getTimeZoneId(offset) || offset;
91
+ } else {
92
+ offset = _getTimeZoneDetails(zone, $Date(this)).offset || TIME_ZONES["UTC"].offset;
93
+ tzId = zone;
94
+ }
95
+ const $zone = zone || offset;
96
+ const tzName = _getTimeZoneName($zone, $Date(this)) ?? offset;
97
+ const relativeOffset = extractMinutesFromUTC(offset) - this.getTimeZoneOffsetMinutes();
98
+ return withOrigin(new $Chronos(new Date($Date(this).getTime() + relativeOffset * 60 * 1e3)), `timeZone`, offset, tzName, tzId, $zone);
99
+ };
100
+ $Chronos.prototype.getTimeZoneName = function(utc) {
101
+ const UTC = utc || offset(this);
102
+ return _getTimeZoneName(utc || this?.$tzTracker || offset(this), $Date(this)) ?? UTC;
103
+ };
104
+ /** Cache to store abbreviated time zone names */
105
+ const TZ_ABBR_CACHE = /* @__PURE__ */ new Map();
106
+ /** Abbreviate full time zone name */
107
+ const _abbreviate = (name) => {
108
+ return name.split(/\s+/).map((w) => w[0]).join("").replace(/\W/g, "");
109
+ };
110
+ $Chronos.prototype.getTimeZoneNameShort = function(utc) {
111
+ const tracker = this?.$tzTracker;
112
+ const UTC = utc || offset(this);
113
+ const tzMapKey = utc || tracker || offset(this);
114
+ if (_isGMT(tzMapKey)) return "GMT";
115
+ if (!utc && tracker && _isValidTzAbbr(tracker)) return tracker;
116
+ if (isValidUTCOffset(tzMapKey)) {
117
+ if (TZ_ABBR_CACHE.has(tzMapKey)) return TZ_ABBR_CACHE.get(tzMapKey);
118
+ if (TZ_NAME_ABBR_MAP.has(tzMapKey)) return TZ_NAME_ABBR_MAP.get(tzMapKey)?.tzAbbr;
119
+ const tzName = _resolveTzName(tzMapKey);
120
+ if (tzName) {
121
+ const tzAbbr = _abbreviate(tzName);
122
+ TZ_ABBR_CACHE.set(tzMapKey, tzAbbr);
123
+ return tzAbbr;
124
+ }
125
+ }
126
+ const zone = _getTimeZoneName(tzMapKey, $Date(this)) ?? UTC;
127
+ if (TZ_ABBR_CACHE.has(`name-${zone}`)) return TZ_ABBR_CACHE.get(zone);
128
+ const customAbbr = isValidUTCOffset(zone) ? zone : _abbreviate(zone);
129
+ TZ_ABBR_CACHE.set(`name-${zone}`, customAbbr);
130
+ return customAbbr;
131
+ };
132
+ $Chronos.prototype.getTimeZoneNameAbbr = function(utc) {
133
+ return this.getTimeZoneNameShort(utc);
134
+ };
135
+ };
136
+
137
+ //#endregion
138
+ export { timeZonePlugin };
@@ -1 +1,51 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../basic-CKxaRSHQ.cjs`),t=require(`../helpers-DGzYnP81.cjs`),n=n=>{function r(e){return e[0]*100+e[1]}function i(t){let{preset:n=`western`,custom:i}=t??{};return[...i??e.m[n]].sort((e,t)=>r(e[1])-r(t[1]))}n.prototype.getZodiacSign=function(e){let{birthDate:t}=e??{},n,r;t&&t?.includes(`-`)?[n,r]=t.split(`-`).map(Number):(n=this.isoMonth,r=this.date);let a=i(e);for(let e=a.length-1;e>=0;e--){let[t,[i,o]]=a[e];if(n>i||n===i&&r>=o)return t;if(e===0)return a.at(-1)[0]}return a[0][0]},n.prototype.zodiac=function(e){return this.getZodiacSign(e)},n.prototype.getZodiacMeta=function(e,n){let r=i(n),a=r.findIndex(([t])=>t===e);if(a===-1)throw RangeError(`Invalid zodiac sign: "${e}"`);let[o,s]=r[a][1],[c,l]=(r[a+1]??r[0])[1];return{index:a,sign:e,start:`${t.f(o)}-${t.f(s)}`,end:`${t.f(c)}-${t.f(l-1)}`}}};exports.zodiacPlugin=n;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_basic = require('../basic-DIp_pxR2.cjs');
3
+ const require_helpers = require('../helpers-M_SfAbAv.cjs');
4
+
5
+ //#region src/plugins/zodiacPlugin.ts
6
+ /** * Plugin to inject `zodiac` related methods */
7
+ const zodiacPlugin = ($Chronos) => {
8
+ function _toHundreds(range) {
9
+ return range[0] * 100 + range[1];
10
+ }
11
+ function _resolveSigns(options) {
12
+ const { preset = "western", custom } = options ?? {};
13
+ return [...custom ?? require_basic.ZODIAC_PRESETS[preset]].sort((a, b) => _toHundreds(a[1]) - _toHundreds(b[1]));
14
+ }
15
+ $Chronos.prototype.getZodiacSign = function(options) {
16
+ const { birthDate } = options ?? {};
17
+ let month;
18
+ let date;
19
+ if (birthDate && birthDate?.includes("-")) [month, date] = birthDate.split("-").map(Number);
20
+ else {
21
+ month = this.isoMonth;
22
+ date = this.date;
23
+ }
24
+ const sortedSigns = _resolveSigns(options);
25
+ for (let i = sortedSigns.length - 1; i >= 0; i--) {
26
+ const [sign, [m, d]] = sortedSigns[i];
27
+ if (month > m || month === m && date >= d) return sign;
28
+ if (i === 0) return sortedSigns.at(-1)[0];
29
+ }
30
+ return sortedSigns[0][0];
31
+ };
32
+ $Chronos.prototype.zodiac = function(options) {
33
+ return this.getZodiacSign(options);
34
+ };
35
+ $Chronos.prototype.getZodiacMeta = function(sign, options) {
36
+ const sortedSigns = _resolveSigns(options);
37
+ const index = sortedSigns.findIndex(([s]) => s === sign);
38
+ if (index === -1) throw new RangeError(`Invalid zodiac sign: "${sign}"`);
39
+ const [startMonth, startDate] = sortedSigns[index][1];
40
+ const [endMonth, endDate] = (sortedSigns[index + 1] ?? sortedSigns[0])[1];
41
+ return {
42
+ index,
43
+ sign,
44
+ start: `${require_helpers._padZero(startMonth)}-${require_helpers._padZero(startDate)}`,
45
+ end: `${require_helpers._padZero(endMonth)}-${require_helpers._padZero(endDate - 1)}`
46
+ };
47
+ };
48
+ };
49
+
50
+ //#endregion
51
+ exports.zodiacPlugin = zodiacPlugin;