Zodiac Plugin
Zodiac Plugin — Chronos Plugin Documentation.
About Zodiac Plugin
Zodiac plugin is a plugin that adds zodiac related functionalities to Chronos.
Import & Usage
Import
To use the Zodiac Plugin, import it first:
import { Chronos, chronos } from "chronos-date";
import { zodiacPlugin } from 'chronos-date/plugins/zodiacPlugin';Register
Now you can use the plugin's methods:
// Register the plugin globally
Chronos.use(zodiacPlugin);
// or
chronos.use(zodiacPlugin);
// or
Chronos.register(zodiacPlugin);
// or
chronos.register(zodiacPlugin);Usage
Example usage of the zodiacPlugin:
const c = new Chronos();
const zodiac = c.getZodiacSign();
console.log(zodiac);Example Usage
Overview
The zodiacPlugin adds comprehensive zodiac functionalities to Chronos, enabling:
- Determining the current zodiac sign based on either predefined regional presets
- Getting detailed metadata for a specific zodiac sign
Methods Added by the Plugin
Note
All these methods are provided by zodiacPlugin. You must register it using Chronos.use(zodiacPlugin) before calling them. Once registered, all Chronos instances will have access to these methods.
| Method | Description | Returns |
|---|---|---|
getZodiacSign | Determines the current zodiac sign based on either predefined regional presets | string |
getZodiacMeta | Gets detailed metadata for a specific zodiac sign. | ZodiacMeta<string> |
API Reference
getZodiacSign()
Signature
getZodiacSign<Sign extends string = ZodiacSign>(options?: ZodiacOptions<Sign>): SignAlias
zodiacis an alias forgetZodiacSignmethod.
Overview
The getZodiacSign() method determines the zodiac sign based on either predefined presets (Western or Vedic) or custom zodiac definitions. It supports both instance date and custom birthdate inputs.
Usage
Configuration
ZodiacOptions
interface ZodiacOptions<Sign extends string = ZodiacSign> {
birthDate?: MonthDateString; // 'MM-DD' format (1-based month)
preset?: ZodiacPreset; // 'western' | 'vedic' | 'tropical' | 'sidereal'
custom?: ZodiacArray<Sign> | Readonly<ZodiacArray<Sign>>; // Custom zodiac definitions
}birthDate: Optional date in'MM-DD'format to use instead of instance datepreset: Name of predefined zodiac configuration (default:'western')custom: Custom array of zodiac definitions (overrides preset if provided)
Available Presets
[
['Capricorn', [12, 22]],
['Aquarius', [1, 20]],
['Pisces', [2, 19]],
['Aries', [3, 21]],
['Taurus', [4, 20]],
['Gemini', [5, 21]],
['Cancer', [6, 21]],
['Leo', [7, 23]],
['Virgo', [8, 23]],
['Libra', [9, 23]],
['Scorpio', [10, 23]],
['Sagittarius', [11, 22]]
]Custom Zodiac
You can create custom zodiac configurations by providing your own array of zodiac definitions with any zodiac sign names:
const customZodiac = [
['Capricorn', [1, 1]],
['Sagittarius', [2, 1]],
['A', [3, 1]],
['B', [6, 1]],
['C', [9, 1]],
['D', [12, 1]],
// ...other signs, zodiac names can be any string
] as const;
const currentSign = new Chronos().getZodiacSign({ custom: customZodiac });Type Definitions
type ZodiacPreset = 'western' | 'vedic' | 'tropical' | 'sidereal';
type ZodiacSign = 'Aries' | 'Taurus' | ...; // All zodiac sign names
type ZodiacArray<Sign extends string = ZodiacSign> = Array<
[Sign, [NumberRange<1, 12>, NumberRange<1, 31>]] | Readonly<[Sign, Readonly<[NumberRange<1, 12>, NumberRange<1, 31>]>]>
>;Date Handling
- Month values are 1-based (1 = January)
- Supports both instance date and custom
birthDateinput - Returns the first sign if no matches found (shouldn't occur with presets or proper definitions)
getZodiacMeta()
Signature
getZodiacMeta<Sign extends string = ZodiacSign>(sign: Sign, options?: ZodiacMetaOptions<Sign>): ZodiacMeta<Sign>Overview
The getZodiacMeta() method retrieves detailed metadata for a specific zodiac sign based on either predefined presets (Western or Vedic) or custom zodiac definitions. It returns the sign's chronological position, inclusive date range, and handles year-boundary wrapping correctly.
Usage
Configuration
ZodiacMetaOptions
interface ZodiacMetaOptions<Sign extends string = ZodiacSign> {
preset?: ZodiacPreset; // 'western' | 'vedic' | 'tropical' | 'sidereal'
custom?: ZodiacArray<Sign> | Readonly<ZodiacArray<Sign>>; // Custom zodiac definitions
}preset: Name of predefined zodiac configuration (default:'western')custom: Custom array of zodiac definitions (overrides preset if provided)
Return Value
ZodiacMeta
interface ZodiacMeta<Sign extends string = ZodiacSign> {
index: number; // 0-based chronological position
sign: Sign; // The zodiac sign name
start: MonthDateString; // Inclusive start date in 'MM-DD' format
end: MonthDateString; // Inclusive end date in 'MM-DD' format
}index
The index property represents the chronological position (0-based) of the zodiac sign within the resolved and sorted zodiac list.
Important Notes about Index
- The index is determined by the Gregorian month–day ordering of zodiac start dates
- Index values may differ between zodiac variants (e.g., Western vs Vedic)
- This index should not be interpreted as a traditional or mythological zodiac ordering
- It's primarily useful for programmatic sorting and comparison within the same zodiac variant
Available Presets
The same presets as getZodiacSign() are available:
[
['Aquarius', [1, 20]], // index: 0
['Pisces', [2, 19]], // index: 1
['Aries', [3, 21]], // index: 2
['Taurus', [4, 20]], // index: 3
['Gemini', [5, 21]], // index: 4
['Cancer', [6, 21]], // index: 5
['Leo', [7, 23]], // index: 6
['Virgo', [8, 23]], // index: 7
['Libra', [9, 23]], // index: 8
['Scorpio', [10, 23]], // index: 9
['Sagittarius', [11, 22]] // index: 10
['Capricorn', [12, 22]], // index: 11
]Year-Boundary Handling
The method correctly handles zodiac signs that wrap around year boundaries:
Error Handling
The method throws a RangeError if the provided sign does not exist in the resolved zodiac list:
Common Use Cases
1 Display sign information:
function displayZodiacInfo(sign: string) {
const meta = chronos.getZodiacMeta(sign);
console.log(`${meta.sign}: ${meta.start} to ${meta.end}`);
}2 Sort signs chronologically:
const signs = ['Leo', 'Aries', 'Capricorn', 'Libra'];
const sortedSigns = signs.sort((a, b) => {
const metaA = chronos.getZodiacMeta(a);
const metaB = chronos.getZodiacMeta(b);
return metaA.index - metaB.index;
});
// Result: ['Aries', 'Leo', 'Libra', 'Capricorn']3 Validate date ranges:
function isDateInSign(date: MonthDateString, sign: string): boolean {
const meta = chronos.getZodiacMeta(sign);
// Implementation to check if date falls within meta.start to meta.end
// considering year-boundary wrapping
}Last updated: Wed, Jun 24, 2026 09:04:13AM (UTC)
