chronos-date 1.0.1 → 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 (102) 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.d.cts +1 -1
  19. package/dist/plugins/banglaPlugin.d.mts +1 -1
  20. package/dist/plugins/banglaPlugin.mjs +120 -1
  21. package/dist/plugins/businessPlugin.cjs +118 -1
  22. package/dist/plugins/businessPlugin.d.cts +1 -1
  23. package/dist/plugins/businessPlugin.d.mts +1 -1
  24. package/dist/plugins/businessPlugin.mjs +117 -1
  25. package/dist/plugins/dateRangePlugin.cjs +46 -1
  26. package/dist/plugins/dateRangePlugin.d.cts +1 -1
  27. package/dist/plugins/dateRangePlugin.d.mts +1 -1
  28. package/dist/plugins/dateRangePlugin.mjs +45 -1
  29. package/dist/plugins/dayPartPlugin.cjs +26 -1
  30. package/dist/plugins/dayPartPlugin.d.cts +1 -1
  31. package/dist/plugins/dayPartPlugin.d.mts +1 -1
  32. package/dist/plugins/dayPartPlugin.mjs +25 -1
  33. package/dist/plugins/durationPlugin.cjs +91 -1
  34. package/dist/plugins/durationPlugin.d.cts +1 -1
  35. package/dist/plugins/durationPlugin.d.mts +1 -1
  36. package/dist/plugins/durationPlugin.mjs +90 -1
  37. package/dist/plugins/fromNowPlugin.cjs +80 -1
  38. package/dist/plugins/fromNowPlugin.d.cts +1 -1
  39. package/dist/plugins/fromNowPlugin.d.mts +1 -1
  40. package/dist/plugins/fromNowPlugin.mjs +79 -1
  41. package/dist/plugins/greetingPlugin.cjs +19 -1
  42. package/dist/plugins/greetingPlugin.d.cts +1 -1
  43. package/dist/plugins/greetingPlugin.d.mts +1 -1
  44. package/dist/plugins/greetingPlugin.mjs +18 -1
  45. package/dist/plugins/palindromePlugin.cjs +22 -1
  46. package/dist/plugins/palindromePlugin.d.cts +1 -1
  47. package/dist/plugins/palindromePlugin.d.mts +1 -1
  48. package/dist/plugins/palindromePlugin.mjs +21 -1
  49. package/dist/plugins/relativeTimePlugin.cjs +74 -1
  50. package/dist/plugins/relativeTimePlugin.d.cts +1 -1
  51. package/dist/plugins/relativeTimePlugin.d.mts +1 -1
  52. package/dist/plugins/relativeTimePlugin.mjs +73 -1
  53. package/dist/plugins/roundPlugin.cjs +69 -1
  54. package/dist/plugins/roundPlugin.d.cts +1 -1
  55. package/dist/plugins/roundPlugin.d.mts +1 -1
  56. package/dist/plugins/roundPlugin.mjs +68 -1
  57. package/dist/plugins/seasonPlugin.cjs +31 -1
  58. package/dist/plugins/seasonPlugin.d.cts +1 -1
  59. package/dist/plugins/seasonPlugin.d.mts +1 -1
  60. package/dist/plugins/seasonPlugin.mjs +30 -1
  61. package/dist/plugins/timeZonePlugin.cjs +139 -1
  62. package/dist/plugins/timeZonePlugin.d.cts +1 -1
  63. package/dist/plugins/timeZonePlugin.d.mts +1 -1
  64. package/dist/plugins/timeZonePlugin.mjs +138 -1
  65. package/dist/plugins/zodiacPlugin.cjs +51 -1
  66. package/dist/plugins/zodiacPlugin.d.cts +1 -1
  67. package/dist/plugins/zodiacPlugin.d.mts +1 -1
  68. package/dist/plugins/zodiacPlugin.mjs +50 -1
  69. package/dist/primitives-BME3_QrA.cjs +49 -0
  70. package/dist/primitives-DEt6I7Sy.mjs +19 -0
  71. package/dist/seasons-CHnjrIKK.mjs +352 -0
  72. package/dist/seasons-CcZicoe1.cjs +418 -0
  73. package/dist/timezone-BfBXeMK_.mjs +5573 -0
  74. package/dist/timezone-DYVJJYKz.cjs +5609 -0
  75. package/dist/types.mjs +1 -1
  76. package/dist/utilities-BU4MSYS7.mjs +43 -0
  77. package/dist/utilities-CGL7F6R9.cjs +72 -0
  78. package/dist/utilities-CtOZhIYv.mjs +241 -0
  79. package/dist/utilities-bXwTPJaD.cjs +318 -0
  80. package/dist/utils.cjs +76 -1
  81. package/dist/utils.mjs +44 -1
  82. package/package.json +1 -1
  83. package/dist/basic-CKxaRSHQ.cjs +0 -1
  84. package/dist/basic-e46DaNAi.mjs +0 -1
  85. package/dist/convert-Bmp63ats.mjs +0 -1
  86. package/dist/convert-DrLrcgqz.cjs +0 -1
  87. package/dist/greet-BBsrvmkn.mjs +0 -1
  88. package/dist/greet-C-6mruI9.cjs +0 -1
  89. package/dist/helpers-DGzYnP81.cjs +0 -1
  90. package/dist/helpers-N1X_Rj_V.mjs +0 -1
  91. package/dist/non-primitives-B2EE6D6s.mjs +0 -1
  92. package/dist/non-primitives-Bu3a4WL4.cjs +0 -1
  93. package/dist/primitives-Cxss_JVF.mjs +0 -1
  94. package/dist/primitives-Db2FUp4e.cjs +0 -1
  95. package/dist/seasons-ChAIVphi.mjs +0 -1
  96. package/dist/seasons-oABOhHcX.cjs +0 -1
  97. package/dist/timezone-B10UItNO.mjs +0 -1
  98. package/dist/timezone-CWxbK_7I.cjs +0 -1
  99. package/dist/utilities-B8dOAQVD.cjs +0 -1
  100. package/dist/utilities-BJE06bms.mjs +0 -1
  101. package/dist/utilities-D2-p26DX.cjs +0 -1
  102. package/dist/utilities-DV_ohS37.mjs +0 -1
@@ -1,7 +1,7 @@
1
1
  import { C as $Chronos, En as LooseLiteral, Nt as TimeZoneIdentifier, Pt as TimeZoneName, Rt as UTCOffset, kt as TimeZone } from "../types-B2fgrJ86.mjs";
2
2
 
3
3
  //#region src/plugins/timeZonePlugin.d.ts
4
- declare module '../' {
4
+ declare module 'chronos-date' {
5
5
  interface Chronos {
6
6
  /**
7
7
  * @instance Creates a new instance of `Chronos` for the specified time zone identifier.
@@ -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;
@@ -1,7 +1,7 @@
1
1
  import { C as $Chronos, S as ZodiacSign, b as ZodiacOptions, v as ZodiacMeta, y as ZodiacMetaOptions } from "../types-DPTQ_yLx.cjs";
2
2
 
3
3
  //#region src/plugins/zodiacPlugin.d.ts
4
- declare module '../' {
4
+ declare module 'chronos-date' {
5
5
  interface Chronos {
6
6
  /**
7
7
  * @instance Returns the zodiac sign based on current date or `birthDate` option.
@@ -1,7 +1,7 @@
1
1
  import { C as $Chronos, S as ZodiacSign, b as ZodiacOptions, v as ZodiacMeta, y as ZodiacMetaOptions } from "../types-B2fgrJ86.mjs";
2
2
 
3
3
  //#region src/plugins/zodiacPlugin.d.ts
4
- declare module '../' {
4
+ declare module 'chronos-date' {
5
5
  interface Chronos {
6
6
  /**
7
7
  * @instance Returns the zodiac sign based on current date or `birthDate` option.
@@ -1 +1,50 @@
1
- import{m as e}from"../basic-e46DaNAi.mjs";import{f as t}from"../helpers-N1X_Rj_V.mjs";const n=n=>{function r(e){return e[0]*100+e[1]}function i(t){let{preset:n=`western`,custom:i}=t??{};return[...i??e[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(o)}-${t(s)}`,end:`${t(c)}-${t(l-1)}`}}};export{n as zodiacPlugin};
1
+ import { m as ZODIAC_PRESETS } from "../basic-Dputob9z.mjs";
2
+ import { f as _padZero } from "../helpers-CrMc9iJZ.mjs";
3
+
4
+ //#region src/plugins/zodiacPlugin.ts
5
+ /** * Plugin to inject `zodiac` related methods */
6
+ const zodiacPlugin = ($Chronos) => {
7
+ function _toHundreds(range) {
8
+ return range[0] * 100 + range[1];
9
+ }
10
+ function _resolveSigns(options) {
11
+ const { preset = "western", custom } = options ?? {};
12
+ return [...custom ?? ZODIAC_PRESETS[preset]].sort((a, b) => _toHundreds(a[1]) - _toHundreds(b[1]));
13
+ }
14
+ $Chronos.prototype.getZodiacSign = function(options) {
15
+ const { birthDate } = options ?? {};
16
+ let month;
17
+ let date;
18
+ if (birthDate && birthDate?.includes("-")) [month, date] = birthDate.split("-").map(Number);
19
+ else {
20
+ month = this.isoMonth;
21
+ date = this.date;
22
+ }
23
+ const sortedSigns = _resolveSigns(options);
24
+ for (let i = sortedSigns.length - 1; i >= 0; i--) {
25
+ const [sign, [m, d]] = sortedSigns[i];
26
+ if (month > m || month === m && date >= d) return sign;
27
+ if (i === 0) return sortedSigns.at(-1)[0];
28
+ }
29
+ return sortedSigns[0][0];
30
+ };
31
+ $Chronos.prototype.zodiac = function(options) {
32
+ return this.getZodiacSign(options);
33
+ };
34
+ $Chronos.prototype.getZodiacMeta = function(sign, options) {
35
+ const sortedSigns = _resolveSigns(options);
36
+ const index = sortedSigns.findIndex(([s]) => s === sign);
37
+ if (index === -1) throw new RangeError(`Invalid zodiac sign: "${sign}"`);
38
+ const [startMonth, startDate] = sortedSigns[index][1];
39
+ const [endMonth, endDate] = (sortedSigns[index + 1] ?? sortedSigns[0])[1];
40
+ return {
41
+ index,
42
+ sign,
43
+ start: `${_padZero(startMonth)}-${_padZero(startDate)}`,
44
+ end: `${_padZero(endMonth)}-${_padZero(endDate - 1)}`
45
+ };
46
+ };
47
+ };
48
+
49
+ //#endregion
50
+ export { zodiacPlugin };
@@ -0,0 +1,49 @@
1
+
2
+ //#region node_modules/.pnpm/nhb-toolbox@4.30.1/node_modules/nhb-toolbox/dist/esm/guards/primitives.js
3
+ function isNumber(value) {
4
+ return typeof value === "number" && Number.isFinite(value);
5
+ }
6
+ function isString(value) {
7
+ return typeof value === "string";
8
+ }
9
+ function isBoolean(value) {
10
+ return typeof value === "boolean";
11
+ }
12
+ function isUndefined(value) {
13
+ return value === void 0;
14
+ }
15
+ function isNonEmptyString(value) {
16
+ return isString(value) && value?.length > 0;
17
+ }
18
+
19
+ //#endregion
20
+ Object.defineProperty(exports, 'isBoolean', {
21
+ enumerable: true,
22
+ get: function () {
23
+ return isBoolean;
24
+ }
25
+ });
26
+ Object.defineProperty(exports, 'isNonEmptyString', {
27
+ enumerable: true,
28
+ get: function () {
29
+ return isNonEmptyString;
30
+ }
31
+ });
32
+ Object.defineProperty(exports, 'isNumber', {
33
+ enumerable: true,
34
+ get: function () {
35
+ return isNumber;
36
+ }
37
+ });
38
+ Object.defineProperty(exports, 'isString', {
39
+ enumerable: true,
40
+ get: function () {
41
+ return isString;
42
+ }
43
+ });
44
+ Object.defineProperty(exports, 'isUndefined', {
45
+ enumerable: true,
46
+ get: function () {
47
+ return isUndefined;
48
+ }
49
+ });
@@ -0,0 +1,19 @@
1
+ //#region node_modules/.pnpm/nhb-toolbox@4.30.1/node_modules/nhb-toolbox/dist/esm/guards/primitives.js
2
+ function isNumber(value) {
3
+ return typeof value === "number" && Number.isFinite(value);
4
+ }
5
+ function isString(value) {
6
+ return typeof value === "string";
7
+ }
8
+ function isBoolean(value) {
9
+ return typeof value === "boolean";
10
+ }
11
+ function isUndefined(value) {
12
+ return value === void 0;
13
+ }
14
+ function isNonEmptyString(value) {
15
+ return isString(value) && value?.length > 0;
16
+ }
17
+
18
+ //#endregion
19
+ export { isUndefined as a, isString as i, isNonEmptyString as n, isNumber as r, isBoolean as t };
@@ -0,0 +1,352 @@
1
+ //#region src/constants/seasons.ts
2
+ /** Western Seasons */
3
+ const DEFAULT_SEASONS = /* @__PURE__ */ Object.freeze([
4
+ {
5
+ name: "Spring",
6
+ boundary: {
7
+ startMonth: 2,
8
+ endMonth: 4
9
+ }
10
+ },
11
+ {
12
+ name: "Summer",
13
+ boundary: {
14
+ startMonth: 5,
15
+ endMonth: 7
16
+ }
17
+ },
18
+ {
19
+ name: "Autumn",
20
+ boundary: {
21
+ startMonth: 8,
22
+ endMonth: 10
23
+ }
24
+ },
25
+ {
26
+ name: "Winter",
27
+ boundary: {
28
+ startMonth: 11,
29
+ endMonth: 1
30
+ }
31
+ }
32
+ ]);
33
+ /**Default Bangladeshi Seasons */
34
+ const BANGLADESH_SEASONS = /* @__PURE__ */ Object.freeze([
35
+ {
36
+ name: "Grisma (Summer)",
37
+ boundary: {
38
+ startDate: "04-15",
39
+ endDate: "06-14"
40
+ }
41
+ },
42
+ {
43
+ name: "Barsa (Monsoon)",
44
+ boundary: {
45
+ startDate: "06-15",
46
+ endDate: "08-14"
47
+ }
48
+ },
49
+ {
50
+ name: "Sarat (Autumn)",
51
+ boundary: {
52
+ startDate: "08-15",
53
+ endDate: "10-14"
54
+ }
55
+ },
56
+ {
57
+ name: "Hemanta (Late-Autumn)",
58
+ boundary: {
59
+ startDate: "10-15",
60
+ endDate: "12-14"
61
+ }
62
+ },
63
+ {
64
+ name: "Shhit (Winter)",
65
+ boundary: {
66
+ startDate: "12-15",
67
+ endDate: "02-14"
68
+ }
69
+ },
70
+ {
71
+ name: "Basanta (Spring)",
72
+ boundary: {
73
+ startDate: "02-15",
74
+ endDate: "04-14"
75
+ }
76
+ }
77
+ ]);
78
+ /** Indian Seasons */
79
+ const INDIA_IMD_SEASONS = /* @__PURE__ */ Object.freeze([
80
+ {
81
+ name: "Winter",
82
+ boundary: {
83
+ startMonth: 0,
84
+ endMonth: 1
85
+ }
86
+ },
87
+ {
88
+ name: "Pre-Monsoon",
89
+ boundary: {
90
+ startMonth: 2,
91
+ endMonth: 4
92
+ }
93
+ },
94
+ {
95
+ name: "Monsoon",
96
+ boundary: {
97
+ startMonth: 5,
98
+ endMonth: 8
99
+ }
100
+ },
101
+ {
102
+ name: "Post-Monsoon",
103
+ boundary: {
104
+ startMonth: 9,
105
+ endMonth: 10
106
+ }
107
+ },
108
+ {
109
+ name: "Cool Season",
110
+ boundary: {
111
+ startMonth: 11,
112
+ endMonth: 11
113
+ }
114
+ }
115
+ ]);
116
+ /** Indian Vedic Seasons */
117
+ const INDIA_VEDIC_SEASONS = /* @__PURE__ */ Object.freeze([
118
+ {
119
+ name: "Shishir (Winter)",
120
+ boundary: {
121
+ startDate: "12-15",
122
+ endDate: "02-14"
123
+ }
124
+ },
125
+ {
126
+ name: "Vasanta (Spring)",
127
+ boundary: {
128
+ startDate: "02-15",
129
+ endDate: "04-14"
130
+ }
131
+ },
132
+ {
133
+ name: "Grishma (Summer)",
134
+ boundary: {
135
+ startDate: "04-15",
136
+ endDate: "06-14"
137
+ }
138
+ },
139
+ {
140
+ name: "Varsha (Monsoon)",
141
+ boundary: {
142
+ startDate: "06-15",
143
+ endDate: "08-14"
144
+ }
145
+ },
146
+ {
147
+ name: "Sharad (Autumn)",
148
+ boundary: {
149
+ startDate: "08-15",
150
+ endDate: "10-14"
151
+ }
152
+ },
153
+ {
154
+ name: "Hemant (Late-Autumn)",
155
+ boundary: {
156
+ startDate: "10-15",
157
+ endDate: "12-14"
158
+ }
159
+ }
160
+ ]);
161
+ /** Indian Tamil Seasons */
162
+ const INDIA_TAMIL_SEASONS = /* @__PURE__ */ Object.freeze([
163
+ {
164
+ name: "Ilavenil (Mid-Summer)",
165
+ boundary: {
166
+ startMonth: 4,
167
+ endMonth: 5
168
+ }
169
+ },
170
+ {
171
+ name: "Mutuvenil (Peak-Summer)",
172
+ boundary: {
173
+ startMonth: 6,
174
+ endMonth: 7
175
+ }
176
+ },
177
+ {
178
+ name: "Kaar (Monsoon)",
179
+ boundary: {
180
+ startMonth: 7,
181
+ endMonth: 9
182
+ }
183
+ },
184
+ {
185
+ name: "Koothir (Autumn)",
186
+ boundary: {
187
+ startMonth: 9,
188
+ endMonth: 10
189
+ }
190
+ },
191
+ {
192
+ name: "Munpani (Early-Winter)",
193
+ boundary: {
194
+ startMonth: 10,
195
+ endMonth: 0
196
+ }
197
+ },
198
+ {
199
+ name: "Pinpani (Late-Winter)",
200
+ boundary: {
201
+ startMonth: 0,
202
+ endMonth: 2
203
+ }
204
+ }
205
+ ]);
206
+ /** Philippines Seasons */
207
+ const PHILIPPINES_SEASONS = /* @__PURE__ */ Object.freeze([{
208
+ name: "Dry Season",
209
+ boundary: {
210
+ startMonth: 11,
211
+ endMonth: 4
212
+ }
213
+ }, {
214
+ name: "Wet Season",
215
+ boundary: {
216
+ startMonth: 5,
217
+ endMonth: 10
218
+ }
219
+ }]);
220
+ /** US Academic Seasons */
221
+ const US_ACADEMIC_SEASONS = /* @__PURE__ */ Object.freeze([
222
+ {
223
+ name: "Spring",
224
+ boundary: {
225
+ startDate: "01-10",
226
+ endDate: "05-15"
227
+ }
228
+ },
229
+ {
230
+ name: "Summer",
231
+ boundary: {
232
+ startDate: "05-16",
233
+ endDate: "08-15"
234
+ }
235
+ },
236
+ {
237
+ name: "Fall",
238
+ boundary: {
239
+ startDate: "08-16",
240
+ endDate: "12-20"
241
+ }
242
+ },
243
+ {
244
+ name: "Winter Break",
245
+ boundary: {
246
+ startDate: "12-21",
247
+ endDate: "01-09"
248
+ }
249
+ }
250
+ ]);
251
+ /** Japanese Seasons */
252
+ const JAPAN_SEASONS = /* @__PURE__ */ Object.freeze([
253
+ {
254
+ name: "Haru (Spring)",
255
+ boundary: {
256
+ startDate: "03-01",
257
+ endDate: "05-31"
258
+ }
259
+ },
260
+ {
261
+ name: "Natsu (Summer)",
262
+ boundary: {
263
+ startDate: "06-01",
264
+ endDate: "08-31"
265
+ }
266
+ },
267
+ {
268
+ name: "Aki (Autumn)",
269
+ boundary: {
270
+ startDate: "09-01",
271
+ endDate: "11-30"
272
+ }
273
+ },
274
+ {
275
+ name: "Fuyu (Winter)",
276
+ boundary: {
277
+ startDate: "12-01",
278
+ endDate: "02-28"
279
+ }
280
+ }
281
+ ]);
282
+ /** Australian Seasons */
283
+ const AUSTRALIA_SEASONS = /* @__PURE__ */ Object.freeze([
284
+ {
285
+ name: "Summer",
286
+ boundary: {
287
+ startMonth: 11,
288
+ endMonth: 1
289
+ }
290
+ },
291
+ {
292
+ name: "Autumn",
293
+ boundary: {
294
+ startMonth: 2,
295
+ endMonth: 4
296
+ }
297
+ },
298
+ {
299
+ name: "Winter",
300
+ boundary: {
301
+ startMonth: 5,
302
+ endMonth: 7
303
+ }
304
+ },
305
+ {
306
+ name: "Spring",
307
+ boundary: {
308
+ startMonth: 8,
309
+ endMonth: 10
310
+ }
311
+ }
312
+ ]);
313
+ /** Ethiopian Seasons */
314
+ const ETHIOPIA_SEASONS = /* @__PURE__ */ Object.freeze([
315
+ {
316
+ name: "Bega (Dry)",
317
+ boundary: {
318
+ startMonth: 10,
319
+ endMonth: 1
320
+ }
321
+ },
322
+ {
323
+ name: "Belg (Short Rain)",
324
+ boundary: {
325
+ startMonth: 2,
326
+ endMonth: 4
327
+ }
328
+ },
329
+ {
330
+ name: "Kiremt (Main Rain)",
331
+ boundary: {
332
+ startMonth: 5,
333
+ endMonth: 9
334
+ }
335
+ }
336
+ ]);
337
+ /** All the Season Presets for `new Chronos.season()` method */
338
+ const SEASON_PRESETS = /* @__PURE__ */ Object.freeze({
339
+ default: DEFAULT_SEASONS,
340
+ bangladesh: BANGLADESH_SEASONS,
341
+ india: INDIA_IMD_SEASONS,
342
+ tamil: INDIA_TAMIL_SEASONS,
343
+ vedic: INDIA_VEDIC_SEASONS,
344
+ philippines: PHILIPPINES_SEASONS,
345
+ academic_us: US_ACADEMIC_SEASONS,
346
+ japan: JAPAN_SEASONS,
347
+ australia: AUSTRALIA_SEASONS,
348
+ ethiopia: ETHIOPIA_SEASONS
349
+ });
350
+
351
+ //#endregion
352
+ export { INDIA_IMD_SEASONS as a, JAPAN_SEASONS as c, US_ACADEMIC_SEASONS as d, ETHIOPIA_SEASONS as i, PHILIPPINES_SEASONS as l, BANGLADESH_SEASONS as n, INDIA_TAMIL_SEASONS as o, DEFAULT_SEASONS as r, INDIA_VEDIC_SEASONS as s, AUSTRALIA_SEASONS as t, SEASON_PRESETS as u };