nhb-toolbox 4.28.57 → 4.28.64
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/CHANGELOG.md +10 -0
- package/dist/cjs/date/constants.js +8 -10
- package/dist/cjs/date/plugins/zodiacPlugin.js +32 -5
- package/dist/dts/date/constants.d.ts +6 -6
- package/dist/dts/date/plugins/zodiacPlugin.d.ts +20 -4
- package/dist/dts/date/types.d.ts +31 -8
- package/dist/esm/date/constants.js +8 -10
- package/dist/esm/date/plugins/zodiacPlugin.js +32 -5
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,16 @@
|
|
|
4
4
|
|
|
5
5
|
All notable changes to the package will be documented here.
|
|
6
6
|
|
|
7
|
+
## [4.28.64] - 2026-01-15
|
|
8
|
+
|
|
9
|
+
- **Added** new `zodiacPlugin` method: `getZodiacMeta` to retrieve zodiac *metadata* for a given *zodiac sign*.
|
|
10
|
+
|
|
11
|
+
## [4.28.60] - 2026-01-13
|
|
12
|
+
|
|
13
|
+
- **Fixed** `Chronos.getZodiacSign` boundary handling to correctly wrap across year transitions for *zodiac presets*.
|
|
14
|
+
- **Improved** zodiac resolution logic to ensure consistent results for early-January dates without altering existing zodiac presets.
|
|
15
|
+
- **Updated** `ZodiacArray` and `ZodiacOptions` types to support custom zodiac definitions with *correctly inferred sign names*.
|
|
16
|
+
|
|
7
17
|
## [4.28.57] - 2026-01-07
|
|
8
18
|
|
|
9
19
|
- **Enhanced** `Color.isLightColor` with an *optional brightness threshold* for custom light/dark detection.
|
|
@@ -74,22 +74,20 @@ exports.WESTERN_ZODIAC_SIGNS = /* @__PURE__ */ Object.freeze([
|
|
|
74
74
|
['Libra', [9, 23]],
|
|
75
75
|
['Scorpio', [10, 23]],
|
|
76
76
|
['Sagittarius', [11, 22]],
|
|
77
|
-
['Capricorn', [12, 22]],
|
|
78
77
|
]);
|
|
79
78
|
exports.VEDIC_ZODIAC_SIGNS = /* @__PURE__ */ Object.freeze([
|
|
80
79
|
['Capricorn', [1, 14]],
|
|
81
80
|
['Aquarius', [2, 13]],
|
|
82
81
|
['Pisces', [3, 14]],
|
|
83
|
-
['Aries', [4,
|
|
84
|
-
['Taurus', [5,
|
|
85
|
-
['Gemini', [6,
|
|
82
|
+
['Aries', [4, 14]],
|
|
83
|
+
['Taurus', [5, 15]],
|
|
84
|
+
['Gemini', [6, 15]],
|
|
86
85
|
['Cancer', [7, 16]],
|
|
87
|
-
['Leo', [8,
|
|
88
|
-
['Virgo', [9,
|
|
89
|
-
['Libra', [10,
|
|
90
|
-
['Scorpio', [11,
|
|
91
|
-
['Sagittarius', [12,
|
|
92
|
-
['Capricorn', [1, 14]],
|
|
86
|
+
['Leo', [8, 17]],
|
|
87
|
+
['Virgo', [9, 17]],
|
|
88
|
+
['Libra', [10, 17]],
|
|
89
|
+
['Scorpio', [11, 16]],
|
|
90
|
+
['Sagittarius', [12, 16]],
|
|
93
91
|
]);
|
|
94
92
|
exports.ZODIAC_PRESETS = /* @__PURE__ */ Object.freeze({
|
|
95
93
|
western: exports.WESTERN_ZODIAC_SIGNS,
|
|
@@ -2,9 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.zodiacPlugin = void 0;
|
|
4
4
|
const constants_1 = require("../constants");
|
|
5
|
+
const helpers_1 = require("../helpers");
|
|
5
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
|
+
const sorted = [...(custom ?? constants_1.ZODIAC_PRESETS[preset])].sort((a, b) => _toHundreds(a[1]) - _toHundreds(b[1]));
|
|
13
|
+
return sorted;
|
|
14
|
+
}
|
|
6
15
|
$Chronos.prototype.getZodiacSign = function (options) {
|
|
7
|
-
const { birthDate
|
|
16
|
+
const { birthDate } = options ?? {};
|
|
8
17
|
let month;
|
|
9
18
|
let date;
|
|
10
19
|
if (birthDate && birthDate?.includes('-')) {
|
|
@@ -14,17 +23,35 @@ const zodiacPlugin = ($Chronos) => {
|
|
|
14
23
|
month = this.isoMonth;
|
|
15
24
|
date = this.date;
|
|
16
25
|
}
|
|
17
|
-
const
|
|
18
|
-
for (let i =
|
|
19
|
-
const [sign, [m, d]] =
|
|
26
|
+
const sortedSigns = _resolveSigns(options);
|
|
27
|
+
for (let i = sortedSigns.length - 1; i >= 0; i--) {
|
|
28
|
+
const [sign, [m, d]] = sortedSigns[i];
|
|
20
29
|
if (month > m || (month === m && date >= d)) {
|
|
21
30
|
return sign;
|
|
22
31
|
}
|
|
32
|
+
if (i === 0) {
|
|
33
|
+
return sortedSigns.at(-1)[0];
|
|
34
|
+
}
|
|
23
35
|
}
|
|
24
|
-
return
|
|
36
|
+
return sortedSigns[0][0];
|
|
25
37
|
};
|
|
26
38
|
$Chronos.prototype.zodiac = function (options) {
|
|
27
39
|
return this.getZodiacSign(options);
|
|
28
40
|
};
|
|
41
|
+
$Chronos.prototype.getZodiacMeta = function (sign, options) {
|
|
42
|
+
const sortedSigns = _resolveSigns(options);
|
|
43
|
+
const index = sortedSigns.findIndex(([s]) => s === sign);
|
|
44
|
+
if (index === -1) {
|
|
45
|
+
throw new RangeError(`Invalid zodiac sign: "${sign}"`);
|
|
46
|
+
}
|
|
47
|
+
const [startMonth, startDate] = sortedSigns[index][1];
|
|
48
|
+
const [endMonth, endDate] = (sortedSigns[index + 1] ?? sortedSigns[0])[1];
|
|
49
|
+
return {
|
|
50
|
+
index,
|
|
51
|
+
sign,
|
|
52
|
+
start: `${(0, helpers_1._padZero)(startMonth)}-${(0, helpers_1._padZero)(startDate)}`,
|
|
53
|
+
end: `${(0, helpers_1._padZero)(endMonth)}-${(0, helpers_1._padZero)(endDate - 1)}`,
|
|
54
|
+
};
|
|
55
|
+
};
|
|
29
56
|
};
|
|
30
57
|
exports.zodiacPlugin = zodiacPlugin;
|
|
@@ -21,15 +21,15 @@ export declare const SORTED_TIME_FORMATS: readonly ("MM" | "SS" | "ms" | "DD" |
|
|
|
21
21
|
/** Ranges for day parts. */
|
|
22
22
|
export declare const DATE_PART_RANGES: Readonly<Record<DayPart, [ClockHour, ClockHour]>>;
|
|
23
23
|
/** Western Zodiac Signs */
|
|
24
|
-
export declare const WESTERN_ZODIAC_SIGNS: readonly [readonly ["Capricorn", readonly [12, 22]], readonly ["Aquarius", readonly [1, 20]], readonly ["Pisces", readonly [2, 19]], readonly ["Aries", readonly [3, 21]], readonly ["Taurus", readonly [4, 20]], readonly ["Gemini", readonly [5, 21]], readonly ["Cancer", readonly [6, 21]], readonly ["Leo", readonly [7, 23]], readonly ["Virgo", readonly [8, 23]], readonly ["Libra", readonly [9, 23]], readonly ["Scorpio", readonly [10, 23]], readonly ["Sagittarius", readonly [11, 22]]
|
|
24
|
+
export declare const WESTERN_ZODIAC_SIGNS: readonly [readonly ["Capricorn", readonly [12, 22]], readonly ["Aquarius", readonly [1, 20]], readonly ["Pisces", readonly [2, 19]], readonly ["Aries", readonly [3, 21]], readonly ["Taurus", readonly [4, 20]], readonly ["Gemini", readonly [5, 21]], readonly ["Cancer", readonly [6, 21]], readonly ["Leo", readonly [7, 23]], readonly ["Virgo", readonly [8, 23]], readonly ["Libra", readonly [9, 23]], readonly ["Scorpio", readonly [10, 23]], readonly ["Sagittarius", readonly [11, 22]]];
|
|
25
25
|
/** Vedic Zodiac Sign */
|
|
26
|
-
export declare const VEDIC_ZODIAC_SIGNS: readonly [readonly ["Capricorn", readonly [1, 14]], readonly ["Aquarius", readonly [2, 13]], readonly ["Pisces", readonly [3, 14]], readonly ["Aries", readonly [4,
|
|
26
|
+
export declare const VEDIC_ZODIAC_SIGNS: readonly [readonly ["Capricorn", readonly [1, 14]], readonly ["Aquarius", readonly [2, 13]], readonly ["Pisces", readonly [3, 14]], readonly ["Aries", readonly [4, 14]], readonly ["Taurus", readonly [5, 15]], readonly ["Gemini", readonly [6, 15]], readonly ["Cancer", readonly [7, 16]], readonly ["Leo", readonly [8, 17]], readonly ["Virgo", readonly [9, 17]], readonly ["Libra", readonly [10, 17]], readonly ["Scorpio", readonly [11, 16]], readonly ["Sagittarius", readonly [12, 16]]];
|
|
27
27
|
/** Zodiac Signs Presets */
|
|
28
28
|
export declare const ZODIAC_PRESETS: Readonly<{
|
|
29
|
-
readonly western: readonly [readonly ["Capricorn", readonly [12, 22]], readonly ["Aquarius", readonly [1, 20]], readonly ["Pisces", readonly [2, 19]], readonly ["Aries", readonly [3, 21]], readonly ["Taurus", readonly [4, 20]], readonly ["Gemini", readonly [5, 21]], readonly ["Cancer", readonly [6, 21]], readonly ["Leo", readonly [7, 23]], readonly ["Virgo", readonly [8, 23]], readonly ["Libra", readonly [9, 23]], readonly ["Scorpio", readonly [10, 23]], readonly ["Sagittarius", readonly [11, 22]]
|
|
30
|
-
readonly vedic: readonly [readonly ["Capricorn", readonly [1, 14]], readonly ["Aquarius", readonly [2, 13]], readonly ["Pisces", readonly [3, 14]], readonly ["Aries", readonly [4,
|
|
31
|
-
readonly tropical: readonly [readonly ["Capricorn", readonly [12, 22]], readonly ["Aquarius", readonly [1, 20]], readonly ["Pisces", readonly [2, 19]], readonly ["Aries", readonly [3, 21]], readonly ["Taurus", readonly [4, 20]], readonly ["Gemini", readonly [5, 21]], readonly ["Cancer", readonly [6, 21]], readonly ["Leo", readonly [7, 23]], readonly ["Virgo", readonly [8, 23]], readonly ["Libra", readonly [9, 23]], readonly ["Scorpio", readonly [10, 23]], readonly ["Sagittarius", readonly [11, 22]]
|
|
32
|
-
readonly sidereal: readonly [readonly ["Capricorn", readonly [1, 14]], readonly ["Aquarius", readonly [2, 13]], readonly ["Pisces", readonly [3, 14]], readonly ["Aries", readonly [4,
|
|
29
|
+
readonly western: readonly [readonly ["Capricorn", readonly [12, 22]], readonly ["Aquarius", readonly [1, 20]], readonly ["Pisces", readonly [2, 19]], readonly ["Aries", readonly [3, 21]], readonly ["Taurus", readonly [4, 20]], readonly ["Gemini", readonly [5, 21]], readonly ["Cancer", readonly [6, 21]], readonly ["Leo", readonly [7, 23]], readonly ["Virgo", readonly [8, 23]], readonly ["Libra", readonly [9, 23]], readonly ["Scorpio", readonly [10, 23]], readonly ["Sagittarius", readonly [11, 22]]];
|
|
30
|
+
readonly vedic: readonly [readonly ["Capricorn", readonly [1, 14]], readonly ["Aquarius", readonly [2, 13]], readonly ["Pisces", readonly [3, 14]], readonly ["Aries", readonly [4, 14]], readonly ["Taurus", readonly [5, 15]], readonly ["Gemini", readonly [6, 15]], readonly ["Cancer", readonly [7, 16]], readonly ["Leo", readonly [8, 17]], readonly ["Virgo", readonly [9, 17]], readonly ["Libra", readonly [10, 17]], readonly ["Scorpio", readonly [11, 16]], readonly ["Sagittarius", readonly [12, 16]]];
|
|
31
|
+
readonly tropical: readonly [readonly ["Capricorn", readonly [12, 22]], readonly ["Aquarius", readonly [1, 20]], readonly ["Pisces", readonly [2, 19]], readonly ["Aries", readonly [3, 21]], readonly ["Taurus", readonly [4, 20]], readonly ["Gemini", readonly [5, 21]], readonly ["Cancer", readonly [6, 21]], readonly ["Leo", readonly [7, 23]], readonly ["Virgo", readonly [8, 23]], readonly ["Libra", readonly [9, 23]], readonly ["Scorpio", readonly [10, 23]], readonly ["Sagittarius", readonly [11, 22]]];
|
|
32
|
+
readonly sidereal: readonly [readonly ["Capricorn", readonly [1, 14]], readonly ["Aquarius", readonly [2, 13]], readonly ["Pisces", readonly [3, 14]], readonly ["Aries", readonly [4, 14]], readonly ["Taurus", readonly [5, 15]], readonly ["Gemini", readonly [6, 15]], readonly ["Cancer", readonly [7, 16]], readonly ["Leo", readonly [8, 17]], readonly ["Virgo", readonly [9, 17]], readonly ["Libra", readonly [10, 17]], readonly ["Scorpio", readonly [11, 16]], readonly ["Sagittarius", readonly [12, 16]]];
|
|
33
33
|
}>;
|
|
34
34
|
/** Variants of different time units */
|
|
35
35
|
export declare const TIME_UNIT_VARIANTS: Readonly<{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { $Chronos, ZodiacOptions, ZodiacSign } from '../types';
|
|
1
|
+
import type { $Chronos, ZodiacMeta, ZodiacMetaOptions, ZodiacOptions, ZodiacSign } from '../types';
|
|
2
2
|
declare module '../Chronos' {
|
|
3
3
|
interface Chronos {
|
|
4
4
|
/**
|
|
@@ -6,7 +6,7 @@ declare module '../Chronos' {
|
|
|
6
6
|
* @param options Optional config to choose preset or provide custom zodiac date ranges.
|
|
7
7
|
* @returns The matching zodiac sign from preset/custom list.
|
|
8
8
|
*/
|
|
9
|
-
getZodiacSign(options?: ZodiacOptions):
|
|
9
|
+
getZodiacSign<Sign extends string = ZodiacSign>(options?: ZodiacOptions<Sign>): Sign;
|
|
10
10
|
/**
|
|
11
11
|
* @instance Returns the zodiac sign based on current date or `birthDate` option.
|
|
12
12
|
* @remarks This method is an alias for {@link https://toolbox.nazmul-nhb.dev/docs/classes/Chronos/names#getzodiacsign getZodiacSign} method.
|
|
@@ -14,8 +14,24 @@ declare module '../Chronos' {
|
|
|
14
14
|
* @param options Optional config to choose preset or provide custom zodiac date ranges.
|
|
15
15
|
* @returns The matching zodiac sign from preset/custom list.
|
|
16
16
|
*/
|
|
17
|
-
zodiac(options?: ZodiacOptions):
|
|
17
|
+
zodiac<Sign extends string = ZodiacSign>(options?: ZodiacOptions<Sign>): Sign;
|
|
18
|
+
/**
|
|
19
|
+
* @instance Returns detailed metadata for a given zodiac sign based on the selected `preset` or custom ranges.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* - The metadata includes the sign's `index` within the normalized zodiac order, its inclusive start and end dates.
|
|
23
|
+
* - **Note:** The returned `index` represents the chronological position of the zodiac sign based on Gregorian month–day ordering and may vary between different zodiac variants.
|
|
24
|
+
* - Handles year-boundary wrapping correctly (e.g. Capricorn, Sagittarius).
|
|
25
|
+
*
|
|
26
|
+
* @param sign The zodiac sign to retrieve metadata for.
|
|
27
|
+
* @param options Optional configuration to select a zodiac preset or provide custom ranges.
|
|
28
|
+
*
|
|
29
|
+
* @throws A {@link RangeError} if the provided sign does not exist in the resolved zodiac set.
|
|
30
|
+
*
|
|
31
|
+
* @returns A metadata object describing the zodiac sign's position and date range.
|
|
32
|
+
*/
|
|
33
|
+
getZodiacMeta<Sign extends string = ZodiacSign>(sign: Sign, options?: ZodiacMetaOptions<Sign>): ZodiacMeta<Sign>;
|
|
18
34
|
}
|
|
19
35
|
}
|
|
20
|
-
/** * Plugin to inject `
|
|
36
|
+
/** * Plugin to inject `zodiac` related methods */
|
|
21
37
|
export declare const zodiacPlugin: ($Chronos: $Chronos) => void;
|
package/dist/dts/date/types.d.ts
CHANGED
|
@@ -304,20 +304,43 @@ export type DayPartConfig = Record<DayPart, [ClockHour, ClockHour]>;
|
|
|
304
304
|
export type Quarter = 1 | 2 | 3 | 4;
|
|
305
305
|
/** Academic year, e.g. `2024-2025` */
|
|
306
306
|
export type AcademicYear = `${number}-${number}`;
|
|
307
|
-
/** Names of Zodiac signs */
|
|
307
|
+
/** Names of standard Zodiac signs */
|
|
308
308
|
export type ZodiacSign = (typeof WESTERN_ZODIAC_SIGNS)[number][0];
|
|
309
309
|
/** Presets for Zodiac Sign Configuration */
|
|
310
310
|
export type ZodiacPreset = keyof typeof ZODIAC_PRESETS;
|
|
311
311
|
/** Shape of Zodiac signs array */
|
|
312
|
-
export type ZodiacArray = Array<[
|
|
312
|
+
export type ZodiacArray<Sign extends string = ZodiacSign> = Array<[Sign, [NumberRange<1, 12>, NumberRange<1, 31>]] | Readonly<[Sign, Readonly<[NumberRange<1, 12>, NumberRange<1, 31>]>]>>;
|
|
313
|
+
/** Zodiac metadata options */
|
|
314
|
+
export interface ZodiacMetaOptions<Sign extends string = ZodiacSign> {
|
|
315
|
+
/**
|
|
316
|
+
* Optional Zodiac preset to use. Default is `western`.
|
|
317
|
+
* - **Note:** `western` and `tropical`, `vedic` and `sidereal` are same.
|
|
318
|
+
*/
|
|
319
|
+
preset?: ZodiacPreset;
|
|
320
|
+
/** Custom Zodiac date ranges, overrides {@link preset presets}. */
|
|
321
|
+
custom?: ZodiacArray<Sign> | Readonly<ZodiacArray<Sign>>;
|
|
322
|
+
}
|
|
313
323
|
/** Options for configuring Zodiac sign getter */
|
|
314
|
-
export interface ZodiacOptions {
|
|
315
|
-
/** - Optional birthdate in `MM-DD` format (1
|
|
324
|
+
export interface ZodiacOptions<Sign extends string = ZodiacSign> extends ZodiacMetaOptions<Sign> {
|
|
325
|
+
/** - Optional birthdate in `MM-DD` format (`1`-based month). */
|
|
316
326
|
birthDate?: MonthDateString;
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
327
|
+
}
|
|
328
|
+
/** Represents resolved metadata for a zodiac sign */
|
|
329
|
+
export interface ZodiacMeta<Sign extends string = ZodiacSign> {
|
|
330
|
+
/**
|
|
331
|
+
* Index (`0`-based) of the zodiac sign within the resolved and chronologically sorted zodiac list.
|
|
332
|
+
*
|
|
333
|
+
* ⚠️ **Notes:**
|
|
334
|
+
* - The `index` is determined by the Gregorian month–day order of zodiac start dates and may differ between variants (e.g. Western vs Vedic).
|
|
335
|
+
* - This `index` should not be interpreted as a traditional or mythological zodiac ordering.
|
|
336
|
+
*/
|
|
337
|
+
index: number;
|
|
338
|
+
/** The zodiac sign name. */
|
|
339
|
+
sign: Sign;
|
|
340
|
+
/** Inclusive start date of the zodiac sign in `MM-DD` format. */
|
|
341
|
+
start: MonthDateString;
|
|
342
|
+
/** Inclusive end date of the zodiac sign in `MM-DD` format. */
|
|
343
|
+
end: MonthDateString;
|
|
321
344
|
}
|
|
322
345
|
/** - Represents the full name of a weekday, e.g., 'Monday', 'Tuesday' etc. */
|
|
323
346
|
export type WeekDay = (typeof DAYS)[number];
|
|
@@ -71,22 +71,20 @@ export const WESTERN_ZODIAC_SIGNS = /* @__PURE__ */ Object.freeze([
|
|
|
71
71
|
['Libra', [9, 23]],
|
|
72
72
|
['Scorpio', [10, 23]],
|
|
73
73
|
['Sagittarius', [11, 22]],
|
|
74
|
-
['Capricorn', [12, 22]],
|
|
75
74
|
]);
|
|
76
75
|
export const VEDIC_ZODIAC_SIGNS = /* @__PURE__ */ Object.freeze([
|
|
77
76
|
['Capricorn', [1, 14]],
|
|
78
77
|
['Aquarius', [2, 13]],
|
|
79
78
|
['Pisces', [3, 14]],
|
|
80
|
-
['Aries', [4,
|
|
81
|
-
['Taurus', [5,
|
|
82
|
-
['Gemini', [6,
|
|
79
|
+
['Aries', [4, 14]],
|
|
80
|
+
['Taurus', [5, 15]],
|
|
81
|
+
['Gemini', [6, 15]],
|
|
83
82
|
['Cancer', [7, 16]],
|
|
84
|
-
['Leo', [8,
|
|
85
|
-
['Virgo', [9,
|
|
86
|
-
['Libra', [10,
|
|
87
|
-
['Scorpio', [11,
|
|
88
|
-
['Sagittarius', [12,
|
|
89
|
-
['Capricorn', [1, 14]],
|
|
83
|
+
['Leo', [8, 17]],
|
|
84
|
+
['Virgo', [9, 17]],
|
|
85
|
+
['Libra', [10, 17]],
|
|
86
|
+
['Scorpio', [11, 16]],
|
|
87
|
+
['Sagittarius', [12, 16]],
|
|
90
88
|
]);
|
|
91
89
|
export const ZODIAC_PRESETS = /* @__PURE__ */ Object.freeze({
|
|
92
90
|
western: WESTERN_ZODIAC_SIGNS,
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { ZODIAC_PRESETS } from '../constants.js';
|
|
2
|
+
import { _padZero } from '../helpers.js';
|
|
2
3
|
export const zodiacPlugin = ($Chronos) => {
|
|
4
|
+
function _toHundreds(range) {
|
|
5
|
+
return range[0] * 100 + range[1];
|
|
6
|
+
}
|
|
7
|
+
function _resolveSigns(options) {
|
|
8
|
+
const { preset = 'western', custom } = options ?? {};
|
|
9
|
+
const sorted = [...(custom ?? ZODIAC_PRESETS[preset])].sort((a, b) => _toHundreds(a[1]) - _toHundreds(b[1]));
|
|
10
|
+
return sorted;
|
|
11
|
+
}
|
|
3
12
|
$Chronos.prototype.getZodiacSign = function (options) {
|
|
4
|
-
const { birthDate
|
|
13
|
+
const { birthDate } = options ?? {};
|
|
5
14
|
let month;
|
|
6
15
|
let date;
|
|
7
16
|
if (birthDate && birthDate?.includes('-')) {
|
|
@@ -11,16 +20,34 @@ export const zodiacPlugin = ($Chronos) => {
|
|
|
11
20
|
month = this.isoMonth;
|
|
12
21
|
date = this.date;
|
|
13
22
|
}
|
|
14
|
-
const
|
|
15
|
-
for (let i =
|
|
16
|
-
const [sign, [m, d]] =
|
|
23
|
+
const sortedSigns = _resolveSigns(options);
|
|
24
|
+
for (let i = sortedSigns.length - 1; i >= 0; i--) {
|
|
25
|
+
const [sign, [m, d]] = sortedSigns[i];
|
|
17
26
|
if (month > m || (month === m && date >= d)) {
|
|
18
27
|
return sign;
|
|
19
28
|
}
|
|
29
|
+
if (i === 0) {
|
|
30
|
+
return sortedSigns.at(-1)[0];
|
|
31
|
+
}
|
|
20
32
|
}
|
|
21
|
-
return
|
|
33
|
+
return sortedSigns[0][0];
|
|
22
34
|
};
|
|
23
35
|
$Chronos.prototype.zodiac = function (options) {
|
|
24
36
|
return this.getZodiacSign(options);
|
|
25
37
|
};
|
|
38
|
+
$Chronos.prototype.getZodiacMeta = function (sign, options) {
|
|
39
|
+
const sortedSigns = _resolveSigns(options);
|
|
40
|
+
const index = sortedSigns.findIndex(([s]) => s === sign);
|
|
41
|
+
if (index === -1) {
|
|
42
|
+
throw new RangeError(`Invalid zodiac sign: "${sign}"`);
|
|
43
|
+
}
|
|
44
|
+
const [startMonth, startDate] = sortedSigns[index][1];
|
|
45
|
+
const [endMonth, endDate] = (sortedSigns[index + 1] ?? sortedSigns[0])[1];
|
|
46
|
+
return {
|
|
47
|
+
index,
|
|
48
|
+
sign,
|
|
49
|
+
start: `${_padZero(startMonth)}-${_padZero(startDate)}`,
|
|
50
|
+
end: `${_padZero(endMonth)}-${_padZero(endDate - 1)}`,
|
|
51
|
+
};
|
|
52
|
+
};
|
|
26
53
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nhb-toolbox",
|
|
3
|
-
"version": "4.28.
|
|
3
|
+
"version": "4.28.64",
|
|
4
4
|
"description": "A versatile collection of smart, efficient, and reusable utility functions, classes and types for everyday development needs.",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@eslint/js": "^9.39.2",
|
|
48
48
|
"@types/jest": "^30.0.0",
|
|
49
|
-
"@types/node": "^25.0.
|
|
50
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
51
|
-
"@typescript-eslint/parser": "^8.
|
|
49
|
+
"@types/node": "^25.0.6",
|
|
50
|
+
"@typescript-eslint/eslint-plugin": "^8.53.0",
|
|
51
|
+
"@typescript-eslint/parser": "^8.53.0",
|
|
52
52
|
"eslint": "^9.39.2",
|
|
53
53
|
"eslint-config-prettier": "^10.1.8",
|
|
54
54
|
"eslint-plugin-prettier": "^5.5.4",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"prettier": "^3.7.4",
|
|
61
61
|
"ts-jest": "^29.4.6",
|
|
62
62
|
"typescript": "^5.9.3",
|
|
63
|
-
"typescript-eslint": "^8.
|
|
63
|
+
"typescript-eslint": "^8.53.0"
|
|
64
64
|
},
|
|
65
65
|
"keywords": [
|
|
66
66
|
"toolbox",
|