This repository has been archived on 2025-06-27. You can view files and clone it, but cannot push or open issues or pull requests.
Files
tingle-bot/src/modules/weather/getSeason.ts

32 lines
783 B
TypeScript

/**
* @copyright nhcarrigan
* @license Naomi's Public License
* @author Naomi Carrigan
*/
import type { Season } from "../../interfaces/weather/names/season.js";
/**
* Module to get the season based on today's date.
* Winter: Dec 21 - March 20.
* Spring: March 21 - June 20.
* Summer: June 21st - September 22.
* Fall: September 23 - December 21.
* @returns The season name.
*/
export const getSeason = (): Season => {
const date = new Date();
const month = date.getMonth();
const day = date.getDate();
if (month < 2 || month === 2 && day < 21 || month === 11 && day > 20) {
return "Winter";
}
if (month < 5 || month === 5 && day < 21) {
return "Spring";
}
if (month < 8 || month === 8 && day < 23) {
return "Summer";
}
return "Fall";
};