Season Plugin
Season Plugin — Chronos Plugin Documentation.
About Season Plugin
Season plugin is a plugin that adds season related functionalities to Chronos.
Import & Usage
Import
To use the Season Plugin, import it first:
import { Chronos, chronos } from "chronos-date";
import { seasonPlugin } from 'chronos-date/plugins/seasonPlugin';Register
Now you can use the plugin's methods:
// Register the plugin globally
Chronos.use(seasonPlugin);
// or
chronos.use(seasonPlugin);
// or
Chronos.register(seasonPlugin);
// or
chronos.register(seasonPlugin);Usage
Example usage of the seasonPlugin:
const c = new Chronos();
const season = c.season();
console.log(season);Example Usage
Overview
The seasonPlugin adds comprehensive season related functionalities to Chronos, enabling:
- Determining the current season based on either predefined regional presets or custom season definitions
Methods Added by the Plugin
Note
All these methods are provided by seasonPlugin. You must register it using Chronos.use(seasonPlugin) before calling them. Once registered, all Chronos instances will have access to these methods.
| Method | Description | Returns |
|---|---|---|
season | Determines the current season based on either predefined regional presets | string |
API Reference
season()
Get season name
Signature
season(options?: SeasonOptions): stringAlias
getSeasonNameis an alias forseasonmethod.
Overview
The season() method determines the current season based on either predefined regional presets or custom season definitions. It supports both month-based and exact date-based season boundaries.
Usage
Configuration
SeasonOptions
interface SeasonOptions {
seasons?: SeasonDefinition[];
preset?: SeasonPreset;
}seasons: Custom array of season definitions (overrides preset if provided)preset: Name of predefined season configuration (default:'default'- Western Seasons)
SeasonDefinition
interface SeasonDefinition {
name: string;
boundary: MonthBoundary | DateBoundary;
}Boundary can be either:
- Month-based:
{ startMonth: 0-11, endMonth: 0-11 }(0=January) - Date-based:
{ startDate: 'MM-DD', endDate: 'MM-DD' }
Boundary Handling
- Supports wrap-around seasons (e.g., Winter: Dec-Feb)
- Boundaries are inclusive
- Returns
'Unknown'if no season matches
Available Presets
[
{ name: 'Spring', boundary: { startMonth: 2, endMonth: 4 } }, // Mar-May
{ name: 'Summer', boundary: { startMonth: 5, endMonth: 7 } }, // Jun-Aug
{ name: 'Autumn', boundary: { startMonth: 8, endMonth: 10 } }, // Sep-Nov
{ name: 'Winter', boundary: { startMonth: 11, endMonth: 1 } } // Dec-Feb
]Custom Seasons
You can create completely custom season configurations by providing your own array of SeasonDefinition objects:
const gamingSeasons = [
{ name: 'Pre-Season', boundary: { startMonth: 0, endMonth: 2 } },
{ name: 'Competitive', boundary: { startDate: '03-01', endDate: '09-30' } },
{ name: 'Off-Season', boundary: { startMonth: 10, endMonth: 11 } }
];
const currentSeason = new Chronos().season({ seasons: gamingSeasons });Type Definitions
type SeasonPreset =
| 'default'
| 'bangladesh'
| 'india'
| 'tamil'
| 'vedic'
| 'philippines'
| 'academic_us'
| 'japan'
| 'australia'
| 'ethiopia';
type MonthDateString = `${MonthString}-${DateString}`; // 'MM-DD' format
interface DateBoundary {
startDate: MonthDateString;
endDate: MonthDateString;
}
interface MonthBoundary {
startMonth: number; // 0-11 (0=January)
endMonth: number; // 0-11
}Note
When using month-based boundaries (MonthBoundary), the season calculation only considers the month component and ignores specific dates within the month.
Last updated: Wed, Jun 24, 2026 09:04:13AM (UTC)
